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

#

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