Commit caaeb0eb authored by 孙灵跃 Leon Sun's avatar 孙灵跃 Leon Sun

#

parent 340442d2
...@@ -7,12 +7,7 @@ ...@@ -7,12 +7,7 @@
<link rel="icon" href="dist/logo.ico"> <link rel="icon" href="dist/logo.ico">
<title>思绪思维导图</title> <title>思绪思维导图</title>
<script> <script>
// 自定义静态资源的路径 window.externalPublicPath = '/mindmap/';
window.externalPublicPath = '/mindmap/'
if(typeof window.takeOverApp !== 'boolean'){
// 如果是本地调试的话, 就不需要接管应用
window.takeOverApp = false
}
</script> </script>
</head> </head>
<body> <body>
...@@ -22,8 +17,6 @@ ...@@ -22,8 +17,6 @@
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
<script> <script>
const getDataFromBackend = () => { const getDataFromBackend = () => {
// 如果外部没有传入思维导图的方法,则使用默认数据 // 如果外部没有传入思维导图的方法,则使用默认数据
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -53,45 +46,31 @@ ...@@ -53,45 +46,31 @@
const setTakeOverAppMethods = (data) => { const setTakeOverAppMethods = (data) => {
window.takeOverAppMethods = window.takeOverAppMethods || {} window.takeOverAppMethods = window.takeOverAppMethods || {}
if(!window.takeOverAppMethods['getMindMapData']){ window.takeOverAppMethods['getMindMapData'] = ()=>{
window.takeOverAppMethods['getMindMapData'] = ()=>{ return data.mindMapData
return data.mindMapData
}
}
if(!window.takeOverAppMethods['saveManualMindMapData']){
window.takeOverAppMethods['saveManualMindMapData'] = void 0
}
if(!window.takeOverAppMethods['manualCancel']){
window.takeOverAppMethods['manualCancel'] = ()=>void 0
}
window.takeOverAppMethods['saveMindMapData'] = ()=>{
} }
window.takeOverAppMethods['saveMindMapData'] = ()=>{}
window.takeOverAppMethods['getLanguage'] = ()=>{ window.takeOverAppMethods['getLanguage'] = ()=>{
return data.lang return data.lang || 'zh'
}
window.takeOverAppMethods['saveLanguage'] = ()=>{
}
window.takeOverAppMethods['getLocalConfig'] = ()=>{
return data.localConfig
}
window.takeOverAppMethods['saveLocalConfig'] = ()=>{
} }
} }
window.onload = async () => { window.onload = async () => {
if (!window.takeOverApp) return window.takeOverApp = false;
// 请求数据 const getJson = function (str) {
const data = await getDataFromBackend() if (typeof str == 'string') {
// 设置全局的方法 try {
return JSON.parse(str);
} catch (e) {
return false;
}
}
}
const key = '[[miniMap]]miniMapData';
const miniMapData = window.sessionStorage.setItem(key);
if(!getJson(miniMapData)) return;
const data = getJson(miniMapData) || await getDataFromBackend();
setTakeOverAppMethods(data) setTakeOverAppMethods(data)
// 思维导图实例创建完成事件
// window.$bus.$on('app_inited', (mindMap) => {
// console.log('思维导图实例创建完成事件',mindMap)
// })
// 实例化页面
window.initApp() window.initApp()
} }
</script> </script>
......
...@@ -95,6 +95,12 @@ export const manualSaveConfig = config=>{ ...@@ -95,6 +95,12 @@ export const manualSaveConfig = config=>{
if(window.takeOverAppMethods?.saveManualMindMapData){ if(window.takeOverAppMethods?.saveManualMindMapData){
window.takeOverAppMethods.saveManualMindMapData(config) window.takeOverAppMethods.saveManualMindMapData(config)
} }
if(window.parent){
const data = JSON.stringify(config.data)
window.parent.postMessage('miniMap_save#*#' + data)
}
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
...@@ -105,6 +111,10 @@ export const manualCancel= ()=>{ ...@@ -105,6 +111,10 @@ export const manualCancel= ()=>{
if(window.takeOverAppMethods?.manualCancel){ if(window.takeOverAppMethods?.manualCancel){
window.takeOverAppMethods.manualCancel() window.takeOverAppMethods.manualCancel()
} }
if(window.parent){
window.parent.postMessage('miniMap_close')
}
} }
......
...@@ -219,12 +219,11 @@ export default { ...@@ -219,12 +219,11 @@ export default {
data: this.mindMap.getData(true), data: this.mindMap.getData(true),
file file
} }
manualSaveConfig(config) manualSaveConfig(config);
}, },
handleClose(){ handleClose(){
console.log('handleClose') manualCancel();
manualCancel()
}, },
// 显示loading // 显示loading
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment