完善备注面板

This commit is contained in:
xianyi
2025-12-16 18:08:39 +08:00
parent f8a7b41463
commit 1d993e76c5
3 changed files with 35 additions and 9 deletions

View File

@@ -27,6 +27,15 @@ const routeToSection = Object.entries(sectionToRoute).reduce<Record<string, Sect
{},
);
interface LoginInfo {
userId: string;
userName: string;
accessToken: string;
refreshToken: string;
roles: string;
username: string;
}
export const MainLayout = () => {
const [search, setSearch] = useState('');
const [quickAction, setQuickAction] = useState<QuickActionType>('none');
@@ -46,14 +55,15 @@ export const MainLayout = () => {
navigate(sectionToRoute[section]);
};
const handleLoginSuccess = (phone: string) => {
// 实际项目中应该从后端获取用户信息
// 这里暂时使用手机号后4位作为操作员名称
const displayName = phone.slice(-4);
const handleLoginSuccess = (info: LoginInfo) => {
const displayName = info.userName || info.username || '操作员';
setOperatorName(displayName);
// 可以存储到 localStorage 或状态管理中
localStorage.setItem('operatorPhone', phone);
// 存储操作员信息与 token
localStorage.setItem('operatorId', info.userId || '');
localStorage.setItem('operatorName', displayName);
localStorage.setItem('operatorUsername', info.username || '');
localStorage.setItem('accessToken', info.accessToken || '');
localStorage.setItem('refreshToken', info.refreshToken || '');
};
// 初始化时检查是否有已登录的操作员