From 3fc95e2b2a74fd4d4d83e164f9c3555dcdc4baae Mon Sep 17 00:00:00 2001 From: inter Date: Mon, 8 Sep 2025 16:36:32 +0800 Subject: [PATCH] Add File --- frontend/src/stores/dashboard/dashboard.ts | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 frontend/src/stores/dashboard/dashboard.ts diff --git a/frontend/src/stores/dashboard/dashboard.ts b/frontend/src/stores/dashboard/dashboard.ts new file mode 100644 index 0000000..6e59368 --- /dev/null +++ b/frontend/src/stores/dashboard/dashboard.ts @@ -0,0 +1,109 @@ +import { defineStore } from 'pinia' +import { store } from '@/stores' + +export const dashboardStore = defineStore('dashboard', { + state: () => { + return { + tabCollisionActiveId: null, + tabMoveInActiveId: null, + curComponent: null, + curComponentId: null, + canvasStyleData: {}, + componentData: [], + canvasViewInfo: {}, + fullscreenFlag: false, + dataPrepareState: false, + baseMatrixCount: { + x: 72, + y: 36, + }, + dashboardInfo: { + id: null, + name: null, + pid: null, + workspaceId: null, + status: null, + dataState: null, + createName: null, + updateName: null, + createTime: null, + updateTime: null, + contentId: null, + type: null, + }, + } + }, + getters: { + getCurComponent(): any { + return this.curComponent + }, + }, + actions: { + setFullscreenFlag(val: boolean) { + this.fullscreenFlag = val + }, + setCurComponent: function (value: any) { + if (!value && this.curComponent) { + // @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment + this.curComponent.editing = false + } + this.curComponent = value + this.curComponentId = value && value.id ? value.id : null + }, + setDashboardInfo(value: any) { + this.dashboardInfo = value + }, + setComponentData(value: any) { + this.componentData = value + }, + setCanvasStyleData(value: any) { + this.canvasStyleData = value + }, + setTabCollisionActiveId(tabId: any) { + this.tabCollisionActiveId = tabId + }, + setTabMoveInActiveId(tabId: any) { + this.tabMoveInActiveId = tabId + }, + updateDashboardInfo(params: any) { + Object.keys(params).forEach((key: string) => { + if (params[key]) { + // @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment + this.dashboardInfo[key] = params[key] + } + }) + }, + setCanvasViewInfo(params: any) { + this.canvasViewInfo = params + }, + addCanvasViewInfo(params: any) { + // @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment + this.canvasViewInfo[params.id] = params + }, + canvasDataInit() { + this.curComponent = null + this.curComponentId = null + this.canvasStyleData = {} + this.componentData = [] + this.canvasViewInfo = {} + this.dashboardInfo = { + id: null, + name: null, + pid: null, + workspaceId: null, + status: null, + dataState: null, + createName: null, + updateName: null, + createTime: null, + updateTime: null, + contentId: null, + type: null, + } + }, + }, +}) + +export const dashboardStoreWithOut = () => { + return dashboardStore(store) +}