lsc 1 день тому
батько
коміт
178ea20df3
3 змінених файлів з 27 додано та 4 видалено
  1. 20 0
      package-lock.json
  2. 1 0
      package.json
  3. 6 4
      src/views/Student/index.vue

+ 20 - 0
package-lock.json

@@ -52,6 +52,7 @@
         "@tsconfig/node18": "^18.2.2",
         "@types/crypto-js": "^4.2.1",
         "@types/file-saver": "^2.0.7",
+        "@types/html2canvas": "^1.0.0",
         "@types/lodash": "^4.14.202",
         "@types/node": "^18.19.3",
         "@types/qs": "^6.14.0",
@@ -1368,6 +1369,16 @@
       "integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==",
       "dev": true
     },
+    "node_modules/@types/html2canvas": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/@types/html2canvas/-/html2canvas-1.0.0.tgz",
+      "integrity": "sha512-BJpVf+FIN9UERmzhbtUgpXj6XBZpG67FMgBLLoj9HZKd9XifcCpSV+UnFcwTZfEyun4U/KmCrrVOG7829L589w==",
+      "deprecated": "This is a stub types definition. html2canvas provides its own type definitions, so you do not need this installed.",
+      "dev": true,
+      "dependencies": {
+        "html2canvas": "*"
+      }
+    },
     "node_modules/@types/json-schema": {
       "version": "7.0.15",
       "resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz",
@@ -6579,6 +6590,15 @@
       "integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==",
       "dev": true
     },
+    "@types/html2canvas": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/@types/html2canvas/-/html2canvas-1.0.0.tgz",
+      "integrity": "sha512-BJpVf+FIN9UERmzhbtUgpXj6XBZpG67FMgBLLoj9HZKd9XifcCpSV+UnFcwTZfEyun4U/KmCrrVOG7829L589w==",
+      "dev": true,
+      "requires": {
+        "html2canvas": "*"
+      }
+    },
     "@types/json-schema": {
       "version": "7.0.15",
       "resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz",

+ 1 - 0
package.json

@@ -59,6 +59,7 @@
     "@tsconfig/node18": "^18.2.2",
     "@types/crypto-js": "^4.2.1",
     "@types/file-saver": "^2.0.7",
+    "@types/html2canvas": "^1.0.0",
     "@types/lodash": "^4.14.202",
     "@types/node": "^18.19.3",
     "@types/qs": "^6.14.0",

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

@@ -650,15 +650,15 @@ const handleHomeworkSubmit = async () => {
             const submitArgs = [iframeSlideIndex]
 
             // 支持同步和异步submitWork
-            const result = iframeWindow.submitWork(...submitArgs)
+            const result = await iframeWindow.submitWork(...submitArgs)
             if (result instanceof Promise) {
               await result
               console.log('submitWork异步执行完成')
-              message.success('作业提交成功')
-              hasSubmitWork = true
             } 
             else {
               console.log('submitWork同步执行完成')
+              message.success('作业提交成功')
+              hasSubmitWork = true
             }
 
             break
@@ -687,6 +687,8 @@ const handleHomeworkSubmit = async () => {
       }
       else {
         console.log('尝试截图当前页面并提交')
+        return
+        /*
         try {
           // 尝试使用html2canvas,对iframe支持更好
           let imageData: string
@@ -742,7 +744,7 @@ const handleHomeworkSubmit = async () => {
         catch (error) {
           console.error('截图提交失败:', error)
           message.error('截图提交失败')
-        }
+        }*/
       }
     }