jack 3 days ago
parent
commit
88d5c096b0
1 changed files with 14 additions and 14 deletions
  1. 14 14
      src/views/Student/index.vue

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

@@ -1503,11 +1503,15 @@ const processIframeLinks = async () => {
                   // 如果无法获取contentWindow,使用HTML方式
                   let html = null
                   try {
-                      const fileData2 = await getFile2(iframeSrc)
-                      if (fileData2 && fileData2.data) {
-                        const uint8Array = new Uint8Array(fileData2.data)
-                        html = new TextDecoder('utf-8').decode(uint8Array)
-                        console.log('getFile2 成功获取内容:', html)
+                      console.log(`getFile2 失败,尝试使用 getHTML:`, error2)
+                      try {
+                        html = await api.getHTML(iframeSrc)
+                        console.log('getHTML 成功获取内容:', html)
+                      }
+                      catch (htmlError) {
+                        console.error('getHTML 也失败:', htmlError)
+                        console.error('无法获取内容: getFile、getFile2 和 getHTML 都失败了')
+                        // throw new Error(`无法获取内容: getFile、getFile2 和 getHTML 都失败了`)
                       }
                   }
                   catch (error) {
@@ -1521,15 +1525,11 @@ const processIframeLinks = async () => {
                       }
                     }
                     catch (error2) {
-                      console.log(`getFile2 失败,尝试使用 getHTML:`, error2)
-                      try {
-                        html = await api.getHTML(iframeSrc)
-                        console.log('getHTML 成功获取内容:', html)
-                      }
-                      catch (htmlError) {
-                        console.error('getHTML 也失败:', htmlError)
-                        console.error('无法获取内容: getFile、getFile2 和 getHTML 都失败了')
-                        // throw new Error(`无法获取内容: getFile、getFile2 和 getHTML 都失败了`)
+                      const fileData2 = await getFile2(iframeSrc)
+                      if (fileData2 && fileData2.data) {
+                        const uint8Array = new Uint8Array(fileData2.data)
+                        html = new TextDecoder('utf-8').decode(uint8Array)
+                        console.log('getFile2 成功获取内容:', html)
                       }
                     }
                   }