From 4fb9bd5135f65eebe4252f42c7ef6e3042560aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Mon, 29 Jul 2024 17:00:39 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E6=89=93=E5=BC=80=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=96=87=E4=BB=B6=E7=BC=96=E8=BE=91=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E4=B8=8D=E5=86=8D=E5=B0=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=B5=8F=E8=A7=88=E5=99=A8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/api/index.js | 10 ++++++++++ web/src/lang/en_us.js | 4 ++-- web/src/lang/zh_cn.js | 4 ++-- web/src/pages/Edit/components/Edit.vue | 6 ++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/web/src/api/index.js b/web/src/api/index.js index 534fbdf1..0a4f86f1 100644 --- a/web/src/api/index.js +++ b/web/src/api/index.js @@ -1,6 +1,7 @@ import exampleData from 'simple-mind-map/example/exampleData' import { simpleDeepClone } from 'simple-mind-map/src/utils/index' import Vue from 'vue' +import vuexStore from '@/store' const SIMPLE_MIND_MAP_DATA = 'SIMPLE_MIND_MAP_DATA' const SIMPLE_MIND_MAP_LANG = 'SIMPLE_MIND_MAP_LANG' @@ -36,6 +37,9 @@ export const getData = () => { mindMapData = window.takeOverAppMethods.getMindMapData() return mindMapData } + if (vuexStore.state.isHandleLocalFile) { + return Vue.prototype.getCurrentData() + } let store = localStorage.getItem(SIMPLE_MIND_MAP_DATA) if (store === null) { return simpleDeepClone(exampleData) @@ -68,6 +72,9 @@ export const storeData = data => { return } Vue.prototype.$bus.$emit('write_local_file', originData) + if (vuexStore.state.isHandleLocalFile) { + return + } let dataStr = JSON.stringify(originData) localStorage.setItem(SIMPLE_MIND_MAP_DATA, dataStr) } catch (error) { @@ -98,6 +105,9 @@ export const storeConfig = config => { return } Vue.prototype.$bus.$emit('write_local_file', originData) + if (vuexStore.state.isHandleLocalFile) { + return + } let dataStr = JSON.stringify(originData) localStorage.setItem(SIMPLE_MIND_MAP_DATA, dataStr) } catch (error) { diff --git a/web/src/lang/en_us.js b/web/src/lang/en_us.js index 4612cd57..73eeead3 100644 --- a/web/src/lang/en_us.js +++ b/web/src/lang/en_us.js @@ -290,9 +290,9 @@ export default { creatingTip: 'Creating file', directory: 'Directory', newFileTip: - 'Please export the currently edited file before creating a new one, otherwise the content will be lost', + 'Please export the currently edited file before creating a new one, Beware of content loss', openFileTip: - 'Please export the currently edited file before opening it, otherwise the content will be lost' + 'Please export the currently edited file before opening it, Beware of content loss' }, edit: { newFeatureNoticeTitle: 'New feature reminder', diff --git a/web/src/lang/zh_cn.js b/web/src/lang/zh_cn.js index 24204b4f..3a05d242 100644 --- a/web/src/lang/zh_cn.js +++ b/web/src/lang/zh_cn.js @@ -285,8 +285,8 @@ export default { defaultFileName: '思维导图', creatingTip: '正在创建文件', directory: '目录', - newFileTip: '新建文件前请先导出当前编辑的文件,否则内容会丢失', - openFileTip: '打开文件前请先导出当前编辑的文件,否则内容会丢' + newFileTip: '新建文件前请先导出当前编辑的文件,谨防内容丢失', + openFileTip: '打开文件前请先导出当前编辑的文件,谨防内容丢失' }, edit: { newFeatureNoticeTitle: '新特性提醒', diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index 0fc646bf..db0d3994 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -581,6 +581,12 @@ export default { if (hasFileURL) { this.$bus.$emit('handle_file_url') } + // api/index.js文件使用 + // 当正在编辑本地文件时通过该方法获取最新数据 + Vue.prototype.getCurrentData = () => { + const fullData = this.mindMap.getData(true) + return { ...fullData, config: this.mindMapData.config } + } // 协同测试 this.cooperateTest() // 销毁