feat: 清空撤销和重做
parent
6401b51995
commit
36a527f926
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<svg width="24" height="24" viewBox="0 0 48 48" fill="none"
|
<svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
xmlns="http://www.w3.org/2000/svg">
|
<g stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<path d="M11.2721 36.7279C14.5294 39.9853 19.0294 42 24 42C33.9411 42 42 33.9411 42 24C42 14.0589 33.9411 6 24 6C19.0294 6 14.5294 8.01472 11.2721 11.2721C9.61407 12.9301 6 17 6 17" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M11.2721 36.7279C14.5294 39.9853 19.0294 42 24 42C33.9411 42 42 33.9411 42 24C42 14.0589 33.9411 6 24 6C19.0294 6 14.5294 8.01472 11.2721 11.2721C9.61407 12.9301 6 17 6 17"/>
|
||||||
<path d="M6 9V17H14" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
<path d="M6 9V17H14" />
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 460 B |
@ -0,0 +1,54 @@
|
|||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { useGlobalStore } from '../global';
|
||||||
|
import { EditPrivateStoreState } from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑器私有状态
|
||||||
|
*/
|
||||||
|
export const useEditPrivateStore = defineStore('edit-private-store', {
|
||||||
|
state: (): EditPrivateStoreState => {
|
||||||
|
return {
|
||||||
|
old_done_components: [], //记录预览之前的组件数据
|
||||||
|
history_doneComponent: [],
|
||||||
|
history_nowindex: 0,
|
||||||
|
is_record_history: true //是否需要记录当前状态,如果是操作的历史记录,则不需要记录
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
getTopBtnUndoStatus(state) {
|
||||||
|
if (state.history_nowindex < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
getTopBtnRedoStatus(state) {
|
||||||
|
if (state.history_nowindex + 1 == state.history_doneComponent.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
topUndoBtnClick() {
|
||||||
|
console.log('撤销');
|
||||||
|
if (this.history_nowindex < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const global_store = useGlobalStore();
|
||||||
|
// select_component_info.value = {};
|
||||||
|
this.is_record_history = false;
|
||||||
|
this.history_nowindex -= 1;
|
||||||
|
global_store.setDoneJson(this.history_doneComponent[this.history_nowindex]);
|
||||||
|
},
|
||||||
|
topRedoBtnClick() {
|
||||||
|
console.log('重做');
|
||||||
|
if (this.history_nowindex + 1 == this.history_doneComponent.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const global_store = useGlobalStore();
|
||||||
|
this.is_record_history = false;
|
||||||
|
this.history_nowindex += 1;
|
||||||
|
global_store.setDoneJson(this.history_doneComponent[this.history_nowindex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,8 @@
|
|||||||
|
import { IDoneJson } from '../global/types';
|
||||||
|
|
||||||
|
export interface EditPrivateStoreState {
|
||||||
|
old_done_components: IDoneJson[];
|
||||||
|
history_doneComponent: IDoneJson[][];
|
||||||
|
history_nowindex: number;
|
||||||
|
is_record_history: boolean;
|
||||||
|
}
|
Loading…
Reference in New Issue