UI: project as seperated workspace

This commit is contained in:
qixinbo
2026-03-22 16:48:41 +08:00
parent 995de29981
commit 6f074df40e
9 changed files with 206 additions and 31 deletions
+16
View File
@@ -17,6 +17,14 @@ export interface ChartConfig {
export interface DashboardConfig {
id: string;
name: string;
titleStyle?: {
fontSize?: string;
fontWeight?: string;
color?: string;
textAlign?: 'left' | 'center' | 'right';
fontStyle?: string;
textDecoration?: string;
};
createdAt: number;
charts: ChartConfig[];
}
@@ -28,6 +36,7 @@ interface DashboardState {
createDashboard: (name: string, projectId: number) => string;
deleteDashboard: (id: string, projectId: number) => void;
renameDashboard: (id: string, newName: string, projectId: number) => void;
updateDashboardTitleStyle: (id: string, style: DashboardConfig['titleStyle'], projectId: number) => void;
setActiveDashboard: (id: string | null) => void;
addChart: (chart: Omit<ChartConfig, 'layout'>, dashboardId: string, projectId: number) => void;
removeChart: (chartId: string, dashboardId: string, projectId: number) => void;
@@ -133,6 +142,13 @@ export const useDashboardStore = create<DashboardState>((set) => ({
saveDashboardsToStorage(nextDashboards, projectId);
return { dashboards: nextDashboards };
}),
updateDashboardTitleStyle: (id, style, projectId) => set((state) => {
const nextDashboards = state.dashboards.map((d) =>
d.id === id ? { ...d, titleStyle: { ...d.titleStyle, ...style } } : d
);
saveDashboardsToStorage(nextDashboards, projectId);
return { dashboards: nextDashboards };
}),
setActiveDashboard: (id) => set({ activeDashboardId: id }),
addChart: (chart, dashboardId, projectId) => set((state) => {
const nextDashboards = state.dashboards.map((d) => {