import { useEffect, useState } from 'react'; import { api } from '../../services/api-client'; import { useAuthStore } from '../../stores/auth.store'; export function ProfilePage() { const user = useAuthStore((s) => s.user); const updateProfile = useAuthStore((s) => s.updateProfile); const [form, setForm] = useState({ name: '', department: '', title: '', introduction: '', phone: '', }); useEffect(() => { if (user) setForm({ name: user.name || '', department: user.department || '', title: user.title || '', introduction: user.introduction || '', phone: user.phone || '', }); }, [user]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); try { await api.put('/api/auth/me', { name: form.name, department: form.department, title: form.title, introduction: form.introduction, }); updateProfile(form); alert('保存成功'); } catch { alert('保存失败'); } }; if (!user) return null; return (