diff --git a/src/components/DrawingBroad.vue b/src/components/DrawingBroad.vue index 4d77cbfe64890b5d79ff0c9266af4eef7fba757c..dc54adfdad03e370fb7d42555e2e01e20019b2ea 100644 --- a/src/components/DrawingBroad.vue +++ b/src/components/DrawingBroad.vue @@ -15,9 +15,8 @@ const containerStyle = computed(() => ({ })) function saveStateList() { - if (statePoint.value !== stateStack.value.length - 1) { + if (statePoint.value !== stateStack.value.length - 1||statePoint.value === -1) { mainStore.clearStackTop(); - console.log(stateStack.value.concat()) } stateStack.value.push(tList.value.concat()) statePoint.value = stateStack.value.length - 1 diff --git a/src/store/index.ts b/src/store/index.ts index 905bea8fe326f24d184d7676963bddf6b9c40aa2..858252654f7fce1a6f529abd9717181bb8784c34 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -11,7 +11,7 @@ interface componentType { } // 使用setup模式定义 -// Re: 不建议使用setup模式定义,已改进 +// Re: 不建议使用setup模式定义,已改进 git export const userMainStore = defineStore('mainStore', { state: () => ({ list: config.componentList, @@ -22,8 +22,11 @@ export const userMainStore = defineStore('mainStore', { }), actions: { executeUndo(): void { - if (this.statePoint < 0) return; this.statePoint--; + if (this.statePoint < 0) { + this.tList = [] + return + } this.tList = this.stateStack[this.statePoint].concat(); }, executeRedo(): void {