diff --git a/components.d.ts b/components.d.ts index 7edf44a6c661662630918baee0ec2201f9641bab..72b943820c5e8a3e4f8780760434b363f92b6e7c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -12,10 +12,6 @@ declare module '@vue/runtime-core' { DrawingBroad: typeof import('./src/components/DrawingBroad.vue')['default'] ElButton: typeof import('element-plus/es')['ElButton'] ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] - ElContainer: typeof import('element-plus/es')['ElContainer'] - ElDivider: typeof import('element-plus/es')['ElDivider'] - ElDrawer: typeof import('element-plus/es')['ElDrawer'] - ElHeader: typeof import('element-plus/es')['ElHeader'] ElIcon: typeof import('element-plus/es')['ElIcon'] ElImage: typeof import('element-plus/es')['ElImage'] ElInput: typeof import('element-plus/es')['ElInput'] diff --git a/src/components/DrawingBroad.vue b/src/components/DrawingBroad.vue index 0c090cc638b5e1c9f46e1b9c42c7f102a1d361e3..4d77cbfe64890b5d79ff0c9266af4eef7fba757c 100644 --- a/src/components/DrawingBroad.vue +++ b/src/components/DrawingBroad.vue @@ -1,94 +1,102 @@ \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index 54ba93acf3e9eb66992bf3529779d78dca7855af..905bea8fe326f24d184d7676963bddf6b9c40aa2 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,21 +1,38 @@ -import { reactive } from 'vue'; -import { defineStore } from 'pinia'; -import config from "@/config/editor.config"; +import {reactive, ref} from 'vue'; +import {defineStore} from 'pinia'; +import config from "@/config/editor.config"; import data from "@/config/data.json"; + interface componentType { - label: string, - preview: string, - render: string, - key: string + label: string, + preview: string, + render: string, + key: string } // 使用setup模式定义 -export const userMainStore = defineStore('mainStore', () => { - const list: Array = reactive(config.componentList); - const tList: Array = reactive([]); - - //json schema - const tree = reactive(data); - - return {list,tList,tree}; //暴露 +// Re: 不建议使用setup模式定义,已改进 +export const userMainStore = defineStore('mainStore', { + state: () => ({ + list: config.componentList, + tList: [], + stateStack: [], + statePoint: -1, + tree: data, + }), + actions: { + executeUndo(): void { + if (this.statePoint < 0) return; + this.statePoint--; + this.tList = this.stateStack[this.statePoint].concat(); + }, + executeRedo(): void { + if (this.statePoint === this.stateStack.length - 1) return; + this.statePoint++; + this.tList = this.stateStack[this.statePoint].concat(); + }, + clearStackTop(): void { + this.stateStack.splice(this.statePoint + 1) + } + } }); \ No newline at end of file diff --git a/src/views/Panel.vue b/src/views/Panel.vue index 18a75837576ca2dc709faf72b71534d14d63527d..0d449ef410f7c1b6563d6d2c4cb0e1201cbe3ec6 100644 --- a/src/views/Panel.vue +++ b/src/views/Panel.vue @@ -13,7 +13,7 @@
- + @@ -21,7 +21,7 @@
- +
@@ -29,18 +29,18 @@
+ @change="handleChange" v-if="flog"/> + @change="handleChange" v-else/>
- + - +
@@ -60,21 +60,21 @@
- +
- +
- +
@@ -83,21 +83,21 @@
- +
- +
- +
自定义组件
@@ -107,10 +107,10 @@
- +
- +
@@ -118,18 +118,26 @@