import { Link, useLocation } from 'react-router-dom' import { cn } from '../lib/utils' import { Database, TrendingUp, History, Home, ClipboardList, BarChart3, PieChart, } from 'lucide-react' import { useEffect, useState } from 'react' // 导航配置 - 精简版 const navItems = [ { name: '仪表盘', href: '/', icon: Home }, { name: '网格回测', href: '/grid', icon: BarChart3 }, { name: '技术指标', href: '/indicators', icon: TrendingUp }, { name: '交易记录', href: '/trades', icon: ClipboardList }, { name: '回测历史', href: '/history', icon: History }, { name: '数据中心', href: '/data', icon: Database }, { name: '行情列表', href: '/market-lists', icon: PieChart }, ] // 世界时钟 const worldClocks = [ { city: '东京', timezone: 'Asia/Tokyo', flag: '🇯🇵' }, { city: '伦敦', timezone: 'Europe/London', flag: '🇬🇧' }, { city: '纽约', timezone: 'America/New_York', flag: '🇺🇸' }, ] export default function Layout({ children }: { children: React.ReactNode }) { const location = useLocation() const [currentTime, setCurrentTime] = useState(new Date()) const [greeting, setGreeting] = useState('') useEffect(() => { const timer = setInterval(() => { setCurrentTime(new Date()) }, 1000) return () => clearInterval(timer) }, []) useEffect(() => { const hour = currentTime.getHours() if (hour < 12) setGreeting('上午好') else if (hour < 18) setGreeting('下午好') else setGreeting('晚上好') }, [currentTime]) const formatTime = (timezone: string) => { return new Intl.DateTimeFormat('zh-CN', { hour: '2-digit', minute: '2-digit', timeZone: timezone, hour12: false, }).format(currentTime) } const isMarketOpen = (timezone: string) => { const hour = parseInt(formatTime(timezone).split(':')[0]) return hour >= 9 && hour < 15 } const isActive = (href: string) => { if (href === '/') return location.pathname === '/' return location.pathname.startsWith(href) } return (
{/* 顶部导航栏 */}
{/* Logo */}
WG
网格交易 {/* 导航链接 */} {/* 右侧时间 */}
{currentTime.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })}
{/* 欢迎区(仅首页) */} {location.pathname === '/' && (

{greeting},交易员!

{currentTime.toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' })}

{/* 世界时钟 */}
{worldClocks.map((clock) => (
{clock.flag}
{clock.city}
{formatTime(clock.timezone)}
))}
)} {/* 主内容 */}
{children}
{/* 页脚 */}
) }