Blame view

src/router/index.js 8.17 KB
80a28914e   吉鹏   init
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
  import Vue from 'vue'
  import Router from 'vue-router'
  
  Vue.use(Router)
  
  /* Layout */
  import Layout from '@/layout'
  
  /**
   * Note: sub-menu only appear when route children.length >= 1
   * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
   *
   * hidden: true                   if set true, item will not show in the sidebar(default is false)
   * alwaysShow: true               if set true, will always show the root menu
   *                                if not set alwaysShow, when item has more than one children route,
   *                                it will becomes nested mode, otherwise not show the root menu
   * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
   * name:'router-name'             the name is used by <keep-alive> (must set!!!)
   * meta : {
      roles: ['admin','editor']    control the page roles (you can set multiple roles)
      title: 'title'               the name show in sidebar and breadcrumb (recommend set)
      icon: 'svg-name'             the icon show in the sidebar
      breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
      activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
    }
   */
  
  /**
   * constantRoutes
   * a base page that does not have permission requirements
   * all roles can be accessed
   */
1172ebb79   Adam   auto commit the c...
33
  export const constantRoutes = [{
80a28914e   吉鹏   init
34
35
36
37
      path: '/login',
      component: () => import('@/views/login/index'),
      hidden: true
    },
80a28914e   吉鹏   init
38
39
40
41
42
    {
      path: '/404',
      component: () => import('@/views/404'),
      hidden: true
    },
80a28914e   吉鹏   init
43
44
45
46
47
48
49
50
    {
      path: '/',
      component: Layout,
      redirect: '/dashboard',
      children: [{
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
1172ebb79   Adam   auto commit the c...
51
52
53
54
        meta: {
          title: '中控台',
          icon: 'dashboard'
        }
80a28914e   吉鹏   init
55
56
      }]
    },
c44ba96f6   Adam   auto commit the c...
57
    {
feb3d4f57   Adam   auto commit the c...
58
      path: '/user', //用户管理
c44ba96f6   Adam   auto commit the c...
59
60
61
      component: Layout,
      redirect: '/user/list',
      name: 'user',
1172ebb79   Adam   auto commit the c...
62
63
      meta: {
        title: '用户管理',
feb3d4f57   Adam   auto commit the c...
64
        icon: 'people'
1172ebb79   Adam   auto commit the c...
65
66
      },
      children: [{
c44ba96f6   Adam   auto commit the c...
67
68
69
          path: 'user',
          name: 'User',
          component: () => import('@/views/table/index'),
1172ebb79   Adam   auto commit the c...
70
71
          meta: {
            title: '用户列表',
feb3d4f57   Adam   auto commit the c...
72
            icon: 'peoples'
1172ebb79   Adam   auto commit the c...
73
          }
c44ba96f6   Adam   auto commit the c...
74
        }
feb3d4f57   Adam   auto commit the c...
75
76
77
78
79
80
81
82
83
84
        // ,
        // {
        //   path: 'tree',
        //   name: '',
        //   component: () => import('@/views/tree/index'),
        //   meta: {
        //     title: '权限控制',
        //     icon: 'lock'
        //   }
        // }
c44ba96f6   Adam   auto commit the c...
85
86
      ]
    },
80a28914e   吉鹏   init
87
    {
feb3d4f57   Adam   auto commit the c...
88
      path: '/shop',
80a28914e   吉鹏   init
89
      component: Layout,
1172ebb79   Adam   auto commit the c...
90
91
      meta: {
        title: '商家管理',
feb3d4f57   Adam   auto commit the c...
92
        icon: 'shopping'
1172ebb79   Adam   auto commit the c...
93
94
      },
      children: [{
feb3d4f57   Adam   auto commit the c...
95
96
          path: 'shop',
          name: 'Shop',
80a28914e   吉鹏   init
97
          component: () => import('@/views/table/index'),
1172ebb79   Adam   auto commit the c...
98
          meta: {
feb3d4f57   Adam   auto commit the c...
99
            title: '商家列表',
1172ebb79   Adam   auto commit the c...
100
101
            icon: 'table'
          }
80a28914e   吉鹏   init
102
103
104
105
106
        },
        {
          path: 'tree',
          name: 'Tree',
          component: () => import('@/views/tree/index'),
1172ebb79   Adam   auto commit the c...
107
          meta: {
feb3d4f57   Adam   auto commit the c...
108
109
            title: '图片分析',
            icon: 'chart'
1172ebb79   Adam   auto commit the c...
110
          }
80a28914e   吉鹏   init
111
112
113
        }
      ]
    },
80a28914e   吉鹏   init
114
    {
feb3d4f57   Adam   auto commit the c...
115
      path: '/prod',
80a28914e   吉鹏   init
116
      component: Layout,
feb3d4f57   Adam   auto commit the c...
117
118
      redirect: '/prod/table',
      name: 'Prod',
1172ebb79   Adam   auto commit the c...
119
120
      meta: {
        title: '产品管理',
feb3d4f57   Adam   auto commit the c...
121
        icon: 'tree'
1172ebb79   Adam   auto commit the c...
122
123
124
      },
      children: [{
          path: 'table',
feb3d4f57   Adam   auto commit the c...
125
          name: 'Tree',
1172ebb79   Adam   auto commit the c...
126
          meta: {
feb3d4f57   Adam   auto commit the c...
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
            title: '成镜',
            icon: 'tree-table'
          },
          children: [{
            path: 'table',
            name: 'tree',
            component: () => import('@/views/tree/index'),
            meta: {
              title: '款式索引',
              icon: 'tree-table'
            },
            children: [{
              path: 'table',
              name: 'Table1',
              component: () => import('@/views/table/index'),
              meta: {
                title: '青春学子风',
                icon: 'guide'
              }
            },{
              path: 'table',
              name: 'Table1',
              component: () => import('@/views/table/index'),
              meta: {
                title: '质感哥特风',
                icon: 'guide'
              }
            }]
          },{
            path: 'table',
            name: 'tree',
            component: () => import('@/views/table/index'),
            meta: {
              title: '颜色索引',
              icon: 'tree-table'
            }
          }]
1172ebb79   Adam   auto commit the c...
164
        },
80a28914e   吉鹏   init
165
        {
1172ebb79   Adam   auto commit the c...
166
167
          path: 'tree',
          name: 'Tree',
feb3d4f57   Adam   auto commit the c...
168
          component: () => import('@/views/table/index'),
1172ebb79   Adam   auto commit the c...
169
          meta: {
feb3d4f57   Adam   auto commit the c...
170
171
            title: '镜片',
            icon: 'tree-table'
1172ebb79   Adam   auto commit the c...
172
          }
80a28914e   吉鹏   init
173
174
        }
      ]
1172ebb79   Adam   auto commit the c...
175
    },
80a28914e   吉鹏   init
176
    {
feb3d4f57   Adam   auto commit the c...
177
      path: '/Meta',
80a28914e   吉鹏   init
178
      component: Layout,
feb3d4f57   Adam   auto commit the c...
179
180
      redirect: '/meta/table',
      name: 'Meta',
80a28914e   吉鹏   init
181
      meta: {
1172ebb79   Adam   auto commit the c...
182
        title: '元管理',
feb3d4f57   Adam   auto commit the c...
183
        icon: 'guide'
80a28914e   吉鹏   init
184
      },
1172ebb79   Adam   auto commit the c...
185
186
187
188
189
190
191
192
      children: [{
          path: 'table',
          name: 'Table',
          component: () => import('@/views/table/index'),
          meta: {
            title: 'Table',
            icon: 'table'
          }
80a28914e   吉鹏   init
193
194
        },
        {
1172ebb79   Adam   auto commit the c...
195
196
197
198
199
200
201
          path: 'tree',
          name: 'Tree',
          component: () => import('@/views/tree/index'),
          meta: {
            title: 'Tree',
            icon: 'tree'
          }
80a28914e   吉鹏   init
202
203
204
        }
      ]
    },
80a28914e   吉鹏   init
205
    {
feb3d4f57   Adam   auto commit the c...
206
      path: '/trade',
1172ebb79   Adam   auto commit the c...
207
208
      component: Layout,
      redirect: '/example/table',
feb3d4f57   Adam   auto commit the c...
209
      name: 'Trade',
1172ebb79   Adam   auto commit the c...
210
211
      meta: {
        title: '交易管理',
feb3d4f57   Adam   auto commit the c...
212
        icon: 'money'
1172ebb79   Adam   auto commit the c...
213
214
215
216
217
218
      },
      children: [{
          path: 'table',
          name: 'Table',
          component: () => import('@/views/table/index'),
          meta: {
feb3d4f57   Adam   auto commit the c...
219
            title: '成交清单',
1172ebb79   Adam   auto commit the c...
220
221
222
223
224
225
226
227
            icon: 'table'
          }
        },
        {
          path: 'tree',
          name: 'Tree',
          component: () => import('@/views/tree/index'),
          meta: {
feb3d4f57   Adam   auto commit the c...
228
229
            title: '未成交清单',
            icon: 'table'
1172ebb79   Adam   auto commit the c...
230
231
232
233
          }
        }
      ]
    }, {
feb3d4f57   Adam   auto commit the c...
234
      path: '/recommand',
80a28914e   吉鹏   init
235
      component: Layout,
feb3d4f57   Adam   auto commit the c...
236
237
      redirect: '/recommand/table',
      name: 'Recommand',
1172ebb79   Adam   auto commit the c...
238
239
      meta: {
        title: '推荐系统',
feb3d4f57   Adam   auto commit the c...
240
        icon: 'size'
1172ebb79   Adam   auto commit the c...
241
242
      },
      children: [{
feb3d4f57   Adam   auto commit the c...
243
244
245
246
247
248
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: {
          title: '推荐系统教学',
          icon: 'table'
1172ebb79   Adam   auto commit the c...
249
        }
feb3d4f57   Adam   auto commit the c...
250
      }]
1172ebb79   Adam   auto commit the c...
251
252
253
254
255
256
257
    }, {
      path: '/system',
      component: Layout,
      redirect: '/system/table',
      name: 'System',
      meta: {
        title: '系统设置',
feb3d4f57   Adam   auto commit the c...
258
        icon: 'component'
1172ebb79   Adam   auto commit the c...
259
260
      },
      children: [{
feb3d4f57   Adam   auto commit the c...
261
262
          path: 'hangye_seting',
          name: 'Hangye',
1172ebb79   Adam   auto commit the c...
263
264
265
          component: () => import('@/views/table/index'),
          meta: {
            title: '行业设置',
feb3d4f57   Adam   auto commit the c...
266
            icon: 'guide'
1172ebb79   Adam   auto commit the c...
267
268
269
          }
        },
        {
feb3d4f57   Adam   auto commit the c...
270
271
          path: 'language_seting',
          name: 'Language',
1172ebb79   Adam   auto commit the c...
272
273
274
          component: () => import('@/views/tree/index'),
          meta: {
            title: '语言设置',
feb3d4f57   Adam   auto commit the c...
275
            icon: 'language'
1172ebb79   Adam   auto commit the c...
276
277
278
          }
        },
        {
feb3d4f57   Adam   auto commit the c...
279
280
          path: 'money_seting',
          name: 'Money',
1172ebb79   Adam   auto commit the c...
281
282
283
          component: () => import('@/views/tree/index'),
          meta: {
            title: '货币设置',
feb3d4f57   Adam   auto commit the c...
284
            icon: 'money'
1172ebb79   Adam   auto commit the c...
285
286
287
          }
        },
        {
feb3d4f57   Adam   auto commit the c...
288
289
          path: 'site_seting',
          name: 'Site',
1172ebb79   Adam   auto commit the c...
290
291
292
          component: () => import('@/views/tree/index'),
          meta: {
            title: '站点类型设置',
feb3d4f57   Adam   auto commit the c...
293
            icon: 'form'
1172ebb79   Adam   auto commit the c...
294
295
296
          }
        },
        {
feb3d4f57   Adam   auto commit the c...
297
298
          path: 'template_seting',
          name: 'Template',
1172ebb79   Adam   auto commit the c...
299
300
301
          component: () => import('@/views/tree/index'),
          meta: {
            title: '模版设置',
feb3d4f57   Adam   auto commit the c...
302
            icon: 'theme'
1172ebb79   Adam   auto commit the c...
303
304
          }
        },
80a28914e   吉鹏   init
305
        {
feb3d4f57   Adam   auto commit the c...
306
307
          path: 'power_seting',
          name: 'Power',
1172ebb79   Adam   auto commit the c...
308
309
310
          component: () => import('@/views/tree/index'),
          meta: {
            title: '权限设置',
feb3d4f57   Adam   auto commit the c...
311
            icon: 'password'
1172ebb79   Adam   auto commit the c...
312
          }
80a28914e   吉鹏   init
313
314
315
        }
      ]
    },
1172ebb79   Adam   auto commit the c...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
    {
      path: '/form',
      component: Layout,
      children: [{
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: {
          title: 'Form',
          icon: 'form'
        }
      }]
    }
  ]
  
  /**
   * asyncRoutes
   * the routes that need to be dynamically loaded based on user roles
   */
  export const asyncRoutes = [
80a28914e   吉鹏   init
336
    // 404 page must be placed at the end !!!
a795fa7b1   Adam   auto commit the c...
337
338
339
340
    {
      path: '*',
      redirect: '/404'
    }
80a28914e   吉鹏   init
341
342
343
344
  ]
  
  const createRouter = () => new Router({
    // mode: 'history', // require service support
1172ebb79   Adam   auto commit the c...
345
346
347
    scrollBehavior: () => ({
      y: 0
    }),
80a28914e   吉鹏   init
348
349
350
351
352
353
354
355
356
357
358
359
    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