2020-06-16 02:20:06 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import VueRouter from 'vue-router'
|
|
|
|
import Login from '../components/Login'
|
2020-06-16 07:20:27 +00:00
|
|
|
import Home from '../components/Home'
|
2020-06-17 03:01:34 +00:00
|
|
|
import welcome from '../components/welcome'
|
2020-06-17 10:04:40 +00:00
|
|
|
import users from '../components/users/users'
|
2020-06-22 03:37:05 +00:00
|
|
|
import access from '../components/access/access'
|
2020-06-22 07:26:09 +00:00
|
|
|
import roles from '../components/access/roles'
|
2020-06-24 06:10:45 +00:00
|
|
|
import categories from '../components/goods/categories'
|
2020-06-28 07:15:20 +00:00
|
|
|
import params from '../components/goods/params'
|
2020-06-29 08:29:51 +00:00
|
|
|
import goods from '../components/goods/goods'
|
|
|
|
import goodsEdit from '../components/goods/edit'
|
2020-06-16 07:20:27 +00:00
|
|
|
|
2020-06-16 02:20:06 +00:00
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
|
|
const routes = [
|
2020-06-17 10:04:40 +00:00
|
|
|
{ path: '/', redirect: '/login' },
|
|
|
|
{ path: '/login', component: Login },
|
2020-06-16 07:20:27 +00:00
|
|
|
{
|
|
|
|
path: '/home',
|
2020-06-17 03:01:34 +00:00
|
|
|
component: Home,
|
|
|
|
redirect: '/welcome',
|
|
|
|
children: [
|
2020-06-17 10:04:40 +00:00
|
|
|
{ path: '/welcome', component: welcome },
|
2020-06-22 03:37:05 +00:00
|
|
|
{ path: '/users', component: users },
|
2020-06-22 07:26:09 +00:00
|
|
|
{ path: '/rights', component: access },
|
2020-06-24 06:10:45 +00:00
|
|
|
{ path: '/roles', component: roles },
|
2020-06-28 07:15:20 +00:00
|
|
|
{ path: '/categories', component: categories },
|
2020-06-29 08:29:51 +00:00
|
|
|
{ path: '/params', component: params },
|
|
|
|
{ path: '/goods', component: goods },
|
|
|
|
{ path: '/goods/add', component: goodsEdit }
|
2020-06-17 03:01:34 +00:00
|
|
|
]
|
2020-06-16 02:20:06 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
|
routes
|
|
|
|
})
|
2020-06-16 07:28:53 +00:00
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
if (to.path === '/login') {
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
const token = sessionStorage.getItem('token')
|
|
|
|
if (!token) {
|
|
|
|
return next('/login')
|
|
|
|
}
|
|
|
|
next()
|
|
|
|
})
|
2020-06-16 02:20:06 +00:00
|
|
|
export default router
|