init
This commit is contained in:
18
pc/middleware/route.global.ts
Normal file
18
pc/middleware/route.global.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { useAppStore } from '~~/stores/app'
|
||||
import { useUserStore } from '~~/stores/user'
|
||||
import { isEmptyObject } from '~~/utils/validate'
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
const userStore = useUserStore()
|
||||
const appStore = useAppStore()
|
||||
try {
|
||||
if (isEmptyObject(appStore.config)) {
|
||||
await appStore.getConfig()
|
||||
}
|
||||
if (userStore.isLogin && isEmptyObject(userStore.userInfo)) {
|
||||
await userStore.getUser()
|
||||
}
|
||||
} catch (error) {
|
||||
userStore.$reset()
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user