This commit is contained in:
2025-03-20 14:53:02 +00:00
parent 111b6fbadd
commit 9cd93e60df
10 changed files with 227 additions and 95 deletions

29
stores/componentStore.ts Normal file
View File

@@ -0,0 +1,29 @@
import { DraggablePropsType } from "@/components/Draggable/Draggable";
import { makeAutoObservable } from "mobx";
class ComponentsStore {
components:DraggablePropsType[] = [];
constructor() {
makeAutoObservable(this);
}
initComponent(componentsList:DraggablePropsType[]) {
this.components = componentsList || [];
}
changeComponent(componentsList:DraggablePropsType) {
this.components = this.components.map(item => {
if (item.id !== componentsList.id) {
return item;
}
return componentsList;
})
}
delectComponent(componentsList:DraggablePropsType) {
this.components = this.components.filter(item => item.id !== componentsList.id);
}
}
export default new ComponentsStore();