Layout.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Link, useLocation } from 'react-router-dom'
  2. const NAV_ITEMS = [
  3. { path: '/', label: '仪表盘' },
  4. { path: '/models', label: '模型' },
  5. { path: '/datasets', label: '数据集' },
  6. { path: '/training', label: '训练' },
  7. { path: '/evaluation', label: '评估' },
  8. { path: '/deployment', label: '部署' },
  9. { path: '/inference', label: '推理' },
  10. ]
  11. export function Layout({ children }: { children: React.ReactNode }) {
  12. const location = useLocation()
  13. return (
  14. <div style={{ display: 'flex', minHeight: '100vh', fontFamily: 'system-ui, sans-serif' }}>
  15. <nav style={{
  16. width: 200, background: '#1a1a2e', color: '#fff', padding: '24px 0',
  17. display: 'flex', flexDirection: 'column', gap: 4,
  18. }}>
  19. <h2 style={{ padding: '0 16px 20px', fontSize: 16, fontWeight: 700, margin: 0 }}>
  20. PEFT Platform
  21. </h2>
  22. {NAV_ITEMS.map((item) => (
  23. <Link
  24. key={item.path}
  25. to={item.path}
  26. style={{
  27. padding: '10px 16px',
  28. textDecoration: 'none',
  29. color: location.pathname === item.path ? '#fff' : '#999',
  30. background: location.pathname === item.path ? '#16213e' : 'transparent',
  31. borderLeft: location.pathname === item.path ? '3px solid #e94560' : '3px solid transparent',
  32. fontSize: 14,
  33. }}
  34. >
  35. {item.label}
  36. </Link>
  37. ))}
  38. </nav>
  39. <main style={{ flex: 1, padding: 24, background: '#f5f5f5' }}>{children}</main>
  40. </div>
  41. )
  42. }