Commit f4a8e732 authored by chenqikuai's avatar chenqikuai

feat:添加路由权限控制

parent 2e27d560
import { token } from '@/util/userInfoUtils'
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import App from '../App.vue'
......@@ -36,24 +37,27 @@ const routes: Array<RouteConfig> = [
name: 'Login',
component: () => import("@/view/Auth/Login/index.vue")
},
{
path: '/auth/PwdSetting',
name: 'PwdSetting',
component: () => import("@/view/Auth/PwdSetting/index.vue")
},
{
path: '/auth/PwdFind',
name: 'PwdFind',
component: () => import("@/view/Auth/PwdFind/index.vue")
},
{
path: '/auth/PwdModify',
name: 'PwdModify',
component: () => import("@/view/Auth/PwdModify/index.vue")
},
// {
// path: '/auth/PwdSetting',
// name: 'PwdSetting',
// component: () => import("@/view/Auth/PwdSetting/index.vue")
// },
// {
// path: '/auth/PwdFind',
// name: 'PwdFind',
// component: () => import("@/view/Auth/PwdFind/index.vue")
// },
// {
// path: '/auth/PwdModify',
// name: 'PwdModify',
// component: () => import("@/view/Auth/PwdModify/index.vue")
// },
]
},
{
path: '*',
redirect: { name: 'Home' }
}
]
......@@ -64,4 +68,12 @@ const router = new VueRouter({
routes
})
router.beforeEach((to, from, next) => {
if (to.name !== 'Login' && token.getToken() === null) {
next({ name: 'Login' })
} else {
next()
}
})
export default router
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment