修复默认登录问题

This commit is contained in:
aixianling
2023-01-29 13:58:42 +08:00
parent a56948aa37
commit 76d0a11ffd

View File

@@ -3,7 +3,7 @@ import {getToken} from './tools'
let home = {name: "工作台", path: "/v", component: () => import('../views/home')},
routes = [{name: "登录", path: "/login", component: () => import('../views/login')}]
routes = [{name: "登录", path: "/login", component: () => import('../views/login')}]
const loadApps = () => {
const files = import.meta.glob('../apps/App*.vue'), apps = []
return Promise.all(Object.keys(files).map(path => {
@@ -34,11 +34,11 @@ export default loadApps().then(() => createRouter({
if (to.name == "工作台") {
next()
} else if (getToken()) {
if (to.name == '登录') next({name: "工作台"})
if (/登录/.test(to.name) || to.path == "/") next({name: "工作台"})
else next()
} else if (to.name != '登录') {
next({name: "登录"})
} else next()
})
return router
})
})