Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | import { useState } from 'react'; import { useSecurityStore } from '../../store/securityStore'; import { Settings as SettingsIcon, BarChart3, Puzzle, MessageSquare, FolderOpen, Shield, Info, ArrowLeft, Coins, Cpu, Zap, HelpCircle, ClipboardList, Clock, Heart, Key, Database, } from 'lucide-react'; import { silentErrorHandler } from '../../lib/error-utils'; import { General } from './General'; import { UsageStats } from './UsageStats'; import { ModelsAPI } from './ModelsAPI'; import { MCPServices } from './MCPServices'; import { Skills } from './Skills'; import { IMChannels } from './IMChannels'; import { Workspace } from './Workspace'; import { Privacy } from './Privacy'; import { About } from './About'; import { Credits } from './Credits'; import { AuditLogsPanel } from '../AuditLogsPanel'; import { SecurityStatus } from '../SecurityStatus'; import { SecurityLayersPanel } from '../SecurityLayersPanel'; import { TaskList } from '../TaskList'; import { HeartbeatConfig } from '../HeartbeatConfig'; import { SecureStorage } from './SecureStorage'; import { VikingPanel } from '../VikingPanel'; interface SettingsLayoutProps { onBack: () => void; } type SettingsPage = | 'general' | 'usage' | 'credits' | 'models' | 'mcp' | 'skills' | 'im' | 'workspace' | 'privacy' | 'security' | 'storage' | 'viking' | 'audit' | 'tasks' | 'heartbeat' | 'feedback' | 'about'; const menuItems: { id: SettingsPage; label: string; icon: React.ReactNode }[] = [ { id: 'general', label: '通用', icon: <SettingsIcon className="w-4 h-4" /> }, { id: 'usage', label: '用量统计', icon: <BarChart3 className="w-4 h-4" /> }, { id: 'credits', label: '积分详情', icon: <Coins className="w-4 h-4" /> }, { id: 'models', label: '模型与 API', icon: <Cpu className="w-4 h-4" /> }, { id: 'mcp', label: 'MCP 服务', icon: <Puzzle className="w-4 h-4" /> }, { id: 'skills', label: '技能', icon: <Zap className="w-4 h-4" /> }, { id: 'im', label: 'IM 频道', icon: <MessageSquare className="w-4 h-4" /> }, { id: 'workspace', label: '工作区', icon: <FolderOpen className="w-4 h-4" /> }, { id: 'privacy', label: '数据与隐私', icon: <Shield className="w-4 h-4" /> }, { id: 'storage', label: '安全存储', icon: <Key className="w-4 h-4" /> }, { id: 'viking', label: '语义记忆', icon: <Database className="w-4 h-4" /> }, { id: 'security', label: '安全状态', icon: <Shield className="w-4 h-4" /> }, { id: 'audit', label: '审计日志', icon: <ClipboardList className="w-4 h-4" /> }, { id: 'tasks', label: '定时任务', icon: <Clock className="w-4 h-4" /> }, { id: 'heartbeat', label: '心跳配置', icon: <Heart className="w-4 h-4" /> }, { id: 'feedback', label: '提交反馈', icon: <HelpCircle className="w-4 h-4" /> }, { id: 'about', label: '关于', icon: <Info className="w-4 h-4" /> }, ]; export function SettingsLayout({ onBack }: SettingsLayoutProps) { const [activePage, setActivePage] = useState<SettingsPage>('general'); const securityStatus = useSecurityStore((s) => s.securityStatus); const renderPage = () => { switch (activePage) { case 'general': return <General />; case 'usage': return <UsageStats />; case 'credits': return <Credits />; case 'models': return <ModelsAPI />; case 'mcp': return <MCPServices />; case 'skills': return <Skills />; case 'im': return <IMChannels />; case 'workspace': return <Workspace />; case 'privacy': return <Privacy />; case 'storage': return <SecureStorage />; case 'security': return ( <div className="space-y-6"> <div> <h1 className="text-xl font-bold text-gray-900 mb-4">安全状态</h1> <SecurityStatus /> </div> <div> <h2 className="text-lg font-semibold text-gray-900 mb-4">安全架构详情</h2> <SecurityLayersPanel status={securityStatus || { layers: [], enabledCount: 0, totalCount: 16, securityLevel: 'low', }} /> </div> </div> ); case 'audit': return <AuditLogsPanel />; case 'tasks': return ( <div className="max-w-3xl"> <h1 className="text-xl font-bold text-gray-900 mb-6">定时任务</h1> <div className="bg-white rounded-xl border border-gray-200 p-6 shadow-sm"> <TaskList /> </div> </div> ); case 'heartbeat': return ( <div className="max-w-3xl h-full"> <HeartbeatConfig /> </div> ); case 'viking': return <VikingPanel />; case 'feedback': return <Feedback />; case 'about': return <About />; default: return <General />; } }; return ( <div className="h-screen flex bg-f9fafb overflow-hidden text-gray-800 text-sm"> {/* Left navigation */} <aside className="w-64 bg-gray-50 border-r border-gray-200 flex flex-col flex-shrink-0"> {/* 返回按钮 */} <div className="p-4 border-b border-gray-200"> <button onClick={onBack} className="flex items-center gap-2 text-gray-500 hover:text-gray-700 transition-colors" > <ArrowLeft className="w-4 h-4" /> <span>返回应用</span> </button> </div> {/* 导航菜单 */} <nav className="flex-1 overflow-y-auto custom-scrollbar py-2 px-3 space-y-1"> {menuItems.map((item) => ( <button key={item.id} onClick={() => setActivePage(item.id)} className={`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-all ${ activePage === item.id ? 'bg-gray-200 text-gray-900 font-medium' : 'text-gray-500 hover:bg-black/5 hover:text-gray-700' }`} > {item.icon} <span>{item.label}</span> </button> ))} </nav> </aside> {/* Main content */} <main className="flex-1 overflow-y-auto custom-scrollbar bg-white p-8"> {renderPage()} </main> </div> ); } // Simple feedback page (inline) function Feedback() { const [text, setText] = useState(''); const [copied, setCopied] = useState(false); const handleCopy = async () => { await navigator.clipboard.writeText(text.trim()); setCopied(true); }; return ( <div className="max-w-3xl"> <h1 className="text-xl font-bold text-gray-900 mb-6">提交反馈</h1> <div className="bg-white rounded-xl border border-gray-200 p-6 shadow-sm"> <p className="text-sm text-gray-500 mb-4">当前版本尚未接入在线反馈通道。你可以先复制下面的反馈内容,再连同截图和日志一起发给开发者。</p> <textarea value={text} onChange={(e) => { setText(e.target.value); if (copied) { setCopied(false); } }} placeholder="请尽量详细描述复现步骤、期望结果和实际结果" className="w-full h-40 border border-gray-300 rounded-lg p-3 text-sm resize-none focus:outline-none focus:border-orange-400" /> <button onClick={() => { handleCopy().catch(silentErrorHandler('SettingsLayout')); }} disabled={!text.trim()} className="mt-4 px-6 py-2 bg-orange-500 text-white text-sm rounded-lg hover:bg-orange-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" > {copied ? '已复制' : '复制反馈内容'} </button> </div> </div> ); } |