From df45c12c12fde4c6413880f279622ce253c0af77 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Wed, 2 Aug 2023 16:01:18 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E5=AF=BC=E5=87=BA=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?web=E7=AB=AF=E5=AF=BC=E5=85=A5=E5=90=8E=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=B4=B4=E7=BA=B8=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/electron/fileHandle.js | 2 +- web/src/pages/Edit/components/Edit.vue | 16 +++++++++ web/src/pages/Edit/components/Export.vue | 4 +-- web/src/pages/Edit/components/Import.vue | 3 +- web/src/utils/index.js | 44 ++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 4 deletions(-) diff --git a/web/src/electron/fileHandle.js b/web/src/electron/fileHandle.js index 32dad3c8..15d39c21 100644 --- a/web/src/electron/fileHandle.js +++ b/web/src/electron/fileHandle.js @@ -50,7 +50,7 @@ export const bindFileHandleEvent = ({ mainWindow, initOpenFileQueue }) => { win.loadURL( process.env.WEBPACK_DEV_SERVER_URL + '/#/workbenche/edit/' + id ) - // if (!process.env.IS_TEST) win.webContents.openDevTools() + if (!process.env.IS_TEST) win.webContents.openDevTools() } else { // Load the index.html when not in development win.loadURL('app://./index.html/#/workbenche/edit/' + id) diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index 18058b11..5f1ddd47 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -39,6 +39,7 @@ import AssociativeLine from 'simple-mind-map/src/plugins/AssociativeLine.js' import TouchEvent from 'simple-mind-map/src/plugins/TouchEvent.js' import NodeImgAdjust from 'simple-mind-map/src/plugins/NodeImgAdjust.js' import SearchPlugin from 'simple-mind-map/src/plugins/Search.js' +import { downloadFile, readBlob } from 'simple-mind-map/src/utils/index' import Outline from './Outline' import Style from './Style' import BaseStyle from './BaseStyle' @@ -66,6 +67,7 @@ import i18n from '../../../i18n' import Search from './Search.vue' import NodeIconSidebar from './NodeIconSidebar.vue' import NodeIconToolbar from './NodeIconToolbar.vue' +import { removeMindMapNodeStickerProtocol, addMindMapNodeStickerProtocol } from '@/utils' // 注册插件 MindMap @@ -148,6 +150,7 @@ export default { this.$bus.$on('execCommand', this.execCommand) this.$bus.$on('paddingChange', this.onPaddingChange) this.$bus.$on('export', this.export) + this.$bus.$on('exportJson', this.exportJson) this.$bus.$on('setData', this.setData) this.$bus.$on('startTextEdit', () => { this.mindMap.renderer.startTextEdit() @@ -267,6 +270,7 @@ export default { let data = await window.electronAPI.getFileContent(this.$route.params.id) let storeData = null if (data) { + addMindMapNodeStickerProtocol(data.content.root) this.setFileName(data.name) storeData = data.content } else { @@ -473,6 +477,17 @@ export default { } }, + async exportJson(type, isDownload = true, name = '思维导图', withConfig) { + let data = this.mindMap.getData(withConfig) + removeMindMapNodeStickerProtocol(data.root ? data.root : data) + let str = JSON.stringify(data) + let blob = new Blob([str]) + let res = await readBlob(blob) + if (isDownload) { + downloadFile(res, name + '.' + type) + } + }, + // 修改导出内边距 onPaddingChange(data) { this.mindMap.updateConfig(data) @@ -508,6 +523,7 @@ export default { async saveToLocal() { let id = this.$route.params.id let data = this.mindMap.getData(true) + removeMindMapNodeStickerProtocol(data.root) let res = await window.electronAPI.save(id, JSON.stringify(data), this.fileName) if (res) { this.isNewFile = false diff --git a/web/src/pages/Edit/components/Export.vue b/web/src/pages/Edit/components/Export.vue index 9af8d971..2a4fc544 100644 --- a/web/src/pages/Edit/components/Export.vue +++ b/web/src/pages/Edit/components/Export.vue @@ -135,7 +135,7 @@ export default { * @Date: 2021-06-06 22:28:20 * @Desc: 确定 */ - confirm() { + async confirm() { if (this.exportType === 'svg') { this.$bus.$emit( 'export', @@ -150,7 +150,7 @@ export default { ) } else if (['smm', 'json'].includes(this.exportType)) { this.$bus.$emit( - 'export', + 'exportJson', this.exportType, true, this.fileName, diff --git a/web/src/pages/Edit/components/Import.vue b/web/src/pages/Edit/components/Import.vue index e936066d..44051851 100644 --- a/web/src/pages/Edit/components/Import.vue +++ b/web/src/pages/Edit/components/Import.vue @@ -34,7 +34,7 @@