fix : 简化模板
This commit is contained in:
@@ -175,36 +175,36 @@ const router = createRouter({
|
||||
],
|
||||
});
|
||||
|
||||
// router.beforeEach(async (to, form, next) => {
|
||||
// const permisstionStore = usePermisstionStroe();
|
||||
// const authStore = useAuthStore();
|
||||
// NProgress.start();
|
||||
// if (!getToken()) {
|
||||
// if (to.path === "/login" || to.path === "/forbidden") {
|
||||
// next();
|
||||
// NProgress.done();
|
||||
// } else {
|
||||
// next({ path: "/login" });
|
||||
// }
|
||||
// } else {
|
||||
// if (to.path === "/login") {
|
||||
// next("/");
|
||||
// NProgress.done();
|
||||
// } else {
|
||||
// permisstionStore.setIsLoadRoutes(true);
|
||||
// if (
|
||||
// permisstionStore.isLoadRoutes &&
|
||||
// permisstionStore.asyncRouters.length == 0
|
||||
// ) {
|
||||
// await permisstionStore.setAsyncRouters();
|
||||
// await authStore.setUserInfo();
|
||||
// next({ ...to, replace: true });
|
||||
// } else {
|
||||
// next();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
router.beforeEach(async (to, form, next) => {
|
||||
const permisstionStore = usePermisstionStroe();
|
||||
const authStore = useAuthStore();
|
||||
NProgress.start();
|
||||
if (!getToken()) {
|
||||
if (to.path === "/login" || to.path === "/forbidden") {
|
||||
next();
|
||||
NProgress.done();
|
||||
} else {
|
||||
next({ path: "/login" });
|
||||
}
|
||||
} else {
|
||||
if (to.path === "/login") {
|
||||
next("/");
|
||||
NProgress.done();
|
||||
} else {
|
||||
permisstionStore.setIsLoadRoutes(true);
|
||||
if (
|
||||
permisstionStore.isLoadRoutes &&
|
||||
permisstionStore.asyncRouters.length == 0
|
||||
) {
|
||||
await permisstionStore.setAsyncRouters();
|
||||
await authStore.setUserInfo();
|
||||
next({ ...to, replace: true });
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done();
|
||||
|
||||
Reference in New Issue
Block a user