diff --git a/src/App.tsx b/src/App.tsx index eca4852..0660b00 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -18,19 +18,7 @@ import { useAuth } from './store/auth'; import { AgentAPI } from './api'; function HomeRedirect() { - const navigate = useNavigate(); - useEffect(() => { - AgentAPI.list().then(list => { - if (list.length > 0) { - navigate(`/agents/${list[0].id}/chat`, { replace: true }); - } else { - navigate('/agents', { replace: true }); - } - }).catch(() => { - navigate('/agents', { replace: true }); - }); - }, [navigate]); - return
; + return ; } export default function App() { @@ -54,10 +42,12 @@ export default function App() { const mainContent = ( } /> + } /> + } /> } /> } /> } /> - } /> + } /> } /> } /> } /> diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index c49e54b..25bddc5 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -28,7 +28,7 @@ const NAV_GROUPS: Array<{ { label: '工作台', items: [ - { to: '/', icon: , label: '聊天', end: true }, + { to: '/chat', icon: , label: '聊天' }, { to: '/agents', icon: , label: '我的智能体' }, { to: '/marketplace', icon: , label: '智能体广场' } ] diff --git a/src/pages/AgentList.tsx b/src/pages/AgentList.tsx index bbc444e..53918c8 100644 --- a/src/pages/AgentList.tsx +++ b/src/pages/AgentList.tsx @@ -226,10 +226,10 @@ export default function AgentList() {
- + + 聊天 + +
+
+ {agentList.map((a) => { + const isActive = a.id === id; + return ( +
navigate(`/chat/${a.id}`)} + style={{ + display: 'flex', + alignItems: 'center', + gap: 12, + padding: '10px 16px', + cursor: 'pointer', + background: isActive ? 'var(--color-surface-2)' : 'transparent', + borderLeft: `3px solid ${isActive ? 'var(--color-brand)' : 'transparent'}`, + transition: 'background 0.2s' + }} + > +
+ {isImageUrl(a.avatar) ? ( + avatar + ) : ( + (a.name?.charAt(0) || '?').toUpperCase() + )} +
+
+
+ {a.name} +
+
+
+ ); + })} +
+ + + {/* 2. 主聊天区 */} +
+ {!agent ? ( +
+ +
+ ) : ( + <> + {/* Header */} +
+
+
{agent.name}
+
+ {agent.model || '默认模型'} · T={agent.temperature} +
+
+ +
+ 流式输出 + +
+ + , onClick: () => setParamsDrawerOpen(true) }, + { key: 'mcp', label: 'MCP 资源', icon: , onClick: () => setMcpDrawerOpen(true) }, + { key: 'edit', label: '管理 Agent', icon: , onClick: () => navigate(`/agents/${id}`) }, + { type: 'divider' }, + { key: 'clear', label: '清空对话', icon: , danger: true, onClick: () => { + Modal.confirm({ + title: '清空当前会话所有消息?', + onOk: handleClear + }); + } + } + ] + }} + > + + +
- - - - {/* 会话切换 */} -
- {id && ( - { - setSessionId(sid); - setHighlightId(opts?.highlightMessageId || null); - }} - refreshTick={sessionRefresh} - /> - )} -
- - - - -
- - ⚡ 流式输出 - - -
- - - - - - - -
- - - {/* 2. 主聊天区 */} -
- {/* Header */} -
-
-
{agent.name}
-
- {agent.model || '默认模型'} · T={agent.temperature} -
-
-
- - {/* Body */} -
+ + {/* Body */} +
{messages.length === 0 && !streaming.active ? (
@@ -778,12 +762,14 @@ export default function ChatPage() {
AI 可能会产生错误信息,请核实重要信息。 -
-
-
- - {/* ---- 抽屉组件保持不变 ---- */} - {id && ( + + + + )} +
+ + {/* ---- 抽屉组件保持不变 ---- */} + {id && ( - - - - ); + + + + setHistoryDrawerOpen(false)} + open={historyDrawerOpen} + bodyStyle={{ padding: 0 }} + > + {id && ( + { + setSessionId(sid); + setHighlightId(opts?.highlightMessageId || null); + setHistoryDrawerOpen(false); + }} + refreshTick={sessionRefresh} + /> + )} + + + ); } /** 输入栏子组件 */