1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router);
// 登录
const login = r => require.ensure([], () => r(require('@/components/end/login')), 'login');
// 首页
import { statisticsRoute } from './statistics'
import { systemRoute } from './system'
import { accoutsRoute } from './accout'
import { STBoxRoute } from './STBox'
import { learnRoute } from './learn'
const router = new Router({
routes: [
{
path: '/',
redirect: '/login'
},
{
path: '/login',
name: '登录',
component: login,
meta: {
noShowbar: true,
isNotRequireLogin: true,
}
},
{
path: '/index',
name: '首页',
component: () => import('@/page/index/index'),
meta: {
showBreadcrumb: false
}
},
...statisticsRoute,
...systemRoute,
...accoutsRoute,
...STBoxRoute,
...learnRoute
]
})
router.beforeEach((to, from, next) => {
if (!to.meta.isNotRequireLogin) {
let backToken = localStorage.getItem("backToken");
if (backToken) {
next()
} else {
next({
path: '/',
query: { redirect: to.fullPath },
})
}
} else {
next();
}
})
export default router