fix: BUG修改

This commit is contained in:
kun 2024-03-11 18:37:43 +08:00
parent 86469738ad
commit 1eba771ad9
2 changed files with 9 additions and 5 deletions

View File

@ -11,7 +11,7 @@ const modules = import.meta.glob("@/views/**/*.vue");
/**
*
*/
export const initDynamicRouter = async (params?: any) => {
export const initDynamicRouter = async (params?: any, defaultUrl?: any) => {
const authStore = AuthStore();
const globalStore = GlobalStore();
try {
@ -44,7 +44,7 @@ export const initDynamicRouter = async (params?: any) => {
}
if (item.meta.isFull) {
router.addRoute(item);
if (globalStore.path) {
if (globalStore.path && !defaultUrl) {
console.log("big");
router.push(globalStore.path);
@ -56,14 +56,18 @@ export const initDynamicRouter = async (params?: any) => {
router.addRoute("layout", item);
if (globalStore.path) {
// console.log("exec");
if (globalStore.path == item.path) {
if (globalStore.path == item.path && !defaultUrl) {
router.push(globalStore.path);
++toNum;
} else {
if (item.path != "/" && toNum < 1) {
if (item.path != "/" && toNum < 1 && !defaultUrl) {
router.push(item.path);
++toNum;
}
if (item.path != "/" && toNum < 1 && defaultUrl) {
router.push(defaultUrl);
++toNum;
}
}
// globalStore.setPath(null);
} else {

View File

@ -48,7 +48,7 @@ const tokenIdentify = async () => {
keepAlive.setKeepAliveName();
await sendMessage({ isSuccess: true }, 2);
globalStore.setPath(data["惠州项目"][0].modulePath);
await initDynamicRouter({ moduleId: data["惠州项目"][0].moduleId });
await initDynamicRouter({ moduleId: data["惠州项目"][0].moduleId }, route.query.routeUrl);
globalStore.moduleId = data["惠州项目"][0].moduleId;
// if (responseData.accountType === 2) {
// await sendMessage({ isSuccess: true }, 2);