feat(frontend): add React SPA with chat, auth, and admin pages

- Vite 6 + React 19 + TypeScript + Tailwind 4 + Zustand 5
- Login page with JWT auth
- Chat interface: MessageList, ChatInput, ChatContainer
- WebSocket hook with auto-reconnect and exponential backoff
- Sidebar with new chat button + session navigation
- Admin dashboard placeholder
- 57 modules, 242KB JS, TypeScript zero errors
This commit is contained in:
Aska committed 2026-08-12 11:47:22 +08:00
1 parent 192144563b
commit 4a71965686
35 files changed
+3146

No files matched your search

@@ -0,0 +1,35 @@
import { useNavigate } from 'react-router-dom'
import { useChatStore } from '../../store/chatStore'
import { api } from '../../api/client'
export default function Sidebar() {
const navigate = useNavigate()
const { currentSessionId, setSessionId, clearMessages } = useChatStore()
const handleNewChat = async () => {
try {
const { session_id } = await api.sessions.create()
setSessionId(session_id)
clearMessages()
navigate(`/chat/${session_id}`)
} catch { /* ignore */ }
}
return (
<aside className="w-56 bg-gray-900 border-r border-gray-800 flex flex-col shrink-0">
<div className="p-3">
<button onClick={handleNewChat}
className="w-full py-2 bg-purple-600 hover:bg-purple-500 rounded text-sm font-medium transition-colors">
+ 新对话
</button>
</div>
<div className="flex-1 overflow-auto px-2 text-sm text-gray-400">
{currentSessionId ? (
<p className="px-2 py-1 truncate text-xs">会话: {currentSessionId.slice(0, 8)}...</p>
) : (
<p className="px-2 py-1 text-xs">暂无对话</p>
)}
</div>
</aside>
)
}