Browse Source

feat: 新增提交失败提示文案并优化作业提交错误处理

新增多语言的提交失败提示文案,优化作业提交时的错误提示逻辑,使用统一的多语言提示,同时在错误日志中补充错误信息记录
lsc 2 days ago
parent
commit
68187be471

+ 20 - 2
src/components/CreateCourseDialog.vue

@@ -95,7 +95,7 @@
 </template>
 
 <script lang="ts" setup>
-import { ref } from 'vue'
+import { ref, watch } from 'vue'
 import useImport from '@/hooks/useImport'
 import FileInput from '@/components/FileInput.vue'
 import message from '@/utils/message'
@@ -109,7 +109,7 @@ const emit = defineEmits<{
   (e: 'setTitle', title: string, type: number): void
 }>()
 
-const { importPPTXFile, exporting } = useImport()
+const { importPPTXFile, exporting, imgExporting } = useImport()
 const mainStore = useMainStore()
 const { setRunningState } = mainStore
 const currentFileName = ref('')
@@ -157,6 +157,24 @@ const handleFileUpload = async (files: FileList) => {
       //     console.log('取消删除')
       //   },
       // })
+      // 等图片上传完毕(imgExporting === false)后触发保存
+      const trySave = () => {
+        const parentWindow = window.parent as any
+        parentWindow?.save?.(3)
+      }
+      if (imgExporting.value === false) {
+        // 没有图片需要上传,立即保存
+        trySave()
+      }
+      else {
+        // 有图片正在上传,等上传完毕再保存
+        const stopWatch = watch(imgExporting, (val) => {
+          if (val === false) {
+            stopWatch()
+            trySave()
+          }
+        })
+      }
     } })
   }
   catch (error) {

+ 4 - 4
src/views/Student/index.vue

@@ -2365,8 +2365,8 @@ const handleHomeworkSubmit = async () => {
               console.log('使用html-to-image截图成功')
             }
             catch (htmlToImageError) {
-              console.log('html-to-image也失败了', htmlToImageError)
-              message.error(lang.ssHtmlToImageFailed + htmlToImageError)
+              console.log('html-to-image也失败了', htmlToImageError) // 
+              message.error(lang.ssHtmlToImageFailed)
               message.error(lang.ssShotFail)
               return
               /*
@@ -2580,10 +2580,10 @@ const handleHomeworkSubmit = async () => {
   }
   catch (error) {
     console.error('作业提交过程中出错:', error)
-    message.error('作业提交过程中出错:' + error)
+    message.error(lang.ssSubmitFailed)
     message.error(lang.ssHwSubmitFail)
     isSubmitting.value = false
-    addOp3(1, new Date().getTime(), { courseid: props.courseid, homeworkContent }, 'error')
+    addOp3(1, new Date().getTime(), { courseid: props.courseid, homeworkContent, error }, 'error')
   }
   finally {
     // isSubmitting.value = false

+ 2 - 1
src/views/lang/cn.json

@@ -1130,5 +1130,6 @@
   "ssFile": "文件上传",
   "ssClickToPreview": "点击预览",
   "ssClickToOpen": "点击打开",
-  "ssAccuracy2": "正确率"
+  "ssAccuracy2": "正确率",
+  "ssSubmitFailed": "提交失败,互动模块暂时无法通信,请重试或重载"
 }

+ 2 - 1
src/views/lang/en.json

@@ -1130,5 +1130,6 @@
   "ssFile": "File Upload",
   "ssClickToPreview": "Click to Preview",
   "ssClickToOpen": "Click to Open",
-  "ssAccuracy2": "accuracy rate"
+  "ssAccuracy2": "accuracy rate",
+  "ssSubmitFailed": "Submit failed, interactive module is temporarily unresponsive, please try again or reload the page"
 }

+ 2 - 1
src/views/lang/hk.json

@@ -1130,5 +1130,6 @@
   "ssFile": "文件上傳",
   "ssClickToPreview": "點擊預覽",
   "ssClickToOpen": "點擊打開",
-  "ssAccuracy2": "正確率"
+  "ssAccuracy2": "正確率",
+  "ssSubmitFailed": "提交失敗,互動模塊暫時無法通訊,請重試或重新加載頁面"
 }