生产管理系统 - 拦截器业务逻辑增强

This commit is contained in:
2025-11-01 09:32:26 +08:00
parent a1b3335664
commit e99567e6b3
6 changed files with 185 additions and 56 deletions

View File

@@ -65,6 +65,11 @@ export function AuthProvider({ children }: AuthProviderProps) {
localStorage.removeItem('user');
removeTokenCookie(); // 清除 cookie
setLoading(false);
// 跳转到登录页
if (typeof window !== 'undefined') {
window.location.href = '/login';
}
};
// 验证当前用户信息
@@ -89,9 +94,9 @@ export function AuthProvider({ children }: AuthProviderProps) {
// 更新用户信息(可能包含最新的权限、角色等)
setUser({
...userData,
...response.data.data, // 合并最新的用户信息
...response.data, // 合并最新的用户信息
});
console.log('✅ 用户验证成功,最新用户信息:', response.data.data);
console.log('✅ 用户验证成功,最新用户信息:', response.data);
} else {
// Token无效清除用户信息
console.warn('⚠️ Token验证失败清除用户信息');