dsy před 1 měsícem
rodič
revize
10663af930

+ 1 - 1
package.json

@@ -19,7 +19,7 @@
     "book-ui": "file:../GCLS-Book-UI/book-ui-0.4.31.tgz",
     "core-js": "^3.36.1",
     "dayjs": "^1.11.10",
-    "eep-ui": "file:../GCLS-Book-UI/eep-ui-0.0.60.tgz",
+    "eep-ui": "file:../GCLS-Book-UI/eep-ui-0.0.61.tgz",
     "element-ui": "^2.15.14",
     "jquery": "^3.7.1",
     "js-base64": "^3.7.7",

+ 54 - 20
src/components/course/FinishCourseware.vue

@@ -118,7 +118,8 @@ export default {
       dialogWidth: '860px',
       themeColor: '',
       bookFontSize: '',
-      previewType: 'previewCheckShow'
+      previewType: 'previewCheckShow',
+      submitting: false
     };
   },
   watch: {
@@ -198,30 +199,63 @@ export default {
         });
     },
 
-    finishTaskMaterial() {
+    async finishTaskMaterial() {
+      if (this.submitting) return;
       if (this.exam_answer.length === 0 && this.category === 'GCLS') {
         this.$message.warning(this.$i18n.t('Key333'));
         return;
       }
-      if (this.category === 'EEP') {
-        this.exam_answer = this.$refs.eep.getAllComponentUserAnswer();
-      }
-      const loading = this.$loading();
-      FinishMyTaskMaterial_Student({
-        task_id: this.id,
-        material_type: 'COURSEWARE',
-        material_id: this.coursewareId,
-        exam_answer: this.exam_answer
-      })
-        .then(() => {
-          this.$message.success(this.$i18n.t('Key334'));
-          this.dialogClose();
-          this.$router.go(0);
-        })
-        .finally(() => {
-          loading.close();
-          this.exam_answer = '';
+
+      this.submitting = true;
+      let loading = null;
+      try {
+        if (this.category === 'EEP') {
+          loading = this.$loading({ lock: true, text: '正在提交,请稍候…' });
+          // 录音在“停止录音”时已异步上传,这里先停止仍在录制的录音并等待上传完成,
+          // 避免把 MB 级 base64 录音内联进答案导致提交请求超时
+          const eep = this.$refs.eep;
+          if (!eep || typeof eep.getAllComponentUserAnswer !== 'function') {
+            loading.close();
+            loading = null;
+            this.$message.error('课件尚未加载完成,请稍后重试');
+            return;
+          }
+          if (typeof eep.waitForPendingRecordings === 'function') {
+            const { timedOut } = await eep.waitForPendingRecordings();
+            const { oversize } =
+              typeof eep.validateAnswerSize === 'function' ? eep.validateAnswerSize() : { oversize: [] };
+            if (timedOut || oversize.length > 0) {
+              loading.close();
+              loading = null;
+              this.$message.error(
+                timedOut
+                  ? '录音上传超时,请检查网络后重试'
+                  : `有 ${oversize.length} 处录音未能上传,请稍后重试或重新录制`
+              );
+              return;
+            }
+          }
+          this.exam_answer = eep.getAllComponentUserAnswer();
+        }
+
+        if (!loading) loading = this.$loading();
+        await FinishMyTaskMaterial_Student({
+          task_id: this.id,
+          material_type: 'COURSEWARE',
+          material_id: this.coursewareId,
+          exam_answer: this.exam_answer
         });
+        this.$message.success(this.$i18n.t('Key334'));
+        this.dialogClose();
+        this.$router.go(0);
+      } catch (e) {
+        // 请求错误已由响应拦截器提示,这里只兜底非请求异常
+        if (!e || !e.isAxiosError) this.$message.error('提交失败,请稍后重试');
+      } finally {
+        if (loading) loading.close();
+        this.submitting = false;
+        this.exam_answer = '';
+      }
     },
 
     dialogClose() {

+ 53 - 19
src/components/live/CurMaterial.vue

@@ -197,7 +197,8 @@ export default {
       text: '',
       themeColor: '',
       bookFontSize: '',
-      refresh: true
+      refresh: true,
+      submitting: false
     };
   },
   computed: {
@@ -399,29 +400,62 @@ export default {
         });
     },
 
-    finishTaskMaterial() {
+    async finishTaskMaterial() {
+      if (this.submitting) return;
       if (this.material_type === 'COURSEWARE' && this.exam_answer.length === 0 && this.category === 'GCLS') {
         this.$message.warning(this.$i18n.t('Key333'));
         return;
       }
-      if (this.category === 'EEP') {
-        this.exam_answer = this.$refs.eep.getAllComponentUserAnswer();
-      }
-      const loading = this.$loading();
-      FinishMyMaterial({
-        task_id: this.taskId,
-        material_id: this.material_id,
-        material_type: this.material_type,
-        exam_answer: this.exam_answer
-      })
-        .then(() => {
-          this.$message.success(this.$i18n.t('Key623'));
-          this.dialogMaterialClose();
-        })
-        .finally(() => {
-          loading.close();
-          this.exam_answer = '';
+
+      this.submitting = true;
+      let loading = null;
+      try {
+        if (this.category === 'EEP') {
+          loading = this.$loading({ lock: true, text: '正在提交,请稍候…' });
+          // 录音在“停止录音”时已异步上传,这里先停止仍在录制的录音并等待上传完成,
+          // 避免把 MB 级 base64 录音内联进答案导致提交请求超时
+          const eep = this.$refs.eep;
+          if (!eep || typeof eep.getAllComponentUserAnswer !== 'function') {
+            loading.close();
+            loading = null;
+            this.$message.error('课件尚未加载完成,请稍后重试');
+            return;
+          }
+          if (typeof eep.waitForPendingRecordings === 'function') {
+            const { timedOut } = await eep.waitForPendingRecordings();
+            const { oversize } =
+              typeof eep.validateAnswerSize === 'function' ? eep.validateAnswerSize() : { oversize: [] };
+            if (timedOut || oversize.length > 0) {
+              loading.close();
+              loading = null;
+              this.$message.error(
+                timedOut
+                  ? '录音上传超时,请检查网络后重试'
+                  : `有 ${oversize.length} 处录音未能上传,请稍后重试或重新录制`
+              );
+              return;
+            }
+          }
+          this.exam_answer = eep.getAllComponentUserAnswer();
+        }
+
+        if (!loading) loading = this.$loading();
+        await FinishMyMaterial({
+          task_id: this.taskId,
+          material_id: this.material_id,
+          material_type: this.material_type,
+          exam_answer: this.exam_answer
         });
+        this.$message.success(this.$i18n.t('Key623'));
+        this.dialogMaterialClose();
+      } catch (e) {
+        // 请求错误已由响应拦截器提示,这里只兜底非请求异常
+        if (!e || !e.isAxiosError) this.$message.error('提交失败,请稍后重试');
+      } finally {
+        if (loading) loading.close();
+        this.submitting = false;
+        this.exam_answer = '';
+      }
     },
 
     /**

+ 0 - 1
src/utils/request.js

@@ -1,5 +1,4 @@
 import axios from 'axios';
-import store from '@/store';
 import { Message } from 'element-ui';
 import { getToken } from '@/utils/auth';