fixed router bug

This commit is contained in:
ray_wuhao 2023-02-01 16:54:48 +08:00
parent 94ae564008
commit 60fc4685a5
2 changed files with 15 additions and 3 deletions

View File

@ -42,8 +42,20 @@ export const permissionRouter = (router: Router) => {
const { role } = storeToRefs(useSignin())
const { meta } = to
const hasRole = () => {
if (meta.role) {
if (meta.role.length === 0) {
return true
} else {
return meta.role.includes(role.value)
}
} else {
return true
}
}
if (token !== 'no') {
if (meta?.role?.includes(role.value)) {
if (hasRole()) {
if (to.path === '/' || from.path === '/login') {
if (route !== 'no') {
next(route)

View File

@ -41,14 +41,14 @@ const Signin = defineComponent({
if (signin(signinForm.value) === 0) {
setTimeout(() => {
router.push('/dashboard')
useSpin(false)
window.$message.success(`欢迎${signinForm.value.name}登陆~`)
setCache('token', 'tokenValue')
setCache('person', signinForm.value)
router.push('/dashboard')
}, 2 * 1000)
}
} else {