From 2d49af3bea494e6dbf87c06fbc322bdd3c35fc1d Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Mon, 24 Nov 2025 16:11:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20UI=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/MainLayout.js | 8 +- .../AgentChat/components/LeftSidebar/index.js | 1 + .../components/RightSidebar/index.js | 1 + src/views/AgentChat/index.js | 109 ++++++++---------- 4 files changed, 53 insertions(+), 66 deletions(-) diff --git a/src/layouts/MainLayout.js b/src/layouts/MainLayout.js index 06d1ae4c..5c298c5b 100644 --- a/src/layouts/MainLayout.js +++ b/src/layouts/MainLayout.js @@ -30,12 +30,12 @@ const MemoizedAppFooter = memo(AppFooter); */ export default function MainLayout() { return ( - + {/* 导航栏 - 在所有页面间共享,memo 后不会在路由切换时重新渲染 */} {/* 页面内容区域 - flex: 1 占据剩余空间,包含错误边界、懒加载 */} - + }> @@ -47,11 +47,11 @@ export default function MainLayout() { {/* 返回顶部按钮 - 滚动超过阈值时显示 */} - + /> */} ); } diff --git a/src/views/AgentChat/components/LeftSidebar/index.js b/src/views/AgentChat/components/LeftSidebar/index.js index 9f9e810d..a893021b 100644 --- a/src/views/AgentChat/components/LeftSidebar/index.js +++ b/src/views/AgentChat/components/LeftSidebar/index.js @@ -71,6 +71,7 @@ const LeftSidebar = ({ > { const { user } = useAuth(); const toast = useToast(); - const { setColorMode } = useColorMode(); // ==================== UI 状态(主组件管理)==================== const [selectedModel, setSelectedModel] = useState(DEFAULT_MODEL_ID); @@ -85,69 +84,55 @@ const AgentChat = () => { // ==================== 输入框引用(保留在主组件)==================== const inputRef = React.useRef(null); - // ==================== 启用深色模式 ==================== - useEffect(() => { - // 为 AgentChat 页面强制启用深色模式 - setColorMode('dark'); - document.documentElement.classList.add('dark'); - - return () => { - // 组件卸载时不移除,让其他页面自己控制 - // document.documentElement.classList.remove('dark'); - }; - }, [setColorMode]); - // ==================== 渲染组件 ==================== return ( - - - {/* 左侧栏 */} - setIsLeftSidebarOpen(false)} - sessions={sessions} - currentSessionId={currentSessionId} - onSessionSwitch={switchSession} - onNewSession={createNewSession} - isLoadingSessions={isLoadingSessions} - user={user} - /> + + {/* 左侧栏 */} + setIsLeftSidebarOpen(false)} + sessions={sessions} + currentSessionId={currentSessionId} + onSessionSwitch={switchSession} + onNewSession={createNewSession} + isLoadingSessions={isLoadingSessions} + user={user} + /> - {/* 中间聊天区 */} - setIsLeftSidebarOpen(true)} - onToggleRightSidebar={() => setIsRightSidebarOpen(true)} - onNewSession={createNewSession} - userAvatar={user?.avatar} - inputRef={inputRef} - fileInputRef={fileInputRef} - /> + {/* 中间聊天区 */} + setIsLeftSidebarOpen(true)} + onToggleRightSidebar={() => setIsRightSidebarOpen(true)} + onNewSession={createNewSession} + userAvatar={user?.avatar} + inputRef={inputRef} + fileInputRef={fileInputRef} + /> - {/* 右侧栏 */} - setIsRightSidebarOpen(false)} - selectedModel={selectedModel} - onModelChange={setSelectedModel} - selectedTools={selectedTools} - onToolsChange={setSelectedTools} - sessionsCount={sessions.length} - messagesCount={messages.length} - /> - - + {/* 右侧栏 */} + setIsRightSidebarOpen(false)} + selectedModel={selectedModel} + onModelChange={setSelectedModel} + selectedTools={selectedTools} + onToolsChange={setSelectedTools} + sessionsCount={sessions.length} + messagesCount={messages.length} + /> + ); };