Skip to content
Snippets Groups Projects
index.js 9.4 KiB
Newer Older
  • Learn to ignore specific revisions
  • Pan's avatar
    Pan committed
    import Vue from 'vue'
    import Router from 'vue-router'
    const _import = require('./_import_' + process.env.NODE_ENV)
    
    Pan's avatar
    Pan committed
    // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
    // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
    Vue.use(Router)
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
    /* Layout */
    
    Pan's avatar
    Pan committed
    import Layout from '../views/layout/Layout'
    
    Pan's avatar
    Pan committed
    
    
    花裤衩's avatar
    花裤衩 committed
    /** note: submenu only apppear when children.length>=1
    *   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
    **/
    
    
    Pan's avatar
    Pan committed
    /**
    
    Pan's avatar
    Pan committed
    * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
    
    Pan's avatar
    Pan committed
    * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
    *                                if not set alwaysShow, only more than one route under the children
    *                                it will becomes nested mode, otherwise not show the root menu
    
    Pan's avatar
    Pan committed
    * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
    * name:'router-name'             the name is used by <keep-alive> (must set!!!)
    
    * meta : {
    
    Pan's avatar
    Pan committed
        roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    
    Pan's avatar
    Pan committed
        title: 'title'               the name show in submenu and breadcrumb (recommend set)
        icon: 'svg-name'             the icon show in the sidebar,
    
    Pan's avatar
    Pan committed
        noCache: true                if true ,the page will no be cached(default is false)
    
    Pan's avatar
    Pan committed
    **/
    
    Pan's avatar
    Pan committed
    export const constantRouterMap = [
    
    Pan's avatar
    Pan committed
      { path: '/login', component: _import('login/index'), hidden: true },
      { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
      { path: '/404', component: _import('errorPage/404'), hidden: true },
      { path: '/401', component: _import('errorPage/401'), hidden: true },
    
    Pan's avatar
    Pan committed
      {
    
    Pan's avatar
    Pan committed
        path: '',
    
    Pan's avatar
    Pan committed
        component: Layout,
    
    Pan's avatar
    Pan committed
        redirect: 'dashboard',
    
    Pan's avatar
    Pan committed
        children: [{
          path: 'dashboard',
          component: _import('dashboard/index'),
          name: 'dashboard',
    
    Pan's avatar
    Pan committed
          meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
    
    Pan's avatar
    Pan committed
        }]
    
    Pan's avatar
    Pan committed
      },
      {
    
    Pan's avatar
    Pan committed
        path: '/documentation',
    
    Pan's avatar
    Pan committed
        component: Layout,
    
    Pan's avatar
    Pan committed
        redirect: '/documentation/index',
    
    Pan's avatar
    Pan committed
        children: [{
          path: 'index',
    
    Pan's avatar
    Pan committed
          component: _import('documentation/index'),
          name: 'documentation',
          meta: { title: 'documentation', icon: 'documentation', noCache: true }
    
    Pan's avatar
    Pan committed
        }]
    
    Pan's avatar
    Pan committed
      }
    ]
    
    export default new Router({
    
    Pan's avatar
    Pan committed
      // mode: 'history', // require service support
    
    Pan's avatar
    Pan committed
      scrollBehavior: () => ({ y: 0 }),
      routes: constantRouterMap
    
    Pan's avatar
    Pan committed
    })
    
    Pan's avatar
    Pan committed
    
    export const asyncRouterMap = [
      {
        path: '/permission',
        component: Layout,
        redirect: '/permission/index',
    
    Pan's avatar
    Pan committed
        meta: { roles: ['admin'] }, // you can set roles in root nav
    
    Pan's avatar
    Pan committed
        children: [{
          path: 'index',
          component: _import('permission/index'),
          name: 'permission',
          meta: {
    
    Pan's avatar
    Pan committed
            title: 'permission',
    
    Pan's avatar
    Pan committed
            icon: 'lock',
    
    Pan's avatar
    Pan committed
            roles: ['admin'] // or you can only set roles in sub nav
    
    Pan's avatar
    Pan committed
          }
        }]
    
    Pan's avatar
    Pan committed
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/icon',
        component: Layout,
    
    Pan's avatar
    Pan committed
        children: [{
          path: 'index',
          component: _import('svg-icons/index'),
          name: 'icons',
    
    Pan's avatar
    Pan committed
          meta: { title: 'icons', icon: 'icon', noCache: true }
    
    Pan's avatar
    Pan committed
        }]
    
    Pan's avatar
    Pan committed
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/components',
        component: Layout,
    
    Pan's avatar
    Pan committed
        redirect: 'noredirect',
    
        name: 'component-demo',
    
    Pan's avatar
    Pan committed
        meta: {
    
    Pan's avatar
    Pan committed
          title: 'components',
    
    Pan's avatar
    Pan committed
          icon: 'component'
        },
    
    Pan's avatar
    Pan committed
        children: [
    
          { path: 'tinymce', component: _import('components-demo/tinymce'), name: 'tinymce-demo', meta: { title: 'tinymce' }},
          { path: 'markdown', component: _import('components-demo/markdown'), name: 'markdown-demo', meta: { title: 'markdown' }},
          { path: 'json-editor', component: _import('components-demo/jsonEditor'), name: 'jsonEditor-demo', meta: { title: 'jsonEditor' }},
          { path: 'dnd-list', component: _import('components-demo/dndList'), name: 'dndList-demo', meta: { title: 'dndList' }},
          { path: 'splitpane', component: _import('components-demo/splitpane'), name: 'splitpane-demo', meta: { title: 'splitPane' }},
          { path: 'avatar-upload', component: _import('components-demo/avatarUpload'), name: 'avatarUpload-demo', meta: { title: 'avatarUpload' }},
          { path: 'dropzone', component: _import('components-demo/dropzone'), name: 'dropzone-demo', meta: { title: 'dropzone' }},
          { path: 'sticky', component: _import('components-demo/sticky'), name: 'sticky-demo', meta: { title: 'sticky' }},
          { path: 'count-to', component: _import('components-demo/countTo'), name: 'countTo-demo', meta: { title: 'countTo' }},
          { path: 'mixin', component: _import('components-demo/mixin'), name: 'componentMixin-demo', meta: { title: 'componentMixin' }},
    
          { path: 'back-to-top', component: _import('components-demo/backToTop'), name: 'backToTop-demo', meta: { title: 'backToTop' }},
          { path: 'drag-dialog', component: _import('components-demo/dragDialog'), name: 'dragDialog-demo', meta: { title: 'dragDialog' }}
    
    Pan's avatar
    Pan committed
        ]
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/charts',
        component: Layout,
    
    Pan's avatar
    Pan committed
        redirect: 'noredirect',
    
    Pan's avatar
    Pan committed
        name: 'charts',
        meta: {
    
    Pan's avatar
    Pan committed
          title: 'charts',
    
    Pan's avatar
    Pan committed
          icon: 'chart'
        },
    
    Pan's avatar
    Pan committed
        children: [
    
    Pan's avatar
    Pan committed
          { path: 'keyboard', component: _import('charts/keyboard'), name: 'keyboardChart', meta: { title: 'keyboardChart', noCache: true }},
          { path: 'line', component: _import('charts/line'), name: 'lineChart', meta: { title: 'lineChart', noCache: true }},
          { path: 'mixchart', component: _import('charts/mixChart'), name: 'mixChart', meta: { title: 'mixChart', noCache: true }}
    
    Pan's avatar
    Pan committed
        ]
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/example',
        component: Layout,
    
    Pan's avatar
    Pan committed
        redirect: '/example/table/complex-table',
    
    Pan's avatar
    Pan committed
        name: 'example',
        meta: {
    
    Pan's avatar
    Pan committed
          title: 'example',
    
    Pan's avatar
    Pan committed
          icon: 'example'
        },
    
    Pan's avatar
    Pan committed
        children: [
          {
            path: '/example/table',
            component: _import('example/table/index'),
    
    Pan's avatar
    Pan committed
            redirect: '/example/table/complex-table',
    
    Pan's avatar
    Pan committed
            name: 'Table',
    
    Pan's avatar
    Pan committed
            meta: {
              title: 'Table',
              icon: 'table'
            },
    
    Pan's avatar
    Pan committed
            children: [
    
    Pan's avatar
    Pan committed
              { path: 'dynamic-table', component: _import('example/table/dynamicTable/index'), name: 'dynamicTable', meta: { title: 'dynamicTable' }},
              { path: 'drag-table', component: _import('example/table/dragTable'), name: 'dragTable', meta: { title: 'dragTable' }},
              { path: 'inline-edit-table', component: _import('example/table/inlineEditTable'), name: 'inlineEditTable', meta: { title: 'inlineEditTable' }},
    
              { path: 'tree-table', component: _import('example/table/treeTable/treeTable'), name: 'treeTableDemo', meta: { title: 'treeTable' }},
              { path: 'custom-tree-table', component: _import('example/table/treeTable/customTreeTable'), name: 'customTreeTableDemo', meta: { title: 'customTreeTable' }},
    
    Pan's avatar
    Pan committed
              { path: 'complex-table', component: _import('example/table/complexTable'), name: 'complexTable', meta: { title: 'complexTable' }}
    
    Pan's avatar
    Pan committed
            ]
          },
    
    Pan's avatar
    Pan committed
          { path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'tab', meta: { title: 'tab' }}
    
        ]
      },
    
      {
        path: '/form',
        component: Layout,
        redirect: 'noredirect',
        name: 'form',
        meta: {
    
    Pan's avatar
    Pan committed
          title: 'form',
    
          icon: 'form'
        },
        children: [
    
    Pan's avatar
    Pan committed
          { path: 'create-form', component: _import('form/create'), name: 'createForm', meta: { title: 'createForm', icon: 'table' }},
          { path: 'edit-form', component: _import('form/edit'), name: 'editForm', meta: { title: 'editForm', icon: 'table' }}
    
    Pan's avatar
    Pan committed
        ]
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
    
    Pan's avatar
    Pan committed
        path: '/error',
    
    Pan's avatar
    Pan committed
        component: Layout,
        redirect: 'noredirect',
    
    Pan's avatar
    Pan committed
        name: 'errorPages',
        meta: {
    
    Pan's avatar
    Pan committed
          title: 'errorPages',
    
    Pan's avatar
    Pan committed
          icon: '404'
        },
    
    Pan's avatar
    Pan committed
        children: [
    
    Pan's avatar
    Pan committed
          { path: '401', component: _import('errorPage/401'), name: 'page401', meta: { title: 'page401', noCache: true }},
          { path: '404', component: _import('errorPage/404'), name: 'page404', meta: { title: 'page404', noCache: true }}
    
    Pan's avatar
    Pan committed
        ]
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
    
    Pan's avatar
    Pan committed
        path: '/error-log',
    
    Pan's avatar
    Pan committed
        component: Layout,
        redirect: 'noredirect',
    
    Pan's avatar
    Pan committed
        children: [{ path: 'log', component: _import('errorLog/index'), name: 'errorLog', meta: { title: 'errorLog', icon: 'bug' }}]
    
    Pan's avatar
    Pan committed
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/excel',
        component: Layout,
    
    Pan's avatar
    Pan committed
        redirect: '/excel/export-excel',
    
    Pan's avatar
    Pan committed
        name: 'excel',
    
    Pan's avatar
    Pan committed
        meta: {
          title: 'excel',
          icon: 'excel'
        },
    
        children: [
    
    Pan's avatar
    Pan committed
          { path: 'export-excel', component: _import('excel/exportExcel'), name: 'exportExcel', meta: { title: 'exportExcel' }},
          { path: 'export-selected-excel', component: _import('excel/selectExcel'), name: 'selectExcel', meta: { title: 'selectExcel' }},
          { path: 'upload-excel', component: _import('excel/uploadExcel'), name: 'uploadExcel', meta: { title: 'uploadExcel' }}
    
    Pan's avatar
    Pan committed
      },
    
    Pan's avatar
    Pan committed
    
    
    spiritree's avatar
    spiritree committed
      {
        path: '/zip',
        component: Layout,
        redirect: '/zip/download',
    
    Pan's avatar
    Pan committed
        alwaysShow: true,
        meta: { title: 'zip', icon: 'zip' },
        children: [{ path: 'download', component: _import('zip/index'), name: 'exportZip', meta: { title: 'exportZip' }}]
    
    spiritree's avatar
    spiritree committed
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/theme',
        component: Layout,
        redirect: 'noredirect',
    
    Pan's avatar
    Pan committed
        children: [{ path: 'index', component: _import('theme/index'), name: 'theme', meta: { title: 'theme', icon: 'theme' }}]
    
    Pan's avatar
    Pan committed
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      {
        path: '/clipboard',
        component: Layout,
        redirect: 'noredirect',
    
    Pan's avatar
    Pan committed
        children: [{ path: 'index', component: _import('clipboard/index'), name: 'clipboardDemo', meta: { title: 'clipboardDemo', icon: 'clipboard' }}]
      },
    
      {
        path: '/i18n',
        component: Layout,
    
    Pan's avatar
    Pan committed
        children: [{ path: 'index', component: _import('i18n-demo/index'), name: 'i18n', meta: { title: 'i18n', icon: 'international' }}]
    
    Pan's avatar
    Pan committed
      },
    
    Pan's avatar
    Pan committed
    
    
    Pan's avatar
    Pan committed
      { path: '*', redirect: '/404', hidden: true }
    
    Pan's avatar
    Pan committed
    ]