diff --git a/src/pages/chat/ChatPagePure.tsx b/src/pages/chat/ChatPagePure.tsx index af58cee..f4a6ad2 100644 --- a/src/pages/chat/ChatPagePure.tsx +++ b/src/pages/chat/ChatPagePure.tsx @@ -1,5 +1,5 @@ import { useEffect, useState, useCallback, useRef } from 'react'; -import { App as AntApp, Empty } from 'antd'; +import { App as AntApp, Empty, Modal } from 'antd'; import type { ChatPageLogicOutput } from './ChatPageLogic'; import { markdownToPlainText } from './utils/copy'; import { useChatPageLogic } from './ChatPageLogic'; @@ -9,6 +9,7 @@ import ChatHeader from './components/ChatHeader'; import ChatInput from './components/ChatInput'; import ChatOutline from './components/ChatOutline'; import type { ModelOverrides } from '../../api'; +import { useAuth } from '../../store/auth'; import './styles/chat-page-pure.css'; /** @@ -19,6 +20,7 @@ import './styles/chat-page-pure.css'; export default function ChatPagePure() { const logic = useChatPageLogic(); const { message } = AntApp.useApp(); + const { logout } = useAuth(); const [outlineCollapsed, setOutlineCollapsed] = useState(true); const isAutoScrolling = useRef(false); @@ -70,6 +72,17 @@ export default function ChatPagePure() { } }, [setHighlightId]); + // 退出登录 + const handleLogout = () => { + Modal.confirm({ + title: '确定要退出登录吗?', + onOk: async () => { + await logout(); + window.location.href = '/login'; + }, + }); + }; + return (
@@ -89,6 +102,7 @@ export default function ChatPagePure() { onOpenMcp={() => setMcpDrawerOpen(true)} onManageAgent={() => navigate(`/agents/${id}`)} onClear={sender.handleClear} + onLogout={handleLogout} /> void; onManageAgent: () => void; onClear: () => void; + onLogout?: () => void; }) { - const { agent, useStream, setUseStream, onOpenHistory, onOpenParams, onOpenMcp, onManageAgent, onClear } = props; + const { agent, useStream, setUseStream, onOpenHistory, onOpenParams, onOpenMcp, onManageAgent, onClear, onLogout } = props; const modelText = formatAgentModel(agent.model); return ( @@ -86,7 +87,18 @@ export default function ChatHeader(props: { onClick: () => { Modal.confirm({ title: '清空当前会话所有消息?', onOk: onClear }); } - } + }, + ...(onLogout + ? [ + { type: 'divider' as const }, + { + key: 'logout', + label: '退出登录', + icon: , + onClick: onLogout, + } + ] + : []) ] }} placement="bottomRight"