🖋️切换账号登录时,如没有权限则跳转到/
This commit is contained in:
parent
4612aa6ad2
commit
50d78fd00b
@ -84,6 +84,7 @@ import { Local, Session } from '/@/utils/storage';
|
||||
import { formatAxis } from '/@/utils/formatTime';
|
||||
import { NextLoading } from '/@/utils/loading';
|
||||
import { sm2 } from 'sm-crypto-v2';
|
||||
import { useRoutesList } from '/@/stores/routesList';
|
||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
@ -246,10 +247,26 @@ const signInSuccess = (isNoPower: boolean | undefined) => {
|
||||
let currentTimeInfo = currentTime.value;
|
||||
// 登录成功,跳到转首页 如果是复制粘贴的路径,非首页/登录页,那么登录成功后重定向到对应的路径中
|
||||
if (route.query?.redirect) {
|
||||
router.push({
|
||||
path: <string>route.query?.redirect,
|
||||
query: Object.keys(<string>route.query?.params).length > 0 ? JSON.parse(<string>route.query?.params) : '',
|
||||
});
|
||||
const stores = useRoutesList();
|
||||
const { routesList } = storeToRefs(stores);
|
||||
const recursion = (routeList: any[], url: string): boolean | undefined => {
|
||||
if (routeList && routeList.length > 0) {
|
||||
for (let i = 0; i < routeList.length; i++) {
|
||||
if (routeList[i].path === url) return true;
|
||||
if (routeList[i]?.children.length > 0) {
|
||||
let result = recursion(routeList[i]?.children, url);
|
||||
if (result) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let exist = recursion(routesList.value, route.query?.redirect as string);
|
||||
if (exist) {
|
||||
router.push({
|
||||
path: <string>route.query?.redirect,
|
||||
query: Object.keys(<string>route.query?.params).length > 0 ? JSON.parse(<string>route.query?.params) : '',
|
||||
});
|
||||
} else router.push('/');
|
||||
} else {
|
||||
router.push('/');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user