refactor(web): React 最佳实践优化 — memo/callback + 目录边界 + 路由增强
- useLogger: useMemo + JSON.stringify 替代 useState 派生 - useIsDark: effectiveTheme 替代 token 色值比较 - useCurrentProject: layouts/ 提升到 shared/hooks/ - ConsoleShell: locale useMemo 缓存 - ConsoleOutlet: 添加 Suspense 边界 - routes: 添加 layout 级 errorElement - Table 组件: operationColumn useMemo + useCallback - ChatPanel: footer 合并为 useCallback, props 传入模型数据 - ChatPage: textModels/conversations useMemo 缓存
This commit is contained in:
@@ -83,8 +83,10 @@ describe("ChatPanel", () => {
|
||||
renderWithProviders(
|
||||
createElement(ChatPanel, {
|
||||
conversationId: null,
|
||||
defaultModelId: "model-1",
|
||||
onConversationCreated: noop,
|
||||
projectId: PROJECT_ID,
|
||||
textModels: [TEXT_MODEL],
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -102,8 +104,10 @@ describe("ChatPanel", () => {
|
||||
renderWithProviders(
|
||||
createElement(ChatPanel, {
|
||||
conversationId: null,
|
||||
defaultModelId: "model-1",
|
||||
onConversationCreated: onCreated,
|
||||
projectId: PROJECT_ID,
|
||||
textModels: [TEXT_MODEL],
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -133,8 +137,10 @@ describe("ChatPanel", () => {
|
||||
renderWithProviders(
|
||||
createElement(ChatPanel, {
|
||||
conversationId: null,
|
||||
defaultModelId: "model-1",
|
||||
onConversationCreated: noop,
|
||||
projectId: PROJECT_ID,
|
||||
textModels: [TEXT_MODEL],
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -154,8 +160,10 @@ describe("ChatPanel", () => {
|
||||
renderWithProviders(
|
||||
createElement(ChatPanel, {
|
||||
conversationId: "conv-1",
|
||||
defaultModelId: "model-1",
|
||||
onConversationCreated: noop,
|
||||
projectId: PROJECT_ID,
|
||||
textModels: [TEXT_MODEL],
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user