|
|
|
@ -10,13 +10,14 @@ import { isRelogin } from "@/utils/request"; |
|
|
|
NProgress.configure({ showSpinner: false }); |
|
|
|
|
|
|
|
const whiteList = ["/login", "/register"]; |
|
|
|
const HOME_PATH = "/index"; |
|
|
|
|
|
|
|
const isWhiteList = (path) => { |
|
|
|
return whiteList.some((pattern) => isPathMatch(pattern, path)); |
|
|
|
}; |
|
|
|
|
|
|
|
const hasHomeRoute = (routes) => { |
|
|
|
return Array.isArray(routes) && routes.some((route) => route && route.path === "/" && route.redirect === "/index"); |
|
|
|
return Array.isArray(routes) && routes.some((route) => route && route.path === "/" && route.redirect === HOME_PATH); |
|
|
|
}; |
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
@ -26,7 +27,7 @@ router.beforeEach((to, from, next) => { |
|
|
|
store.dispatch("settings/setTitle", to.meta.title); |
|
|
|
} |
|
|
|
if (to.path === "/login") { |
|
|
|
next({ path: "/" }); |
|
|
|
next({ path: HOME_PATH, replace: true }); |
|
|
|
NProgress.done(); |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -44,6 +45,10 @@ router.beforeEach((to, from, next) => { |
|
|
|
next({ path: "/no-permission", replace: true }); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (to.path === "/") { |
|
|
|
next({ path: HOME_PATH, replace: true }); |
|
|
|
return; |
|
|
|
} |
|
|
|
next({ ...to, replace: true }); |
|
|
|
}); |
|
|
|
}).catch((err) => { |
|
|
|
|