Ver Fonte

refactor(pptEasy): 重构PPT iframe URL生成逻辑并过滤图片元素

将PPT iframe URL的生成从计算属性改为方法,并初始化时调用
在生成PPT JSON时过滤掉所有图片元素
lsc há 4 meses atrás
pai
commit
990b12479f

+ 29 - 21
src/components/pages/pptEasy/addCourse2.vue

@@ -1022,6 +1022,7 @@ export default {
   },
   data() {
     return {
+      pptIframeUrl: "",
       gotype: (window.topU && window.topU.gotype) ? window.topU.gotype : '',
       checkAll: false,
       userid: this.$route.query.userid,
@@ -1195,25 +1196,6 @@ export default {
     }
   },
   computed: {
-    // 判断当前页面URL是否包含beta
-    isBetaEnv() {
-      return window.location.href.includes('beta');
-    },
-    // 动态生成PPT iframe的URL
-    pptIframeUrl() {
-
-      let ppturl = "https://beta.ppt.cocorobo.cn"
-      if (this.isBetaEnv) {
-        ppturl = "https://beta.ppt.cocorobo.cn"
-      } else if (this.lang.lang == 'com') {
-        ppturl = 'https://ppt.cocorobo.com'
-      } else if (this.lang.lang == 'hk') {
-        ppturl = 'https://ppt.cocorobo.hk'
-      } else {
-        ppturl = 'https://ppt.cocorobo.cn'
-      }
-      return `${ppturl}/?mode=editor2&courseid=${this.cid}`;
-    },
     getListClassC() {
       return function(list) {
         let _c2 = [];
@@ -1721,9 +1703,16 @@ export default {
       if (this.uploadWorkLoading) return;
       this.uploadWorkLoading = true;
       let _pptData = await this.getPPtJson();
-
+      const _pptData2 = JSON.parse(JSON.stringify(_pptData))
+      if (_pptData2.slides) {
+        _pptData2.slides.forEach((slide) => {
+          if (slide.elements) {
+            slide.elements = slide.elements.filter((element) => element.type !== 'image')
+          }
+        })
+      }
       // 用_pptData生成json文件,并生成File对象
-      const pptJsonStr = JSON.stringify(_pptData, null, 2);
+      const pptJsonStr = JSON.stringify(_pptData2, null, 2);
       const pptJsonFile = new File([pptJsonStr], this.courseName + ".json", { type: "application/json" });
       // 你可以根据需要将pptJsonFile上传或保存
       console.log(_url)
@@ -3074,6 +3063,24 @@ export default {
       this.isAddOrUpdateLineLoading = false;
 
     },
+    // 判断当前页面URL是否包含beta
+    isBetaEnv() {
+      return window.location.href.includes('beta');
+    },
+    // 动态生成PPT iframe的URL
+    setPptIframeUrl() {
+      let ppturl = "https://beta.ppt.cocorobo.cn"
+      if (this.isBetaEnv) {
+        ppturl = "https://beta.ppt.cocorobo.cn"
+      } else if (this.lang.lang == 'com') {
+        ppturl = 'https://ppt.cocorobo.com'
+      } else if (this.lang.lang == 'hk') {
+        ppturl = 'https://ppt.cocorobo.hk'
+      } else {
+        ppturl = 'https://ppt.cocorobo.cn'
+      }
+      this.pptIframeUrl = `${ppturl}/?mode=editor2&courseid=${this.cid}`;
+    },
   },
   beforeDestroy() {
 
@@ -3092,6 +3099,7 @@ export default {
     if (this.mergedList.includes(this.org)) {
       this.isTeacherSee = true
     }
+    this.setPptIframeUrl();
     // 清空
     this.pptCourseJson.toolsList = [];
     this.setPPtToolList()

+ 29 - 21
src/components/pages/pptEasy/addCourse3.vue

@@ -977,6 +977,7 @@ export default {
   },
   data() {
     return {
+      pptIframeUrl: "",
       gotype: (window.topU && window.topU.gotype) ? window.topU.gotype : '',
       checkAll: false,
       userid: this.$route.query.userid,
@@ -1163,25 +1164,6 @@ export default {
     }
   },
   computed: {
-    // 判断当前页面URL是否包含beta
-    isBetaEnv() {
-      return window.location.href.includes('beta');
-    },
-    // 动态生成PPT iframe的URL
-    pptIframeUrl() {
-
-      let ppturl = "https://beta.ppt.cocorobo.cn"
-      if (this.isBetaEnv) {
-        ppturl = "https://beta.ppt.cocorobo.cn"
-      } else if (this.lang.lang == 'com') {
-        ppturl = 'https://ppt.cocorobo.com'
-      } else if (this.lang.lang == 'hk') {
-        ppturl = 'https://ppt.cocorobo.hk'
-      } else {
-        ppturl = 'https://ppt.cocorobo.cn'
-      }
-      return `${ppturl}/?mode=editor3&courseid=${this.cid}`;
-    },
     getListClassC() {
       return function (list) {
         let _c2 = [];
@@ -1804,9 +1786,16 @@ export default {
         this.uploadWorkLoading = true;
       }
       let _pptData = await this.getPPtJson();
-
+      const _pptData2 = JSON.parse(JSON.stringify(_pptData))
+      if (_pptData2.slides) {
+        _pptData2.slides.forEach((slide) => {
+          if (slide.elements) {
+            slide.elements = slide.elements.filter((element) => element.type !== 'image')
+          }
+        })
+      }
       // 用_pptData生成json文件,并生成File对象
-      const pptJsonStr = JSON.stringify(_pptData, null, 2);
+      const pptJsonStr = JSON.stringify(_pptData2, null, 2);
       const pptJsonFile = new File([pptJsonStr], this.courseName + ".json", { type: "application/json" });
       // 你可以根据需要将pptJsonFile上传或保存
 
@@ -3293,6 +3282,24 @@ export default {
       this.dialogVisible7 = false;
 
     },
+    // 判断当前页面URL是否包含beta
+    isBetaEnv() {
+      return window.location.href.includes('beta');
+    },
+    // 动态生成PPT iframe的URL
+    setPptIframeUrl() {
+      let ppturl = "https://beta.ppt.cocorobo.cn"
+      if (this.isBetaEnv) {
+        ppturl = "https://beta.ppt.cocorobo.cn"
+      } else if (this.lang.lang == 'com') {
+        ppturl = 'https://ppt.cocorobo.com'
+      } else if (this.lang.lang == 'hk') {
+        ppturl = 'https://ppt.cocorobo.hk'
+      } else {
+        ppturl = 'https://ppt.cocorobo.cn'
+      }
+      this.pptIframeUrl = `${ppturl}/?mode=editor3&courseid=${this.cid}`;
+    },
   },
   beforeDestroy() {
 
@@ -3314,6 +3321,7 @@ export default {
     // 清空
     this.pptCourseJson.toolsList = [];
     this.setPPtToolList()
+    this.setPptIframeUrl();
     // iframe页面加载完成
     this.$refs.pptIframeRef.onload = () => {
       console.log("iframe页面加载完成");