import React, { useState } from 'react'; import { RefreshCw, User, LogOut, CheckCircle2 } from 'lucide-react'; import { useAuth } from '../context/AuthContext'; import { syncAPI } from '../api'; export const Navbar = ({ activeTab, setActiveTab, onOpenAuthModal }) => { const { user, logout } = useAuth(); const [syncing, setSyncing] = useState(false); const [syncToast, setSyncToast] = useState(false); // Format current date matching iOS app format const currentDateFormatted = (() => { const d = new Date(); const year = d.getFullYear(); const month = d.getMonth() + 1; const date = d.getDate(); const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; const weekDay = weekDays[d.getDay()]; return `${year}年${month}月${date}日 ${weekDay}`; })(); const handleSyncNow = async () => { if (!user) { if (onOpenAuthModal) onOpenAuthModal(); return; } setSyncing(true); try { await syncAPI.triggerManualSync(); setSyncToast(true); setTimeout(() => setSyncToast(false), 3000); } catch (e) { console.warn("Manual sync failed:", e); } finally { setSyncing(false); } }; return (
{/* Left Title Section matching iOS TopBar screenshot */}
setActiveTab('dashboard')} >

星痕 现场 记录

{currentDateFormatted}

{/* Center Status Indicator & Sync Actions */}
{/* iOS Ready Status Badge matching screenshot */}
就绪
{syncToast && (
已同步至云端
)}
{/* Right Controls: User Card / Auth button */}
{user ? (
Avatar
{user.username}
{user.phoneNumber || user.email || `ID: ${String(user.id || '').substring(0, 6)}`}
) : ( )}
); };