Newer
Older
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
/* Layout */
import Layout from '@/layout'
/* Router Modules */
import componentsRouter from './modules/components'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
export const constantRoutes = [
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path*',
}
]
},
{
path: '/login',
component: () => import('@/views/login/index'),
hidden: true
},
{
path: '/auth-redirect',
hidden: true
},
{
path: '/401',
// component: () => import('@/views/error-page/401'),
hidden: true
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
}
]
},
{
path: '/guide',
component: Layout,
redirect: '/guide/index',
children: [
{
}
]
},
{
path: '/profile',
component: Layout,
redirect: '/profile/index',
hidden: true,
children: [
{
name: 'Profile',
meta: { title: 'profile', icon: 'user', noCache: true }
}
]
}
]
/**
* asyncRoutes
* the routes that need to be dynamically loaded based on user roles
*/
export const asyncRoutes = [
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
// {
// path: '/permission',
// component: Layout,
// redirect: '/permission/page',
// alwaysShow: true, // will always show the root menu
// name: 'Permission',
// meta: {
// title: 'permission',
// icon: 'lock',
// roles: ['admin', 'editor'] // you can set roles in root nav
// },
// children: [
// {
// path: 'page',
// component: () => import('@/views/permission/page'),
// name: 'PagePermission',
// meta: {
// title: 'pagePermission',
// roles: ['admin'] // or you can only set roles in sub nav
// }
// },
// {
// path: 'directive',
// component: () => import('@/views/permission/directive'),
// name: 'DirectivePermission',
// meta: {
// title: 'directivePermission'
// // if do not set roles, means: this page does not require permission
// }
// },
// {
// path: 'role',
// component: () => import('@/views/permission/role'),
// name: 'RolePermission',
// meta: {
// title: 'rolePermission',
// roles: ['admin']
// }
// }
// ]
// },
{
path: '/icon',
component: Layout,
children: [
{
}
]
},
/** when your routing map is too long, you can split it into small modules **/
componentsRouter,
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
182
183
184
185
186
187
188
189
190
191
nestedRouter,
tableRouter,
// {
// path: '/example',
// component: Layout,
// redirect: '/example/list',
// name: 'Example',
// meta: {
// title: 'example',
// icon: 'example'
// },
// children: [
// {
// path: 'create',
// component: () => import('@/views/example/create'),
// name: 'CreateArticle',
// meta: { title: 'createArticle', icon: 'edit' }
// },
// {
// path: 'edit/:id(\\d+)',
// component: () => import('@/views/example/edit'),
// name: 'EditArticle',
// meta: { title: 'editArticle', noCache: true, activeMenu: '/example/list' },
// hidden: true
// },
// {
// path: 'list',
// component: () => import('@/views/example/list'),
// name: 'ArticleList',
// meta: { title: 'articleList', icon: 'list' }
// }
// ]
// },
{
path: '/tab',
component: Layout,
children: [
{
name: 'Tab',
meta: { title: 'tab', icon: 'tab' }
}
]
},
{
path: '/error',
component: Layout,
redirect: 'noRedirect',
name: 'ErrorPages',
meta: {
title: 'errorPages',
icon: '404'
},
children: [
{
path: '401',
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// {
// path: '/error-log',
// component: Layout,
// children: [
// {
// path: 'log',
// component: () => import('@/views/error-log/index'),
// name: 'ErrorLog',
// meta: { title: 'errorLog', icon: 'bug' }
// }
// ]
// },
// {
// path: '/excel',
// component: Layout,
// redirect: '/excel/export-excel',
// name: 'Excel',
// meta: {
// title: 'excel',
// icon: 'excel'
// },
// children: [
// {
// path: 'export-excel',
// component: () => import('@/views/excel/export-excel'),
// name: 'ExportExcel',
// meta: {title: 'exportExcel'}
// },
// {
// path: 'export-selected-excel',
// component: () => import('@/views/excel/select-excel'),
// name: 'SelectExcel',
// meta: {title: 'selectExcel'}
// },
// {
// path: 'export-merge-header',
// component: () => import('@/views/excel/merge-header'),
// name: 'MergeHeader',
// meta: {title: 'mergeHeader'}
// },
// {
// path: 'upload-excel',
// component: () => import('@/views/excel/upload-excel'),
// name: 'UploadExcel',
// meta: {title: 'uploadExcel'}
// }
// ]
// },
// {
// path: '/zip',
// component: Layout,
// redirect: '/zip/download',
// alwaysShow: true,
// name: 'Zip',
// meta: { title: 'zip', icon: 'zip' },
// children: [
// {
// path: 'download',
// component: () => import('@/views/zip/index'),
// name: 'ExportZip',
// meta: { title: 'exportZip' }
// }
// ]
// },
// {
// path: '/pdf',
// component: Layout,
// redirect: '/pdf/index',
// children: [
// {
// path: 'index',
// component: () => import('@/views/pdf/index'),
// name: 'PDF',
// meta: { title: 'pdf', icon: 'pdf' }
// }
// ]
// },
// {
// path: '/pdf/download',
// component: () => import('@/views/pdf/download'),
// hidden: true
// },
path: '/pdf-view',
component: () => import('@/views/file/pdf-view'),
name: 'pdf-view',
meta: { title: 'PDF预览' }
path: '/file-upload',
component: () => import('@/views/file/file-upload'),
name: 'file-upload',
meta: { title: '文件上传' }
path: '/file-download',
component: () => import('@/views/file/file-download'),
name: 'file-download',
meta: { title: '文件下载' }
}
]
},
{
path: '/theme',
component: Layout,
children: [
{
// {
// path: '/clipboard',
// component: Layout,
// children: [
// {
// path: 'index',
// component: () => import('@/views/clipboard/index'),
// name: 'ClipboardDemo',
// meta: { title: 'clipboardDemo', icon: 'clipboard' }
// }
// ]
// },
// {
// path: '/i18n',
// component: Layout,
// children: [
// {
// path: 'index',
// component: () => import('@/views/i18n-demo/index'),
// name: 'I18n',
// meta: { title: 'i18n', icon: 'international' }
// }
// ]
// },
// {
// path: 'external-link',
// component: Layout,
// children: [
// {
// path: 'https://github.com/PanJiaChen/vue-element-admin',
// meta: { title: 'externalLink', icon: 'link' }
// }
// ]
// },
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]
const createRouter = () => new Router({
// mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router