Skip to content

Commit 69fc52d

Browse files
committed
refine router.js
1 parent d78b498 commit 69fc52d

File tree

1 file changed

+65
-122
lines changed

1 file changed

+65
-122
lines changed

src/router/index.js

Lines changed: 65 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,38 @@ import Router from 'vue-router';
33
const _import = require('./_import_' + process.env.NODE_ENV);
44
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading
55

6-
/* layout */
7-
import Layout from '../views/layout/Layout';
8-
9-
/* login */
10-
const Login = _import('login/index');
11-
const authRedirect = _import('login/authredirect');
12-
13-
/* dashboard */
14-
const dashboard = _import('dashboard/index');
15-
16-
/* Introduction */
17-
const Introduction = _import('introduction/index');
18-
19-
/* components */
20-
const componentsIndex = _import('components/index');
21-
const Tinymce = _import('components/tinymce');
22-
const Markdown = _import('components/markdown');
23-
const JsonEditor = _import('components/jsoneditor');
24-
const DndList = _import('components/dndlist');
25-
const AvatarUpload = _import('components/avatarUpload');
26-
const Dropzone = _import('components/dropzone');
27-
const Sticky = _import('components/sticky');
28-
const SplitPane = _import('components/splitpane');
29-
const CountTo = _import('components/countTo');
30-
const Mixin = _import('components/mixin');
31-
const BackToTop = _import('components/backToTop')
32-
33-
/* charts */
34-
const chartIndex = _import('charts/index');
35-
const KeyboardChart = _import('charts/keyboard');
36-
const KeyboardChart2 = _import('charts/keyboard2');
37-
const LineMarker = _import('charts/line');
38-
const MixChart = _import('charts/mixChart');
39-
40-
/* error page */
41-
const Err404 = _import('error/404');
42-
const Err401 = _import('error/401');
43-
44-
/* error log */
45-
const ErrorLog = _import('errlog/index');
46-
47-
/* excel */
48-
const ExcelDownload = _import('excel/index');
49-
const SelectExcelDownload = _import('excel/selectExcel');
50-
51-
/* theme */
52-
const Theme = _import('theme/index');
53-
54-
/* example */
55-
const TableLayout = _import('example/table/index');
56-
const DynamicTable = _import('example/table/dynamictable');
57-
const Table = _import('example/table/table');
58-
const DragTable = _import('example/table/dragTable');
59-
const InlineEditTable = _import('example/table/inlineEditTable');
60-
61-
const Form = _import('example/form');
62-
const Tab = _import('example/tab/index');
63-
64-
/* permission */
65-
const Permission = _import('permission/index');
66-
676
Vue.use(Router);
687

69-
/**
70-
* icon : the icon show in the sidebar
71-
* hidden : if hidden:true will not show in the sidebar
72-
* redirect : if redirect:noredirect will not redirct in the levelbar
73-
* noDropdown : if noDropdown:true will not has submenu
74-
* meta : { role: ['admin'] } will control the page role
75-
**/
8+
/* layout */
9+
import Layout from '../views/layout/Layout';
7610

11+
/**
12+
* icon : the icon show in the sidebar
13+
* hidden : if `hidden:true` will not show in the sidebar
14+
* redirect : if `redirect:noredirect` will no redirct in the levelbar
15+
* noDropdown : if `noDropdown:true` will has no submenu
16+
* meta : { role: ['admin'] } will control the page role
17+
**/
7718
export const constantRouterMap = [
78-
{ path: '/login', component: Login, hidden: true },
79-
{ path: '/authredirect', component: authRedirect, hidden: true },
80-
{ path: '/404', component: Err404, hidden: true },
81-
{ path: '/401', component: Err401, hidden: true },
19+
{ path: '/login', component: _import('login/index'), hidden: true },
20+
{ path: '/authredirect', component: _import('login/authredirect'), hidden: true },
21+
{ path: '/404', component: _import('error/404'), hidden: true },
22+
{ path: '/401', component: _import('error/401'), hidden: true },
8223
{
8324
path: '/',
8425
component: Layout,
8526
redirect: '/dashboard',
8627
name: '首页',
8728
hidden: true,
88-
children: [{ path: 'dashboard', component: dashboard }]
29+
children: [{ path: 'dashboard', component: _import('dashboard/index') }]
8930
},
9031
{
9132
path: '/introduction',
9233
component: Layout,
9334
redirect: '/introduction/index',
9435
icon: 'xinrenzhinan',
9536
noDropdown: true,
96-
children: [{ path: 'index', component: Introduction, name: '简述' }]
37+
children: [{ path: 'index', component: _import('introduction/index'), name: '简述' }]
9738
}
9839
]
9940

