Просмотр исходного кода

fix(Student): 过滤PPT数据中的图片元素以优化处理

在解析PPT数据时,新增过滤逻辑移除所有类型为image的元素,避免处理不必要的内容
lsc 3 недель назад
Родитель
Сommit
3374a82ccb
1 измененных файлов с 11 добавлено и 2 удалено
  1. 11 2
      src/views/Student/index.vue

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

@@ -2441,8 +2441,17 @@ const getCourseDetail = async () => {
         jsonStr = new TextDecoder('utf-8').decode(uint8Array)
         try {
           const jsonObj = JSON.parse(jsonStr)
-          checkPPTFile(JSON.stringify(jsonObj, null, 2))
-          importJSON(jsonObj)
+          // 过滤掉 elements 中 type 为 image 的内容
+          const jsonObj2 = JSON.parse(JSON.stringify(jsonObj))
+          if (jsonObj2.slides) {
+            jsonObj2.slides.forEach((slide: any) => {
+              if (slide.elements) {
+                slide.elements = slide.elements.filter((element: any) => element.type !== 'image')
+              }
+            })
+          }
+          checkPPTFile(JSON.stringify(jsonObj2, null, 2))
+          importJSON(jsonObj2)
         }
         catch (e) {
           console.error('解析pptdata.data失败:', e)