修复了token错误无法退出的bug

修复了字段查询为空的bug
This commit is contained in:
piexlmax
2022-01-07 19:09:41 +08:00
parent 727caf3f4f
commit 3a74c9483e
3 changed files with 16 additions and 13 deletions

View File

@@ -7,9 +7,8 @@ let asyncRouterFlag = 0
const whiteList = ['Login', 'Init']
const getRouter = async() => {
const getRouter = async(userStore) => {
const routerStore = useRouterStore()
const userStore = useUserStore()
await routerStore.SetAsyncRouter()
await userStore.GetUserInfo()
const asyncRouters = routerStore.asyncRouters
@@ -45,7 +44,7 @@ router.beforeEach(async(to, from, next) => {
if (token) {
if (!asyncRouterFlag && whiteList.indexOf(from.name) < 0) {
asyncRouterFlag++
await getRouter()
await getRouter(userStore)
}
next({ name: userStore.userInfo.authority.defaultRouter })
} else {
@@ -57,7 +56,7 @@ router.beforeEach(async(to, from, next) => {
// 添加flag防止多次获取动态路由和栈溢出
if (!asyncRouterFlag && whiteList.indexOf(from.name) < 0) {
asyncRouterFlag++
await getRouter()
await getRouter(userStore)
next({ ...to, replace: true })
} else {
if (to.matched.length) {