diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js index 88623da6..66ff1609 100644 --- a/simple-mind-map/src/plugins/Export.js +++ b/simple-mind-map/src/plugins/Export.js @@ -390,11 +390,28 @@ class Export { if (!this.mindMap.doExportXMind) { throw new Error('请注册ExportXMind插件') } - const data = this.mindMap.getData() + // const data = this.mindMap.getData() + const data = await this.changeTagObjToString(this.mindMap.getData()) const blob = await this.mindMap.doExportXMind.xmind(data, name) const res = await readBlob(blob) return res } + // 把tag对象数组转换成字符串数组 + async changeTagObjToString (treeObj) { + const tagArr = [] + if (treeObj.data.tag) { + await treeObj.data.tag.forEach(item => { + tagArr.push(item.text) + treeObj.data.tag = tagArr + }) + } else { + treeObj.data.tag = [] + } + await treeObj.children.forEach(child => { + this.changeTagObjToString(child) + }) + return treeObj + } // 导出为svg async svg(name) { diff --git a/web/src/pages/Edit/components/Count.vue b/web/src/pages/Edit/components/Count.vue index c7b1e016..86f84071 100644 --- a/web/src/pages/Edit/components/Count.vue +++ b/web/src/pages/Edit/components/Count.vue @@ -46,6 +46,7 @@ export default { methods: { // 监听数据变化 onDataChange(data) { + if (!data) return this.textStr = '' this.words = 0 this.num = 0 @@ -56,7 +57,6 @@ export default { // 遍历 walk(data) { - if (!data) return this.num++ this.textStr += String(data.data.text) || '' if (data.children && data.children.length > 0) {