feat: 个人中心管理(编辑信息 + 修改密码 + 退出登录)

- 新增 /profile 路由:两个 Tab(个人信息 / 修改密码)+ 退出按钮
- Sidebar 底部用户区改造:绑定真实登录用户(头像/姓名/角色)+ 加 Settings icon 跳 /profile
- useAuthStore 加 refreshUser:保存信息后立即同步 Sidebar 显示
- 个人信息表单:姓名/手机/邮箱可改,部门/角色只读,复用 updateMember
- 密码修改:原密 + 新密(≥8位且≠原密) + 确认 三档校验,眼睛 icon 切换可见,下次登录生效
- 退出登录:confirm → useAuthStore.logout → /login

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Script Generator
2026-06-16 19:51:22 +08:00
parent c2f2fed82c
commit 7c49868c4f
4 changed files with 469 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ interface AuthState {
login: (phone: string, password: string, remember: boolean) => boolean;
logout: () => void;
checkAuth: () => void;
refreshUser: () => void;
}
const SESSION_KEY = 'ftb_auth_session';
@@ -88,4 +89,22 @@ export const useAuthStore = create<AuthState>((set) => ({
return;
}
},
refreshUser: () => {
const cur = useAuthStore.getState().user;
if (!cur) return;
try {
const raw = localStorage.getItem('ftb_members_v1');
if (!raw) return;
const parsed = JSON.parse(raw);
const m = parsed.members?.find((x: any) => x.id === cur.id);
if (!m) return;
const next: AuthUser = { id: m.id, name: m.name, roleId: m.roleId, departmentId: m.departmentId, phone: m.phone, email: m.email };
useAuthStore.setState({ user: next });
sessionStorage.setItem(SESSION_KEY, JSON.stringify(next));
if (localStorage.getItem(PERSIST_KEY)) {
localStorage.setItem(PERSIST_KEY, JSON.stringify(next));
}
} catch {}
},
}));