feat: ✨ 新增路由守卫

This commit is contained in:
何嘉悦
2025-05-25 18:06:09 +08:00
parent 16b59d6ab2
commit f4d078ca07
52 changed files with 928 additions and 282 deletions
+3 -2
View File
@@ -2,7 +2,7 @@ import type { HookFetchPlugin } from 'hook-fetch';
import { ElMessage } from 'element-plus';
import hookFetch from 'hook-fetch';
import { sseTextDecoderPlugin } from 'hook-fetch/plugins';
import { useUserStore } from '@/store';
import { useUserStore } from '@/stores';
interface BaseResponse {
code: number;
@@ -34,8 +34,9 @@ function jwtPlugin(): HookFetchPlugin<BaseResponse> {
return response;
}
if (response.result?.code === 401) {
// 如果没有权限,也不退出,则是弹框提示登录
// 如果没有权限,退出,且弹框提示登录
userStore.logout();
userStore.openLoginDialog();
}
ElMessage.error(response.result?.msg);
return Promise.reject(response);