11wqe1 5 months ago
parent
commit
1ead610cbc
1 changed files with 36 additions and 46 deletions
  1. 36 46
      src/components/components/choseWorksDetailDialog.vue

+ 36 - 46
src/components/components/choseWorksDetailDialog.vue

@@ -1327,30 +1327,6 @@ export default {
       }
       console.log('text',text);
 
-      // const script = document.createElement("script");
-      // script.type = "text/javascript";
-      // script.charset = "UTF-8";
-      // script.src = "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js";
-      // script.onload = () => {
-      //   const images = document.getElementsByTagName("img");
-      //   for (let i = 0; i < images.length; i++) {
-      //     images[i].crossOrigin = "anonymous";
-      //   }
-      //   html2canvas(document.body, {
-      //     allowTaint: true,
-      //     useCORS: true,
-      //     height: document.body.scrollHeight,
-      //     windowHeight: document.body.scrollHeight,
-      //   }).then(canvas => {
-      //     const base64Url = canvas.toDataURL("image/png");
-      //     const base64 = `<img src="${base64Url}" />`;
-      //     const file = this.dataURLtoFile_shishi(base64Url, "截图");
-      //     this.beforeUpload_shishi(file, this.userId, this.courseId, this.courseType, this.taskCount, this.toolType, `${str}_loadLi_JieE${this.courseId}${this.courseType}${this.taskCount}${this.toolType}${this.userId}`, this.toolType, text);
-      //   });
-      // };
-      // document.head.appendChild(script);
-      // iframeWindow.document.head.appendChild(_ajs);
-
       var _ajs = iframeWindow.document.createElement("script");
             _ajs.type = "text/javascript";
             _ajs.innerHTML =
@@ -1599,9 +1575,11 @@ export default {
 				this.changeShowType(this.dialogTypeList.findIndex(i=>i.showType.includes(this.toolType)))
 			}
       this.setData();
-			if([3,1,7].includes(this.toolType)){
-				this.getIframeWorksData()
-			}
+			if([3,1,7].includes(this.toolType)){ 
+        this.$nextTick(() => {
+          this.getIframeWorksData();
+        }); 
+      }
     },
     openWordCloud() {
       this.dialogVisibleWordCloud = true
@@ -1852,16 +1830,21 @@ export default {
           t:this.toolIndex,
           type:"2"
         }
+        let _iframe = this.$refs.iframeMainMapRef;
+        
+
         this.ajax.get(this.$store.state.api+"selectWord2",params).then(res=>{
           let _data = res.data[0]
-          if(_data[0]){
-            this.$nextTick(()=>{
-              let _iframe = this.$refs.iframeMainMapRef;
-              _iframe.onload = () =>{
+          console.log('_data',_data);
+          
+            // this.$nextTick(()=>{
+              // _iframe.onload = () =>{
                 console.log("思维导图iframe加载数据👈")
                 // iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
+                if(_data[0]){
+                  _iframe.contentWindow.editor.minder.importData('json',JSON.parse(_data[0].text) )
+                }
 
-                _iframe.contentWindow.editor.minder.importData("json", JSON.parse(_data[0].text))
                 const scripts = [
                   "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
                   "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
@@ -1873,10 +1856,9 @@ export default {
                   script.src = src;
                   _iframe.contentWindow.document.body.appendChild(script);
                 });
-              }
-            })
+              // }
+            // })
 
-          }
         })
 			}else if([1].includes(this.toolType)){ //电子白板
         let params = {
@@ -1887,21 +1869,23 @@ export default {
           t:this.toolIndex,
           type:"3"
         }
-        console.log('电子白板params',params);
+        let _iframe = this.$refs.iframeWhiteBoardRef;
+        console.log('电子白板_iframe',_iframe);
         
-
         this.ajax.get(this.$store.state.api+"selectWord2",params).then(res=>{
           let _data = res.data[0]
           console.log('_data',_data);
           
-          if(_data[0]){
-            this.$nextTick(()=>{
-              let _iframe = this.$refs.iframeWhiteBoardRef;
-              _iframe.onload = () =>{
+            // this.$nextTick(()=>{
+              
+              // _iframe.onload = () =>{
                 console.log("电子白板iframe加载数据👈")
-                // iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
+                if(_data[0]){
+                  _iframe.contentWindow.h.app.updateScene({elements:JSON.parse(_data[0].text)})
+                }
 
-                _iframe.contentWindow.h.app.updateScene({elements:JSON.parse(_data[0].text)})
+                console.log(' _iframe.contentWindow', _iframe.contentWindow);
+                
                 const scripts = [
                   "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
                   "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
@@ -1913,10 +1897,16 @@ export default {
                   script.src = src;
                   _iframe.contentWindow.document.body.appendChild(script);
                 });
-              }
-            })
 
-          }
+                // if (scripts) {
+                //   _iframe.contentDocument.location.reload()
+                // } else {
+                //     _iframe.contentDocument.location.reload()
+                // }
+              // }
+              
+            // })
+
         })
 			}else if([57].includes(this.toolType)){