Commit 8262071b authored by rockyl's avatar rockyl

独立编辑加锁

parent fdaf0b39
...@@ -30,6 +30,7 @@ export const editorStore = { ...@@ -30,6 +30,7 @@ export const editorStore = {
svgaCache: {}, svgaCache: {},
svgaLoadingQueue: {}, svgaLoadingQueue: {},
assetSizeCache: {}, assetSizeCache: {},
processEditorWin: null,
}, },
mutations: { mutations: {
updateEnv(state, env) { updateEnv(state, env) {
...@@ -46,15 +47,22 @@ export const editorStore = { ...@@ -46,15 +47,22 @@ export const editorStore = {
state.codeSyncServeConfig = config; state.codeSyncServeConfig = config;
localStorage.setItem(storeKey, JSON.stringify(state.codeSyncServeConfig)); localStorage.setItem(storeKey, JSON.stringify(state.codeSyncServeConfig));
}, },
updateProcessEditorWin(state, win) {
state.processEditorWin = win;
}
}, },
getters: { getters: {
assetSize: state => url => { assetSize: state => url => {
let size = state.assetSizeCache[url]; let size = state.assetSizeCache[url];
if(size){ if (size) {
return `${size.width}x${size.height}` return `${size.width}x${size.height}`
} }
return '0x0'; return '0x0';
} },
behaviorEditable(state){
let win = state.processEditorWin;
return !win || win.closed || !win.editable;
},
}, },
actions: { actions: {
async updateEnv({state, commit}) { async updateEnv({state, commit}) {
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
}, },
async mounted() { async mounted() {
if (!window.saveProcesses) { if (!window.saveProcesses) {
window.saveProcesses = (processes)=> { window.saveProcesses = (processes) => {
this.overwriteProcesses({processes}); this.overwriteProcesses({processes});
this.$message({ this.$message({
message: this.$t('Save behavior successfully'), message: this.$t('Save behavior successfully'),
...@@ -408,10 +408,12 @@ ...@@ -408,10 +408,12 @@
let processEditorUrl = location.href.substr(0, location.href.indexOf('#')) + '#/process-editor'; let processEditorUrl = location.href.substr(0, location.href.indexOf('#')) + '#/process-editor';
let processEditorWin = this.processEditorWin = open(processEditorUrl, 'Process Editor', 'width=800, height=600'); let processEditorWin = this.processEditorWin = open(processEditorUrl, 'Process Editor', 'width=800, height=600');
if (processEditorWin.reset) { this.updateProcessEditorWin(processEditorWin);
if(processEditorWin.editable()){
if (processEditorWin.editable) {
if (processEditorWin.editable()) {
this.showStandaloneEditor(path, index); this.showStandaloneEditor(path, index);
}else{ } else {
this.$message({ this.$message({
message: this.$t('A behavior is being edited. Please save it first'), message: this.$t('A behavior is being edited. Please save it first'),
type: 'warning' type: 'warning'
...@@ -434,7 +436,7 @@ ...@@ -434,7 +436,7 @@
handleBehaviorsChange() { handleBehaviorsChange() {
this.makeProjectDirty(); this.makeProjectDirty();
}, },
...mapMutations(['makeProjectDirty', 'overwriteProcesses']), ...mapMutations(['makeProjectDirty', 'overwriteProcesses', 'updateProcessEditorWin']),
...mapActions([ ...mapActions([
'loadPackages', 'loadPackages',
'localVersionExist', 'localVersionExist',
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
} }
}, },
computed: { computed: {
...mapGetters(['activeComponent', 'componentList']) ...mapGetters(['activeComponent', 'componentList', 'behaviorEditable'])
}, },
methods: { methods: {
getBehavior(behavior) { getBehavior(behavior) {
...@@ -89,20 +89,24 @@ ...@@ -89,20 +89,24 @@
} }
}, },
addTrigger(command) { addTrigger(command) {
let trigger = {behaviors: []}; if(this.behaviorEditable){
switch (command) { let trigger = {behaviors: []};
case 'custom-global': switch (command) {
case 'custom-private': case 'custom-global':
trigger.custom = true; case 'custom-private':
break; trigger.custom = true;
} break;
}
if (command === 'custom-private') { if (command === 'custom-private') {
trigger.private = true; trigger.private = true;
} }
this.addBehavior(command, trigger.behaviors); this.addBehavior(command, trigger.behaviors);
this.$set(this.activeComponent.events, command, trigger); this.$set(this.activeComponent.events, command, trigger);
}else{
this.$message('独立过程编辑器正在使用中,不可编辑')
}
}, },
toggleCollapse(trigger) { toggleCollapse(trigger) {
this.$set(trigger, 'collapse', !trigger.collapse); this.$set(trigger, 'collapse', !trigger.collapse);
...@@ -122,13 +126,17 @@ ...@@ -122,13 +126,17 @@
} }
}, },
addBehavior(eventName, behaviors) { addBehavior(eventName, behaviors) {
const alias = `${this.activeComponent.name}_${eventName}` + (behaviors.length > 0 ? '_' + (behaviors.length + 1) : ''); if(this.behaviorEditable){
const alias = `${this.activeComponent.name}_${eventName}` + (behaviors.length > 0 ? '_' + (behaviors.length + 1) : '');
this.addBehaviorDirect({ this.addBehaviorDirect({
alias, behaviors, alias, behaviors,
}); });
this.makeProjectDirty(); this.makeProjectDirty();
}else{
this.$message('独立过程编辑器正在使用中,不可编辑')
}
}, },
editTriggerName(name) { editTriggerName(name) {
this.$prompt(this.$t('Input event name'), this.$t('Rename event'), { this.$prompt(this.$t('Input event name'), this.$t('Rename event'), {
...@@ -167,24 +175,29 @@ ...@@ -167,24 +175,29 @@
this.makeProjectDirty(); this.makeProjectDirty();
}, },
async deleteBehavior(index, behaviors) { async deleteBehavior(index, behaviors) {
let deleteMeta = false; if(this.behaviorEditable){
await this.$confirm(this.$t('Are you sure to delete it\'s process?'), this.$t('Alert'), { let deleteMeta = false;
confirmButtonText: this.$t('Delete'), await this.$confirm(this.$t('Are you sure to delete it\'s process?'), this.$t('Alert'), {
cancelButtonText: this.$t('Not delete'), confirmButtonText: this.$t('Delete'),
distinguishCancelAndClose: true, cancelButtonText: this.$t('Not delete'),
type: 'warning' distinguishCancelAndClose: true,
}).then(() => { type: 'warning'
deleteMeta = true; }).then(() => {
this.makeProjectDirty(); deleteMeta = true;
}).catch(action => { this.makeProjectDirty();
}).catch(action => {
}); });
this.deleteBehaviorDirect({
behaviors,
index,
deleteMeta,
})
}else{
this.$message('独立过程编辑器正在使用中,不可编辑')
}
this.deleteBehaviorDirect({
behaviors,
index,
deleteMeta,
})
}, },
...mapActions([ ...mapActions([
'modifyActiveView', 'modifyActiveView',
......
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