import { ResourceModule } from "."; export type ActiveKeys = { type: string; id?: string; mId?: string; }; export const store = ResourceModule.store({ state: () => ({ type: "video", sourceDetail: { webEditor: { pack: {} }, } as any, matSlots: [] as any[], meshSlots: [] as any[], activeKeys: { type: "" } as ActiveKeys, treeData: [], }), getters: { currentMesh(state) { return ( state.treeData.find( (e: any) => e.Id == (state.activeKeys.type == "mesh" ? state.activeKeys.id : state.activeKeys.mId) ) || {} ); }, currentMat() { return {}; }, currentSlot(state) { if (state.activeKeys.type == "mesh") return state.meshSlots.find((d) => d.id == state.activeKeys.id); else if (state.activeKeys.type == "mat") return state.matSlots.find((d) => d.id == state.activeKeys.id); }, // currentMat(state) { // return this.store.currentMesh?.children?.find( // (e: any) => e.id == state.activeKeys.id // ); // }, }, actions: { setSourceType(v: string) { this.store.type = v; }, setSourceDetail(data) { this.store.sourceDetail = data; }, setActiveKey(data: ActiveKeys) { this.store.activeKeys = data; }, setTreeData(data) { this.store.treeData = data; }, }, });