From f558f3b3c7309f292d2e485edc717123060ca639 Mon Sep 17 00:00:00 2001 From: admin <572701190@qq.com> Date: Mon, 4 May 2026 03:19:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E6=80=BB=E4=BD=93=E6=A6=82=E5=86=B5=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 Zustand 默认 activeModule 从 workspace 调整为 dashboard,登录后默认展示总体概况页。 - 同步测试 resetStore 的默认模块,避免测试环境与真实默认入口不一致。 - 补充 useStore 默认模块回归测试,固定 dashboard 初始入口行为。 - 更新 AGENTS 和前端实现文档,记录登录后的默认模块。 --- AGENTS.md | 2 +- doc/02-current-implementation-map.md | 1 + src/store/useStore.test.ts | 4 ++++ src/store/useStore.ts | 2 +- src/test/storeTestUtils.ts | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ad1f27e..99d45af 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -181,7 +181,7 @@ uvicorn main:app --host 0.0.0.0 --port 8000 --reload - 单页应用,无路由库;模块切换由 `useStore().activeModule` 控制。 - 模块值包括:`dashboard`、`projects`、`ai`、`workspace`、`templates`。 -- 默认模块是 `workspace`。 +- 默认模块是 `dashboard`,用户登录后默认进入“总体概况”页。 - 未登录时渲染 `Login`。 - 登录成功后后端返回签名 JWT,token 写入 `localStorage`,Axios request interceptor 会附加 `Authorization: Bearer `。 - `App.tsx` 在已有 token 或登录成功后调用 `/api/auth/me` 恢复当前用户,再调用 `getProjects()` 初始化当前用户项目列表。 diff --git a/doc/02-current-implementation-map.md b/doc/02-current-implementation-map.md index af7b73a..9b67900 100644 --- a/doc/02-current-implementation-map.md +++ b/doc/02-current-implementation-map.md @@ -29,6 +29,7 @@ ## 前端模块切换 `App.tsx` 使用 Zustand 中的 `activeModule` 做模块切换,没有使用路由库。 +`useStore` 默认 `activeModule` 为 `dashboard`,因此用户登录后默认进入“总体概况”页。 | activeModule | 组件 | 页面 | |--------------|------|------| diff --git a/src/store/useStore.test.ts b/src/store/useStore.test.ts index a5a9da9..6c313ad 100644 --- a/src/store/useStore.test.ts +++ b/src/store/useStore.test.ts @@ -7,6 +7,10 @@ describe('useStore', () => { resetStore(); }); + it('defaults to the dashboard module after login state is initialized', () => { + expect(useStore.getState().activeModule).toBe('dashboard'); + }); + it('stores and clears auth state with localStorage', () => { useStore.getState().login('token-1', { id: 1, username: 'admin', role: 'admin' }); diff --git a/src/store/useStore.ts b/src/store/useStore.ts index 9b72c39..68c3728 100644 --- a/src/store/useStore.ts +++ b/src/store/useStore.ts @@ -233,7 +233,7 @@ export const useStore = create((set) => ({ })), // Workspace - activeModule: 'workspace', + activeModule: 'dashboard', activeTool: 'move', aiModel: DEFAULT_AI_MODEL_ID, frames: [], diff --git a/src/test/storeTestUtils.ts b/src/test/storeTestUtils.ts index e77fe67..64b25c9 100644 --- a/src/test/storeTestUtils.ts +++ b/src/test/storeTestUtils.ts @@ -7,7 +7,7 @@ export function resetStore() { currentUser: null, projects: [], currentProject: null, - activeModule: 'workspace', + activeModule: 'dashboard', activeTool: 'move', aiModel: DEFAULT_AI_MODEL_ID, frames: [],