import { useState } from 'react'; import ChatList from './components/ChatList'; import ChatWindow from './components/ChatWindow'; import Settings from './components/Settings'; import useLocalStorage from './hooks/useLocalStorage'; function App() { const [profiles, setProfiles] = useLocalStorage('profiles', [ { id: 'default', name: 'Default Profile', apiEndpoint: '', apiKey: '', model: 'DeepSeek-R1' } ]); const [summarizationProfile, setSummarizationProfile] = useLocalStorage('summarizationProfile', { id: 'default-summarization-profile', name: 'Summarization Profile', apiEndpoint: '', apiKey: '', model: 'DeepSeek-R1' }); const [activeProfileId, setActiveProfileId] = useLocalStorage('activeProfileId', 'default'); const [chats, setChats] = useLocalStorage('chats', []); const [currentChatId, setCurrentChatId] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const [showSettings, setShowSettings] = useState(false); const [sidebarCollapsed, setSidebarCollapsed] = useState(false); const [showProfileDropdown, setShowProfileDropdown] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const activeProfile = profiles.find(p => p.id === activeProfileId) || profiles[0]; const createNewChat = () => { const newChat = { id: Date.now(), title: 'New Conversation', messages: [] }; setChats([...chats, newChat]); setCurrentChatId(newChat.id); }; const deleteChat = (chatId) => { setChats(chats.filter(chat => chat.id !== chatId)); if (currentChatId === chatId) { setCurrentChatId(null); } }; const toggleSettings = () => { setShowSettings(!showSettings); }; const toggleSidebar = () => { setSidebarCollapsed(!sidebarCollapsed); // 在移动设备上,如果侧边栏是展开的,点击收起按钮也应该关闭移动菜单 if (window.innerWidth <= 768 && !sidebarCollapsed) { setMobileMenuOpen(false); } }; const toggleMobileMenu = () => { setMobileMenuOpen(!mobileMenuOpen); // 如果侧边栏是收起的,则展开它 if (sidebarCollapsed) { setSidebarCollapsed(false); } }; const toggleProfileDropdown = () => { setShowProfileDropdown(!showProfileDropdown); }; const handleProfileSelect = (profileId) => { setActiveProfileId(profileId); setShowProfileDropdown(false); }; return (

Thinking Model Client

{showProfileDropdown && (
{profiles.map(profile => (
handleProfileSelect(profile.id)} > {profile.name}
))}
)}

Conversations

c.id === currentChatId)} onSelectChat={setCurrentChatId} onDeleteChat={deleteChat} onCreateNewChat={createNewChat} collapsed={sidebarCollapsed} />
{currentChatId ? ( c.id === currentChatId)} profile={activeProfile} summarizationProfile={summarizationProfile} onUpdateChat={(updatedChat) => { setChats(chats.map(c => c.id === updatedChat.id ? updatedChat : c )); }} /> ) : (

Welcome to Thinking Model Client

Start a new conversation or select an existing one.

)}
{showSettings && (
{ setProfiles(newProfiles); // Ensure the active profile still exists, otherwise select the first one if (!newProfiles.some(p => p.id === activeProfileId)) { setActiveProfileId(newProfiles[0]?.id || null); } }} onSaveSummarizationProfile={setSummarizationProfile} summarizationProfile={summarizationProfile} onChangeActiveProfile={setActiveProfileId} onCloseSettings={() => setShowSettings(false)} />
)} {error && (
Error: {error}
)} {loading && (
Loading...
)}
); } export default App;