From d9b2e860fffe45da968c8a5604e49d7668b32e0e Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 17 May 2026 11:25:39 +0800 Subject: [PATCH] auto-sync: 2026-05-17 11:25:38 --- src/frontend/src/store.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/store.ts b/src/frontend/src/store.ts index d98d5b7..51a3e0a 100644 --- a/src/frontend/src/store.ts +++ b/src/frontend/src/store.ts @@ -429,8 +429,17 @@ export const useStore = create((set, get) => ({ try { const data = await api.liveStatus(); set({ liveStatus: data }); - // Also preload officials for monitor tab + // 同步项目列表 + const projects = (data.syncStatus as any)?.projects || {}; + set({ projects }); + // 自动选择第一个项目 const s = get(); + if (!s.selectedProjectId && Object.keys(projects).length > 0) { + const firstPid = Object.keys(projects)[0]; + set({ selectedProjectId: firstPid }); + setApiProjectId(firstPid); + } + // Also preload officials for monitor tab if (!s.officialsData) { api.officialsStats().then((d) => set({ officialsData: d })).catch(() => {}); } @@ -439,6 +448,21 @@ export const useStore = create((set, get) => ({ } }, + loadProjects: async () => { + try { + const data = await api.projects(); + set({ projects: data.projects }); + const s = get(); + if (!s.selectedProjectId && Object.keys(data.projects).length > 0) { + const firstPid = Object.keys(data.projects)[0]; + set({ selectedProjectId: firstPid }); + setApiProjectId(firstPid); + } + } catch { + // silently fail + } + }, + loadAgentConfig: async () => { try { const cfg = await api.agentConfig();