From 850b9ed9368b12c6d36ebe95bee3fb8509626023 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Thu, 24 Aug 2023 17:57:12 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=99=BE=E5=BA=A6=E8=84=91=E5=9B=BE=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=9A=84xmind=E6=96=87=E4=BB=B6=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/parse/xmind.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/simple-mind-map/src/parse/xmind.js b/simple-mind-map/src/parse/xmind.js index b852067d..cb8b72df 100644 --- a/simple-mind-map/src/parse/xmind.js +++ b/simple-mind-map/src/parse/xmind.js @@ -14,11 +14,13 @@ const parseXmindFile = file => { async zip => { try { let content = '' - if (zip.files['content.json']) { - let json = await zip.files['content.json'].async('string') + let jsonFile = zip.files['content.json'] + let xmlFile = zip.files['content.xml'] || zip.files['/content.xml'] + if (jsonFile) { + let json = await jsonFile.async('string') content = await transformXmind(json, zip.files) - } else if (zip.files['content.xml']) { - let xml = await zip.files['content.xml'].async('string') + } else if (xmlFile) { + let xml = await xmlFile.async('string') let json = xmlConvert.xml2json(xml) content = transformOldXmind(json) } @@ -187,7 +189,7 @@ const transformOldXmind = content => { if (_children && _children.elements && _children.elements.length > 0) { _children.elements.forEach(item => { if (item.name === 'topics') { - item.elements.forEach(item2 => { + (item.elements || []).forEach(item2 => { let newChild = {} newNode.children.push(newChild) walk(item2, newChild)