@@ -112,7 +53,7 @@ export const asyncRouterMap = [
11253
icon: 'quanxian',
11354
meta: { role: ['admin'] },
11455
noDropdown: true,
115-
children: [{ path: 'index', component: Permission, name: '权限测试页', meta: { role: ['admin'] } }]
56+
children: [{ path: 'index', component: _import('permission/index'), name: '权限测试页', meta: { role: ['admin'] } }]
11657
},
11758
{
11859
path: '/components',
@@ -121,18 +62,18 @@ export const asyncRouterMap = [
12162
name: '组件',
12263
icon: 'zujian',
12364
children: [
124-
{ path: 'index', component: componentsIndex, name: '介绍 ' },
125-
{ path: 'tinymce', component: Tinymce, name: '富文本编辑器' },
126-
{ path: 'markdown', component: Markdown, name: 'Markdown' },
127-
{ path: 'jsoneditor', component: JsonEditor, name: 'JSON编辑器' },
128-
{ path: 'dndlist', component: DndList, name: '列表拖拽' },
129-
{ path: 'splitpane', component: SplitPane, name: 'SplitPane' },
130-
{ path: 'avatarupload', component: AvatarUpload, name: '头像上传' },
131-
{ path: 'dropzone', component: Dropzone, name: 'Dropzone' },
132-
{ path: 'sticky', component: Sticky, name: 'Sticky' },
133-
{ path: 'countto', component: CountTo, name: 'CountTo' },
134-
{ path: 'mixin', component: Mixin, name: '小组件' },
135-
{ path: 'backtotop', component: BackToTop, name: '返回顶部' }
65+
{ path: 'index', component: _import('components/index'), name: '介绍 ' },
66+
{ path: 'tinymce', component: _import('components/tinymce'), name: '富文本编辑器' },
67+
{ path: 'markdown', component: _import('components/markdown'), name: 'Markdown' },
68+
{ path: 'jsoneditor', component: _import('components/jsoneditor'), name: 'JSON编辑器' },
69+
{ path: 'dndlist', component: _import('components/dndlist'), name: '列表拖拽' },
70+
{ path: 'splitpane', component: _import('components/splitpane'), name: 'SplitPane' },
71+
{ path: 'avatarupload', component: _import('components/avatarUpload'), name: '头像上传' },
72+
{ path: 'dropzone', component: _import('components/dropzone'), name: 'Dropzone' },
73+
{ path: 'sticky', component: _import('components/sticky'), name: 'Sticky' },
74+
{ path: 'countto', component: _import('components/countTo'), name: 'CountTo' },
75+
{ path: 'mixin', component: _import('components/mixin'), name: '小组件' },
76+
{ path: 'backtotop', component: _import('components/backToTop'), name: '返回顶部' }
13677
]
13778
},
13879
{
@@ -142,11 +83,37 @@ export const asyncRouterMap = [
14283
name: '图表',
14384
icon: 'tubiaoleixingzhengchang',
14485
children: [
145-
{ path: 'index', component: chartIndex, name: '介绍' },
146-
{ path: 'keyboard', component: KeyboardChart, name: '键盘图表' },
147-
{ path: 'keyboard2', component: KeyboardChart2, name: '键盘图表2' },
148-
{ path: 'line', component: LineMarker, name: '折线图' },
149-
{ path: 'mixchart', component: MixChart, name: '混合图表' }
86+
{ path: 'index', component: _import('charts/index'), name: '介绍' },
87+
{ path: 'keyboard', component: _import('charts/keyboard'), name: '键盘图表' },
88+
{ path: 'keyboard2', component: _import('charts/keyboard2'), name: '键盘图表2' },
89+
{ path: 'line', component: _import('charts/line'), name: '折线图' },
90+
{ path: 'mixchart', component: _import('charts/mixChart'), name: '混合图表' }
91+
]
92+
},
93+
{
94+
path: '/example',
95+
component: Layout,
96+
redirect: 'noredirect',
97+
name: '综合实例',
98+
icon: 'zonghe',
99+
children: [
100+
{
101+
path: '/example/table',
102+
component: _import('example/table/index'),
103+
redirect: '/example/table/table',
104+
name: 'Table',
105+
icon: 'table',
106+
children: [
107+
{ path: 'dynamictable', component: _import('example/table/dynamictable'), name: '动态table' },
108+
{ path: 'dragtable', component: _import('example/table/dragTable'), name: '拖拽table' },
109+
{ path: 'inline_edit_table', component: _import('example/table/inlineEditTable'), name: 'table内编辑' },
110+
{ path: 'table', component: _import('example/table/table'), name: '综合table' }
111+
]
112+
},
113+
{ path: 'form/edit', icon: 'ziliaoshouce', component: _import('example/form'), name: '编辑Form', meta: { isEdit: true } },
114+
{ path: 'form/create', icon: 'yinhangqia', component: _import('example/form'), name: '创建Form' },
115+
116+
{ path: 'tab/index', icon: 'mobankuangjia', component: _import('example/tab/index'), name: 'Tab' }
150117
]
151118
},
152119
{
@@ -156,8 +123,8 @@ export const asyncRouterMap = [
156123
name: '错误页面',
157124
icon: '404',
158125
children: [
159-
{ path: '401', component: Err401, name: '401' },
160-
{ path: '404', component: Err404, name: '404' }
126+
{ path: '401', component: _import('error/401'), name: '401' },
127+
{ path: '404', component: _import('error/404'), name: '404' }
161128
]
162129
},
163130
{
@@ -167,7 +134,7 @@ export const asyncRouterMap = [
167134
name: 'errlog',
168135
icon: 'bug',
169136
noDropdown: true,
170-
children: [{ path: 'log', component: ErrorLog, name: '错误日志' }]
137+
children: [{ path: 'log', component: _import('errlog/index'), name: '错误日志' }]
171138
},
172139
{
173140
path: '/excel',
@@ -176,8 +143,8 @@ export const asyncRouterMap = [
176143
name: 'excel',
177144
icon: 'EXCEL',
178145
children: [
179-
{ path: 'download', component: ExcelDownload, name: '导出excel' },
180-
{ path: 'download2', component: SelectExcelDownload, name: '选择导出excel' }
146+
{ path: 'download', component: _import('excel/index'), name: '导出excel' },
147+
{ path: 'download2', component: _import('excel/selectExcel'), name: '选择导出excel' }
181148
]
182149
},
183150
{
@@ -187,32 +154,8 @@ export const asyncRouterMap = [
187154
name: 'theme',
188155
icon: 'theme',
189156
noDropdown: true,
190-
children: [{ path: 'index', component: Theme, name: '换肤' }]
157+
children: [{ path: 'index', component: _import('theme/index'), name: '换肤' }]
191158
},
192-
{
193-
path: '/example',
194-
component: Layout,
195-
redirect: 'noredirect',
196-
name: '综合实例',
197-
icon: 'zonghe',
198-
children: [
199-
{
200-
path: '/example/table',
201-
component: TableLayout,
202-
redirect: '/example/table/table',
203-
name: 'Table',
204-
children: [
205-
{ path: 'dynamictable', component: DynamicTable, name: '动态table' },
206-
{ path: 'dragtable', component: DragTable, name: '拖拽table' },
207-
{ path: 'inline_edit_table', component: InlineEditTable, name: 'table内编辑' },
208-
{ path: 'table', component: Table, name: '综合table' }
209-
]
210-
},
211-
{ path: 'form/edit', component: Form, name: '编辑Form', meta: { isEdit: true } },
212-
{ path: 'form/create', component: Form, name: '创建Form' },
213159

214-
{ path: 'tab/index', component: Tab, name: 'Tab' }
215-
]
216-
},
217160
{ path: '*', redirect: '/404', hidden: true }
218161
];

0 commit comments

Comments
 (0)