index.js
4.1 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import Vue from 'vue'
import Router from 'vue-router'
import Login from './../pages/Login.vue'
import NotFound from './../pages/404.vue'
import Home from './../pages/Home.vue'
import Main from './../pages/Main.vue'
// import Table from './../pages/nav1/Table.vue'
// import Form from './../pages/nav1/Form.vue'
// import user from './../pages/nav1/user.vue'
// import Page4 from './../pages/nav2/Page4.vue'
// import Page5 from './../pages/nav2/Page5.vue'
import Page6 from './../pages/nav3/Page6.vue'
import Dashboard from './../pages/dashboard/Dashboard.vue'
import VideoManager from './../pages/video-manager/VideoManager.vue'
import BannerManager from './../pages/classroom/BannerManager.vue'
import ArticleManager from './../pages/classroom/ArticleManager.vue'
import TagManager from './../pages/classroom/TagManager.vue'
import StoreManager from './../pages/store-manager/StoreManager.vue'
Vue.use(Router)
const router = new Router({
routes: [{
path: '/login',
component: Login,
name: '',
hidden: true
},
{
path: '/404',
component: NotFound,
name: '',
hidden: true
},
//{ path: '/main', component: Main },
{
path: '/',
component: Home,
name: '',
iconCls: 'fa fa-address-card',
leaf: true, //只有一个节点
children: [{
path: '/',
component: Dashboard,
name: 'Dashboard'
}]
},
{
path: '/',
component: Home,
name: '',
iconCls: 'fa fa-address-card',
leaf: true, //只有一个节点
children: [{
path: '/video/manager',
component: VideoManager,
name: '视频管理'
}]
},
{
path: '/',
component: Home,
name: '爸妈学堂',
iconCls: 'fa fa-id-card-o',
children: [{
path: '/tag/manager',
component: TagManager,
name: '话题管理'
},
{
path: '/banner/manager',
component: BannerManager,
name: '头图管理'
},
{
path: '/article/manager',
component: ArticleManager,
name: '文章管理'
}
]
},
{
path: '/',
component: Home,
name: '',
iconCls: 'fa fa-address-card',
leaf: true, //只有一个节点
children: [{
path: '/store/manager',
component: StoreManager,
name: '呵护到家'
}]
},
// {
// path: '/',
// component: Home,
// name: '导航一',
// iconCls: 'el-icon-message', //图标样式class
// children: [{
// path: '/main',
// component: Main,
// name: '主页',
// hidden: true
// },
// {
// path: '/table',
// component: Table,
// name: 'Table'
// },
// {
// path: '/form',
// component: Form,
// name: 'Form'
// },
// {
// path: '/user',
// component: user,
// name: '列表'
// },
// ]
// },
// {
// path: '/',
// component: Home,
// name: '导航二',
// iconCls: 'fa fa-id-card-o',
// children: [{
// path: '/page4',
// component: Page4,
// name: '页面4'
// },
// {
// path: '/page5',
// component: Page5,
// name: '页面5'
// }
// ]
// },
// {
// path: '/',
// component: Home,
// name: '',
// iconCls: 'fa fa-address-card',
// leaf: true, //只有一个节点
// children: [{
// path: '/page6',
// component: Page6,
// name: '导航三'
// }]
// },
{
path: '*',
hidden: true,
redirect: {
path: '/404'
}
}
]
})
router.beforeEach((to, from, next) => {
//NProgress.start();
if (to.path == '/login') {
sessionStorage.removeItem('user');
}
let user = JSON.parse(sessionStorage.getItem('user'));
if (!user && to.path != '/login') {
next({
path: '/login'
})
} else {
next()
}
})
export default router;