Commit 10674cff authored by rockyl's avatar rockyl

修改:当hash修改的时候,把editor重载一遍

parent a15f7a96
...@@ -45,15 +45,9 @@ export const projectStore = { ...@@ -45,15 +45,9 @@ export const projectStore = {
Vue.set(localData, 'dataMapping', dataMapping || []); Vue.set(localData, 'dataMapping', dataMapping || []);
} }
}else{ }else{
if (!localData.views) { Vue.set(localData, 'views', []);
Vue.set(localData, 'views', []); Vue.set(localData, 'assets', []);
} Vue.set(localData, 'dataMapping', []);
if (!localData.assets) {
Vue.set(localData, 'assets', []);
}
if (!localData.dataMapping) {
Vue.set(localData, 'dataMapping', []);
}
} }
// compoleteComponentData(state.data.views); // compoleteComponentData(state.data.views);
}, },
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
.right-part{ .right-part{
color: $--color-text-regular; color: $--color-text-regular;
line-height: 15px;
.el-button{ .el-button{
padding: 2px; padding: 2px;
......
<template> <template>
<div class="editor"> <div class="editor" v-if="ready">
<tool-bar @click-menu="clickMenu"/> <tool-bar @click-menu="clickMenu"/>
<split-panes class="pane-container" @resized="onPanesReSized(0, $event)"> <split-panes class="pane-container" @resized="onPanesReSized(0, $event)">
<split-panes splitpanes-min="40" :splitpanes-size="getSize(0, 0)" horizontal @resized="onPanesReSized(1, $event)"> <split-panes splitpanes-min="40" :splitpanes-size="getSize(0, 0)" horizontal @resized="onPanesReSized(1, $event)">
...@@ -45,41 +45,59 @@ ...@@ -45,41 +45,59 @@
const panesConfig = localStorage.panesConfig ? JSON.parse(localStorage.panesConfig) : [0.8, 0.8, 0.3]; const panesConfig = localStorage.panesConfig ? JSON.parse(localStorage.panesConfig) : [0.8, 0.8, 0.3];
return { return {
panesConfig, panesConfig,
ready: false,
}
},
watch: {
$route: {
handler: function(val, oldVal){
console.log('router changed');
this.loadProject();
},
deep: true
} }
}, },
computed: { computed: {
...mapGetters([]), ...mapGetters([]),
}, },
async mounted() { mounted() {
const {projectID} = this.$route.params; this.loadProject();
if (await this.localVersionExist(projectID)) {
this.$confirm(this.$t('Unsaved version found locally'), this.$t('Alert'), {
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
confirmButtonText: this.$t('Local Version'),
cancelButtonText: this.$t('Remote Version'),
type: 'warning'
}).then(() => {
this.loadLocalVersion(projectID);
}).catch((e) => {
if (e === 'cancel') {
this.loadRemoteVersion(projectID);
} else {
console.log(e);
}
});
} else {
this.loadRemoteVersion(projectID);
}
}, },
methods: { methods: {
async loadProject(){
const {projectID} = this.$route.params;
if (await this.localVersionExist(projectID)) {
this.$confirm(this.$t('Unsaved version found locally'), this.$t('Alert'), {
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
confirmButtonText: this.$t('Local Version'),
cancelButtonText: this.$t('Remote Version'),
type: 'warning'
}).then(() => {
this.loadLocalVersion(projectID);
}).catch((e) => {
if (e === 'cancel') {
this.loadRemoteVersion(projectID);
} else {
console.log(e);
}
});
} else {
this.loadRemoteVersion(projectID);
}
},
loadLocalVersion(projectID) { loadLocalVersion(projectID) {
this.loadFromLocal(projectID) this.ready = false;
this.loadFromLocal(projectID);
this.$nextTick(()=>{
this.ready = true;
});
}, },
loadRemoteVersion(projectID) { async loadRemoteVersion(projectID) {
if (projectID) { if (projectID) {
playWaiting(this.loadFromRemote(projectID), this.$t('Preparing')).catch(e => { this.ready = false;
await playWaiting(this.loadFromRemote(projectID), this.$t('Preparing')).catch(e => {
this.$alert(this.$t('Project does not exist'), this.$t('Alert'), { this.$alert(this.$t('Project does not exist'), this.$t('Alert'), {
confirmButtonText: this.$t('Confirm'), confirmButtonText: this.$t('Confirm'),
callback: action=>{ callback: action=>{
...@@ -87,6 +105,7 @@ ...@@ -87,6 +105,7 @@
} }
}); });
}); });
this.ready = true;
} else { } else {
this.$router.push({name: 'home'}) this.$router.push({name: 'home'})
} }
......
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