Commit 8262071b authored by rockyl's avatar rockyl

独立编辑加锁

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