lex hai 1 ano
pai
achega
a3c1538801
Modificáronse 1 ficheiros con 53 adicións e 27 borrados
  1. 53 27
      src/views/attend-class/index.tsx

+ 53 - 27
src/views/attend-class/index.tsx

@@ -5,8 +5,7 @@ import {
   onUnmounted,
   ref,
   Transition,
-  computed,
-  nextTick
+  computed
 } from 'vue';
 import styles from './index.module.less';
 import 'plyr/dist/plyr.css';
@@ -49,6 +48,7 @@ import beatIcon from '/src/components/layout/images/beatIcon.png';
 import toneIcon from '/src/components/layout/images/toneIcon.png';
 import { px2vw } from '/src/utils';
 import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
+import { state } from '/src/state';
 export type ToolType = 'init' | 'pen' | 'whiteboard';
 export type ToolItem = {
   type: ToolType;
@@ -58,7 +58,26 @@ export type ToolItem = {
 
 export default defineComponent({
   name: 'CoursewarePlay',
-  setup() {
+  props: {
+    type: {
+      type: String,
+      default: ''
+    },
+    subjectId: {
+      type: [String, Number],
+      default: ''
+    },
+    detailId: {
+      type: String,
+      default: ''
+    },
+    classGroupId: {
+      type: String,
+      default: ''
+    }
+  },
+  emits: ['close'],
+  setup(props, { emit }) {
     const message = useMessage();
     const route = useRoute();
     /** 设置播放容器 16:9 */
@@ -101,10 +120,7 @@ export default defineComponent({
       modelAttendStatus: false, // 布置作业提示弹窗
       modalAttendMessage: '本节课未设置课后训练,是否继续?',
       modelTrainStatus: false, // 训练设置
-      homeworkStatus: true, // 布置作业完成时
-      removeVisiable: false,
-      removeTitle: '',
-      removeContent: ''
+      homeworkStatus: true // 布置作业完成时
     });
     const activeData = reactive({
       // isAutoPlay: false, // 是否自动播放
@@ -292,10 +308,11 @@ export default defineComponent({
 
     onMounted(() => {
       const query = route.query;
-      data.type = query.type as any;
-      data.subjectId = query.subjectId;
-      data.detailId = query.detailId;
-      data.classGroupId = query.classGroupId;
+      // 先取参数,
+      data.type = props.type || (query.type as any);
+      data.subjectId = props.subjectId || query.subjectId;
+      data.detailId = props.detailId || query.detailId;
+      data.classGroupId = props.classGroupId || query.classGroupId;
       initMoveable();
       window.addEventListener('message', iframeHandle);
       getDetail();
@@ -341,7 +358,7 @@ export default defineComponent({
         }
 
         if (activeItem.type === 'SONG' && activeItem.audioEle) {
-          activeItem.audioEle?.stop();
+          activeItem.audioEle.stop();
         }
         // console.log('🚀 ~ activeItem:', activeItem)
         // 停止曲谱的播放
@@ -510,12 +527,9 @@ export default defineComponent({
               clearTimeout(activeData.timer);
               message.destroyAll();
               // item.autoPlay = false;
-              nextTick(() => {
-                if (item.error) {
-                  item.videoEle?.src(item.content);
-                  //   item.videoEle?.onPlay();
-                }
-              });
+              // nextTick(() => {
+              //   item.videoEle?.play();
+              // });
             }
           }
           //   requestAnimationFrame(() => {
@@ -599,10 +613,10 @@ export default defineComponent({
       const activeItem = data.itemList[popupData.activeIndex];
       // 暂停视频和曲谱的播放
       if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
-        activeItem.videoEle?.stop();
+        activeItem.videoEle.pause();
       }
       if (activeItem.type === 'SONG' && activeItem.audioEle) {
-        activeItem.audioEle?.stop();
+        activeItem.audioEle.stop();
       }
       if (activeItem.type === 'MUSIC') {
         activeItem.iframeRef?.contentWindow?.postMessage(
@@ -731,9 +745,6 @@ export default defineComponent({
                               setModelOpen();
                             }
                           }}
-                          onError={() => {
-                            m.error = true;
-                          }}
                         />
                         <Transition name="van-fade">
                           {!m.isprepare && (
@@ -855,7 +866,13 @@ export default defineComponent({
           ]}
           onClick={async () => {
             if (data.type === 'preview') {
-              window.close();
+              handleStop();
+              if (state.application) {
+                emit('close');
+              } else {
+                window.close();
+              }
+
               // onFullScreen();
             } else {
               const res = await lessonPreTrainingPage({
@@ -974,7 +991,12 @@ export default defineComponent({
               round
               onClick={() => {
                 data.modelAttendStatus = false;
-                window.close();
+                handleStop();
+                if (state.application) {
+                  emit('close');
+                } else {
+                  window.close();
+                }
               }}>
               暂不布置
             </NButton>
@@ -1004,7 +1026,12 @@ export default defineComponent({
             onConfirm={() => {
               // 布置完作业之后直接关闭
               setTimeout(() => {
-                window.close();
+                handleStop();
+                if (state.application) {
+                  emit('close');
+                } else {
+                  window.close();
+                }
               }, 1000);
             }}
           />
@@ -1107,7 +1134,6 @@ export default defineComponent({
             <TimerMeter></TimerMeter>
           </div>
         </NModal>
-
         <NModal
           v-model:show={data.removeVisiable}
           preset="card"