Demo:打开本地文件编辑的情况下不再将数据写入浏览器缓存
This commit is contained in:
parent
cf56b5db24
commit
4fb9bd5135
@ -1,6 +1,7 @@
|
|||||||
import exampleData from 'simple-mind-map/example/exampleData'
|
import exampleData from 'simple-mind-map/example/exampleData'
|
||||||
import { simpleDeepClone } from 'simple-mind-map/src/utils/index'
|
import { simpleDeepClone } from 'simple-mind-map/src/utils/index'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import vuexStore from '@/store'
|
||||||
|
|
||||||
const SIMPLE_MIND_MAP_DATA = 'SIMPLE_MIND_MAP_DATA'
|
const SIMPLE_MIND_MAP_DATA = 'SIMPLE_MIND_MAP_DATA'
|
||||||
const SIMPLE_MIND_MAP_LANG = 'SIMPLE_MIND_MAP_LANG'
|
const SIMPLE_MIND_MAP_LANG = 'SIMPLE_MIND_MAP_LANG'
|
||||||
@ -36,6 +37,9 @@ export const getData = () => {
|
|||||||
mindMapData = window.takeOverAppMethods.getMindMapData()
|
mindMapData = window.takeOverAppMethods.getMindMapData()
|
||||||
return mindMapData
|
return mindMapData
|
||||||
}
|
}
|
||||||
|
if (vuexStore.state.isHandleLocalFile) {
|
||||||
|
return Vue.prototype.getCurrentData()
|
||||||
|
}
|
||||||
let store = localStorage.getItem(SIMPLE_MIND_MAP_DATA)
|
let store = localStorage.getItem(SIMPLE_MIND_MAP_DATA)
|
||||||
if (store === null) {
|
if (store === null) {
|
||||||
return simpleDeepClone(exampleData)
|
return simpleDeepClone(exampleData)
|
||||||
@ -68,6 +72,9 @@ export const storeData = data => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
Vue.prototype.$bus.$emit('write_local_file', originData)
|
Vue.prototype.$bus.$emit('write_local_file', originData)
|
||||||
|
if (vuexStore.state.isHandleLocalFile) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let dataStr = JSON.stringify(originData)
|
let dataStr = JSON.stringify(originData)
|
||||||
localStorage.setItem(SIMPLE_MIND_MAP_DATA, dataStr)
|
localStorage.setItem(SIMPLE_MIND_MAP_DATA, dataStr)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -98,6 +105,9 @@ export const storeConfig = config => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
Vue.prototype.$bus.$emit('write_local_file', originData)
|
Vue.prototype.$bus.$emit('write_local_file', originData)
|
||||||
|
if (vuexStore.state.isHandleLocalFile) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let dataStr = JSON.stringify(originData)
|
let dataStr = JSON.stringify(originData)
|
||||||
localStorage.setItem(SIMPLE_MIND_MAP_DATA, dataStr)
|
localStorage.setItem(SIMPLE_MIND_MAP_DATA, dataStr)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -290,9 +290,9 @@ export default {
|
|||||||
creatingTip: 'Creating file',
|
creatingTip: 'Creating file',
|
||||||
directory: 'Directory',
|
directory: 'Directory',
|
||||||
newFileTip:
|
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:
|
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: {
|
edit: {
|
||||||
newFeatureNoticeTitle: 'New feature reminder',
|
newFeatureNoticeTitle: 'New feature reminder',
|
||||||
|
|||||||
@ -285,8 +285,8 @@ export default {
|
|||||||
defaultFileName: '思维导图',
|
defaultFileName: '思维导图',
|
||||||
creatingTip: '正在创建文件',
|
creatingTip: '正在创建文件',
|
||||||
directory: '目录',
|
directory: '目录',
|
||||||
newFileTip: '新建文件前请先导出当前编辑的文件,否则内容会丢失',
|
newFileTip: '新建文件前请先导出当前编辑的文件,谨防内容丢失',
|
||||||
openFileTip: '打开文件前请先导出当前编辑的文件,否则内容会丢'
|
openFileTip: '打开文件前请先导出当前编辑的文件,谨防内容丢失'
|
||||||
},
|
},
|
||||||
edit: {
|
edit: {
|
||||||
newFeatureNoticeTitle: '新特性提醒',
|
newFeatureNoticeTitle: '新特性提醒',
|
||||||
|
|||||||
@ -581,6 +581,12 @@ export default {
|
|||||||
if (hasFileURL) {
|
if (hasFileURL) {
|
||||||
this.$bus.$emit('handle_file_url')
|
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()
|
this.cooperateTest()
|
||||||
// 销毁
|
// 销毁
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user