Fix:修复导入百度脑图导出的xmind文件报错的问题
This commit is contained in:
parent
26508b5a62
commit
850b9ed936
@ -14,11 +14,13 @@ const parseXmindFile = file => {
|
|||||||
async zip => {
|
async zip => {
|
||||||
try {
|
try {
|
||||||
let content = ''
|
let content = ''
|
||||||
if (zip.files['content.json']) {
|
let jsonFile = zip.files['content.json']
|
||||||
let json = await zip.files['content.json'].async('string')
|
let xmlFile = zip.files['content.xml'] || zip.files['/content.xml']
|
||||||
|
if (jsonFile) {
|
||||||
|
let json = await jsonFile.async('string')
|
||||||
content = await transformXmind(json, zip.files)
|
content = await transformXmind(json, zip.files)
|
||||||
} else if (zip.files['content.xml']) {
|
} else if (xmlFile) {
|
||||||
let xml = await zip.files['content.xml'].async('string')
|
let xml = await xmlFile.async('string')
|
||||||
let json = xmlConvert.xml2json(xml)
|
let json = xmlConvert.xml2json(xml)
|
||||||
content = transformOldXmind(json)
|
content = transformOldXmind(json)
|
||||||
}
|
}
|
||||||
@ -187,7 +189,7 @@ const transformOldXmind = content => {
|
|||||||
if (_children && _children.elements && _children.elements.length > 0) {
|
if (_children && _children.elements && _children.elements.length > 0) {
|
||||||
_children.elements.forEach(item => {
|
_children.elements.forEach(item => {
|
||||||
if (item.name === 'topics') {
|
if (item.name === 'topics') {
|
||||||
item.elements.forEach(item2 => {
|
(item.elements || []).forEach(item2 => {
|
||||||
let newChild = {}
|
let newChild = {}
|
||||||
newNode.children.push(newChild)
|
newNode.children.push(newChild)
|
||||||
walk(item2, newChild)
|
walk(item2, newChild)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user