Browse Source

fix(Student): 调整html2canvas配置以提高截图清晰度

修改html2canvas配置参数,将scale提高到2以增强截图清晰度,同时关闭allowTaint选项避免跨域污染问题
lsc 23 hours ago
parent
commit
801d154a5e
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/views/Student/index.vue

+ 11 - 7
src/views/Student/index.vue

@@ -1906,13 +1906,17 @@ const handleHomeworkSubmit = async () => {
             // 直接对iframe内部的body进行截图
             // 直接对iframe内部的body进行截图
             const html2canvas = await import('html2canvas')
             const html2canvas = await import('html2canvas')
             const canvas = await html2canvas.default(iframeBody, {
             const canvas = await html2canvas.default(iframeBody, {
-              useCORS: true,
-              allowTaint: true,
-              scale: 1,
-              backgroundColor: '#ffffff',
-              logging: false,
-              foreignObjectRendering: true,
-              removeContainer: true
+              // useCORS: true,
+              // allowTaint: true,
+              // scale: 1,
+              // backgroundColor: '#ffffff',
+              // logging: false,
+              // foreignObjectRendering: true,
+              // removeContainer: true
+              scale: 2, // 提高清晰度
+              allowTaint: false, // 是否允许跨域污染画布
+              useCORS: true, // 尝试跨域加载图片
+              logging: true,
             })
             })
             imageData = canvas.toDataURL('image/png', 0.95)
             imageData = canvas.toDataURL('image/png', 0.95)