lsc 2 days ago
parent
commit
2ca702a5c9
1 changed files with 17 additions and 1 deletions
  1. 17 1
      js/Desktop/DeskTop.js

+ 17 - 1
js/Desktop/DeskTop.js

@@ -11494,7 +11494,23 @@ U.MD.D.I.getContents2 = function (cid, s, task, t, uid, type, iframe) {
                 if (type == '2') {
                     iframe.contentWindow.editor.minder.importData('json', JSON.parse(xmlhttp.response)[0][0].text)
                 } else if (type == '3') {
-                    iframe.contentWindow.h.app.updateScene({ elements: JSON.parse(JSON.parse(xmlhttp.response)[0][0].text) })
+                    let text = JSON.parse(JSON.parse(xmlhttp.response)[0][0].text)
+                    if ((Array.isArray(text)) || (text && Array.isArray(text.elements))) {
+                        // 如果是数组或含有 elements 并且 elements 是数组
+                        if (Array.isArray(text)) {
+                            // 兼容原有结构:仅为数组时
+                            iframe.contentWindow.h.app.updateScene({ elements: text });
+                        } else {
+                            // 有 elements 和可能的 files 字段时,直接传递整个对象
+                            iframe.contentWindow.h.app.updateScene(text);
+                        }
+                    } else if (text && (text.elements || text.files)) {
+                        // 有 elements 和 files 字段的 json对象
+                        iframe.contentWindow.h.app.updateScene(text);
+                    } else {
+                        // fallback 兼容早期意外结构,作为 elements
+                        iframe.contentWindow.h.app.updateScene({ elements: text });
+                    }
                 } else if (type == '4') {
                     iframe.contentWindow.loadingXml(JSON.parse(xmlhttp.response)[0][0].text)
                 } else if (type == '5') {