/** * SSASidebar - V11 左侧抽屉栏 * * 100% 还原 V11 原型图 * - 汉堡菜单切换展开/收起 * - Logo + 新建按钮 * - 历史记录列表(展开时显示) */ import React, { useState, useEffect } from 'react'; import { Menu, BarChart3, Plus, MessageSquare } from 'lucide-react'; import { useSSAStore } from '../stores/ssaStore'; import apiClient from '@/common/api/axios'; import type { SSASession } from '../types'; interface HistoryItem { id: string; title: string; status: 'active' | 'completed' | 'archived'; } export const SSASidebar: React.FC = () => { const { sidebarExpanded, setSidebarExpanded, currentSession, hydrateFromHistory, reset } = useSSAStore(); const [historyItems, setHistoryItems] = useState([]); const [isLoading, setIsLoading] = useState(false); useEffect(() => { if (sidebarExpanded) { fetchHistory(); } }, [sidebarExpanded]); const fetchHistory = async () => { setIsLoading(true); try { const response = await apiClient.get('/api/v1/ssa/sessions'); setHistoryItems(response.data.sessions || []); } catch (error) { console.error('Failed to fetch history:', error); setHistoryItems([]); } finally { setIsLoading(false); } }; const handleToggleSidebar = () => { setSidebarExpanded(!sidebarExpanded); }; const handleNewAnalysis = () => { reset(); }; const handleSelectSession = async (sessionId: string) => { if (sessionId === currentSession?.id) return; try { const response = await apiClient.get(`/api/v1/ssa/sessions/${sessionId}`); const session: SSASession = response.data; hydrateFromHistory(session); } catch (error) { console.error('Failed to load session:', error); } }; return ( ); }; export default SSASidebar;