🖋️切换账号登录时,如没有权限则跳转到/

This commit is contained in:
KaneLeung 2024-09-30 15:34:05 +08:00
parent 4612aa6ad2
commit 50d78fd00b
No known key found for this signature in database
GPG Key ID: 8F0FE0297C3B1256

View File

@ -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('/');
}