mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-26 00:06:41 +08:00
【v3.8.3】前端小改动汇总集合
This commit is contained in:
@ -1,5 +1,10 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { getMenuListResultModel } from './model/menuModel';
|
||||
import { useUserStoreWithOut } from '@/store/modules/user';
|
||||
import { setAuthCache } from '@/utils/auth';
|
||||
import { TOKEN_KEY } from '@/enums/cacheEnum';
|
||||
import { router } from '@/router';
|
||||
import { PageEnum } from '@/enums/pageEnum';
|
||||
|
||||
enum Api {
|
||||
GetMenuList = '/sys/permission/getUserPermissionByToken',
|
||||
@ -28,7 +33,21 @@ export const getMenuList = () => {
|
||||
* @description: 获取后台菜单权限和按钮权限
|
||||
*/
|
||||
export function getBackMenuAndPerms() {
|
||||
return defHttp.get({ url: Api.GetMenuList });
|
||||
return defHttp.get({ url: Api.GetMenuList }).catch((e) => {
|
||||
// Token过期失效,直接跳转登录页面 2025-09-08 scott
|
||||
if (e && (e.message.includes('timeout') || e.message.includes('401'))) {
|
||||
const userStore = useUserStoreWithOut();
|
||||
userStore.setToken('');
|
||||
setAuthCache(TOKEN_KEY, null);
|
||||
router.push({
|
||||
path: PageEnum.BASE_LOGIN,
|
||||
query: {
|
||||
// 传入当前的路由,登录成功后跳转到当前路由
|
||||
redirect: router.currentRoute.value.fullPath,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -81,13 +81,12 @@ export function phoneLoginApi(params: LoginParams, mode: ErrorMessageMode = 'mod
|
||||
export function getUserInfo() {
|
||||
return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo }, {}).catch((e) => {
|
||||
// update-begin--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面
|
||||
// Token过期失效,直接跳转登录页面
|
||||
if (e && (e.message.includes('timeout') || e.message.includes('401'))) {
|
||||
//接口不通时跳转到登录界面
|
||||
const userStore = useUserStoreWithOut();
|
||||
userStore.setToken('');
|
||||
setAuthCache(TOKEN_KEY, null);
|
||||
|
||||
// update-begin-author:sunjianlei date:20230306 for: 修复登录成功后,没有正确重定向的问题
|
||||
router.push({
|
||||
path: PageEnum.BASE_LOGIN,
|
||||
query: {
|
||||
@ -95,8 +94,6 @@ export function getUserInfo() {
|
||||
redirect: router.currentRoute.value.fullPath,
|
||||
}
|
||||
});
|
||||
// update-end-author:sunjianlei date:20230306 for: 修复登录成功后,没有正确重定向的问题
|
||||
|
||||
}
|
||||
// update-end--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user