lsc 1 year ago
parent
commit
ff038eeac0
1 changed files with 74 additions and 11 deletions
  1. 74 11
      js/Desktop/DeskTop.js

+ 74 - 11
js/Desktop/DeskTop.js

@@ -1792,6 +1792,8 @@ window.addEventListener('message', function (e) { // 监听 message 事件
         U.MD.D.I.openApplicationJieE("whiteboard", e.data.cid, e.data.stage, e.data.task, e.data.tool)
         U.MD.D.I.openApplicationJieE("whiteboard", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     } else if (e.data.tools && e.data.tools == "3E") {
     } else if (e.data.tools && e.data.tools == "3E") {
         U.MD.D.I.openApplicationJieE("mind", e.data.cid, e.data.stage, e.data.task, e.data.tool)
         U.MD.D.I.openApplicationJieE("mind", e.data.cid, e.data.stage, e.data.task, e.data.tool)
+    } else if (e.data.tools && e.data.tools == "57y") {
+        U.MD.D.I.openApplicationYu("CocoPi", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     } else if (e.data.tools && e.data.tools == "57u") {
     } else if (e.data.tools && e.data.tools == "57u") {
         U.MD.D.I.openApplicationUpload("CocoPi", e.data.cid, e.data.stage, e.data.task, e.data.tool)
         U.MD.D.I.openApplicationUpload("CocoPi", e.data.cid, e.data.stage, e.data.task, e.data.tool)
     } else if (e.data.tools && e.data.tools == "57teacher") {
     } else if (e.data.tools && e.data.tools == "57teacher") {
@@ -5539,9 +5541,7 @@ U.MD.D.I.getContent = function (cid, s, task, t, uid, type, iframe) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
                 // resolve(res.value[0][0].text);
                 // resolve(res.value[0][0].text);
                 if (type == '2') {
                 if (type == '2') {
-                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
-                        $(fileInput).val('');
-                    });
+                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
                 } else if (type == '3') {
                 } else if (type == '3') {
                     iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
                     iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
                 }
                 }
@@ -6344,6 +6344,51 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
                 }
                 }
             }
             }
             break;
             break;
+        case "CocoPi":
+                aTool = 57;
+                _iframe = $$("iframe", {
+                    "allowpaymentrequest":"allowpaymentrequest",
+                    "allow": "camera *; microphone *;display-capture;usb",
+                    "webkitallowfullscreen": "", "mozallowfullscreen": "",
+                    "frameborder": "no",
+                    "border": "0",
+                    "scrolling ": "no",
+                    "style": {
+                        "cssText": "border:0;width:100%;height:100%"
+                    },
+                    "src": "https://beta.v.cocorobo.cn/"
+                })
+                _box.appendChild(_iframe);
+                _box.appendChild(_jie);
+                _formdiv = new U.UF.UI.form(
+                    "CocoPi",
+                    _box, {
+                    "id": "CocoPi" + cid + stage + task + tool,
+                    "style": {
+                        "width": "90%",
+                        "height": "90%",
+                        "overflow": 'hidden'
+                    },
+                    "onresize": function () { }
+                }, {
+                    closecallback: function () { }
+                }, {
+                    "style": {
+                        "height": "36px"
+                    }
+                }).form; //创建窗体
+                _taskbar = {
+                    "id": str + _formdiv.id,
+                    "style": {
+                        "backgroundImage": "url(/img/icon/cocopi.png)"
+                    },
+                    "name": "CocoPi",
+                    "forms": _formdiv,
+                    "click": function () {
+                        U.MD.D.I.openApplication(str, obj, info);
+                    }
+                }
+                break;
     }
     }
 
 
     if (_iframe) {
     if (_iframe) {
@@ -6377,6 +6422,16 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             } else {
             } else {
                 _iframe.contentDocument.location.reload()
                 _iframe.contentDocument.location.reload()
             }
             }
+        } else if (str == 'CocoPi') {
+            _iframe = _formdiv.querySelector('iframe')
+            let onloadListener = U.UF.DL.iframeLoad(_iframe, function () {
+                U.MD.D.I.getContents2(cid, stage, task, tool, _userid, '4', _iframe)
+            })
+            if (onloadListener) {
+                _iframe.contentDocument.location.reload()
+            } else {
+                _iframe.contentDocument.location.reload()
+            }
         } else {
         } else {
             _iframe.onload = () => {
             _iframe.onload = () => {
             };
             };
@@ -6393,6 +6448,9 @@ U.MD.D.I.openApplicationYu = function (str, cid, stage, task, tool) {
             } else if (aTool == 3) {
             } else if (aTool == 3) {
                 text = await U.MD.D.I.getEditorContent(_iframe);
                 text = await U.MD.D.I.getEditorContent(_iframe);
                 type = '2'
                 type = '2'
+            } else if (aTool == 57) {
+                text = _iframe.contentWindow.getLoadXmlStr()
+                type = '4'
             }
             }
             _loading.style.display = 'flex'
             _loading.style.display = 'flex'
 
 
@@ -6423,9 +6481,7 @@ U.MD.D.I.getContents = function (cid, s, task, t, uid, type, iframe) {
         if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
         if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
                 // resolve(res.value[0][0].text);
                 // resolve(res.value[0][0].text);
-                iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
-                    $(fileInput).val('');
-                });
+                iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
             }
             }
         }
         }
     }
     }
@@ -6451,14 +6507,20 @@ U.MD.D.I.getContents2 = function (cid, s, task, t, uid, type, iframe) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
             if (xmlhttp.response && JSON.parse(xmlhttp.response)[0].length > 0) {
                 // resolve(res.value[0][0].text);
                 // resolve(res.value[0][0].text);
                 if (type == '2') {
                 if (type == '2') {
-                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text).then(function (data) {
-                        $(fileInput).val('');
-                    });
+                    iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
                 } else if (type == '3') {
                 } else if (type == '3') {
                     iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
                     iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
+                } else if (type == '4') {
+                    iframe.contentWindow.loadingXml(JSON.parse(xmlhttp.response)[0][0].text)
                 }
                 }
             } else {
             } else {
-                iframe.contentWindow.h.app.updateScene({ elements: [] })
+                if (type == '2') {
+                    iframe.contentWindow.editor.minder.importData('json', '')
+                } else if (type == '3') {
+                    iframe.contentWindow.h.app.updateScene({ elements: [] })
+                } else if (type == '4') {
+                    iframe.contentWindow.window.blockpy.components.editor.blockly.clear();
+                }
             }
             }
         }
         }
     }
     }
@@ -6782,7 +6844,8 @@ U.MD.D.I.getUploadContent = function (cid, s, task, t, uid, atool, type, iframe)
                 }
                 }
             } else {
             } else {
                 if (atool == 57) {
                 if (atool == 57) {
-                    iframe.contentWindow.window.blockpy.components.editor.blockly.clear();
+                    U.MD.D.I.getContents2(cid, s, task, t, uid, type, iframe)
+                    // iframe.contentWindow.window.blockpy.components.editor.blockly.clear();
                 }
                 }
             }
             }
         }, [], { "type": "POST", "withCredentials": true });
         }, [], { "type": "POST", "withCredentials": true });