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() // 销毁