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: [],