-
-
-
-
-
-
-
+
\ 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 @@