lsc 2 viikkoa sitten
vanhempi
commit
61b0e83a97
1 muutettua tiedostoa jossa 33 lisäystä ja 33 poistoa
  1. 33 33
      src/views/Student/index.vue

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

@@ -1338,42 +1338,42 @@ const handleHomeworkSubmit = async () => {
                 throw new Error('无法创建canvas上下文')
               }*/
             }
-            const _a = iframeBody.getElementsByTagName('img')
-            const _b = iframeBody.getElementsByTagName('video')
-            for (let i = 0; i < _a.length; i++) {
-              _a[i].removeAttribute('crossorigin')
-            }
-            for (let i = 0; i < _b.length; i++) {
-              _b[i].removeAttribute('crossorigin')
-            }
-            // 将base64字符串转换为File对象
-            const base64ToFile = (base64String: string, filename: string): File => {
-              const arr = base64String.split(',')
-              const mime = arr[0].match(/:(.*?);/)?.[1] || 'image/png'
-              const bstr = atob(arr[1])
-              let n = bstr.length
-              const u8arr = new Uint8Array(n)
-              while (n--) {
-                u8arr[n] = bstr.charCodeAt(n)
-              }
-              return new File([u8arr], filename, { type: mime })
+          }
+          const _a = iframeBody.getElementsByTagName('img')
+          const _b = iframeBody.getElementsByTagName('video')
+          for (let i = 0; i < _a.length; i++) {
+            _a[i].removeAttribute('crossorigin')
+          }
+          for (let i = 0; i < _b.length; i++) {
+            _b[i].removeAttribute('crossorigin')
+          }
+          // 将base64字符串转换为File对象
+          const base64ToFile = (base64String: string, filename: string): File => {
+            const arr = base64String.split(',')
+            const mime = arr[0].match(/:(.*?);/)?.[1] || 'image/png'
+            const bstr = atob(arr[1])
+            let n = bstr.length
+            const u8arr = new Uint8Array(n)
+            while (n--) {
+              u8arr[n] = bstr.charCodeAt(n)
             }
+            return new File([u8arr], filename, { type: mime })
+          }
           
-            const imageFile = base64ToFile(imageData, `screenshot_${Date.now()}.png`)
-            const imageUrl = await uploadFile(imageFile)
-            // 提交截图
-            await submitWork(slideIndex.value, '73', imageUrl, '1') // 73表示截图工具,21表示图片类型
-            message.success('页面截图提交成功')
-            hasSubmitWork = true
+          const imageFile = base64ToFile(imageData, `screenshot_${Date.now()}.png`)
+          const imageUrl = await uploadFile(imageFile)
+          // 提交截图
+          await submitWork(slideIndex.value, '73', imageUrl, '1') // 73表示截图工具,21表示图片类型
+          message.success('页面截图提交成功')
+          hasSubmitWork = true
           
-            // 发送作业提交成功的socket消息
-            sendMessage({
-              type: 'homework_submitted',
-              courseid: props.courseid,
-              slideIndex: slideIndex.value,
-              userid: props.userid
-            })
-          }
+          // 发送作业提交成功的socket消息
+          sendMessage({
+            type: 'homework_submitted',
+            courseid: props.courseid,
+            slideIndex: slideIndex.value,
+            userid: props.userid
+          })
         }
         catch (error) {
           console.error('截图提交失败:', error)