nav.js 6.25 KB
Newer Older
WhatAKitty's avatar
WhatAKitty committed
1
import dynamic from 'dva/dynamic';
2

nikogu's avatar
nikogu committed
3
// wrapper of dynamic
nikogu's avatar
nikogu committed
4
const dynamicWrapper = (app, models, component) => dynamic({
nikogu's avatar
nikogu committed
5
  app,
nikogu's avatar
nikogu committed
6
  models: () => models.map(m => import(`../models/${m}.js`)),
7
  component,
nikogu's avatar
nikogu committed
8 9 10 11 12
});

// nav data
export const getNavData = app => [
  {
13
    component: dynamicWrapper(app, ['user', 'login'], () => import('../layouts/BasicLayout')),
nikogu's avatar
nikogu committed
14 15 16 17 18 19 20 21 22 23 24 25
    layout: 'BasicLayout',
    name: '首页', // for breadcrumb
    path: '/',
    children: [
      {
        name: 'Dashboard',
        icon: 'dashboard',
        path: 'dashboard',
        children: [
          {
            name: '分析页',
            path: 'analysis',
26
            component: dynamicWrapper(app, ['chart'], () => import('../routes/Dashboard/Analysis')),
nikogu's avatar
nikogu committed
27 28 29 30
          },
          {
            name: '监控页',
            path: 'monitor',
31
            component: dynamicWrapper(app, ['monitor'], () => import('../routes/Dashboard/Monitor')),
nikogu's avatar
nikogu committed
32 33 34 35
          },
          {
            name: '工作台',
            path: 'workplace',
36
            component: dynamicWrapper(app, ['project', 'activities', 'chart'], () => import('../routes/Dashboard/Workplace')),
nikogu's avatar
nikogu committed
37 38 39 40 41 42 43 44 45 46 47
          },
        ],
      },
      {
        name: '表单页',
        path: 'form',
        icon: 'form',
        children: [
          {
            name: '基础表单',
            path: 'basic-form',
48
            component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/BasicForm')),
nikogu's avatar
nikogu committed
49 50 51 52
          },
          {
            name: '分步表单',
            path: 'step-form',
53
            component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm')),
nikogu's avatar
nikogu committed
54 55 56
            children: [
              {
                path: 'confirm',
57
                component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm/Step2')),
nikogu's avatar
nikogu committed
58 59 60
              },
              {
                path: 'result',
61
                component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm/Step3')),
nikogu's avatar
nikogu committed
62 63 64 65 66 67
              },
            ],
          },
          {
            name: '高级表单',
            path: 'advanced-form',
68
            component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/AdvancedForm')),
nikogu's avatar
nikogu committed
69
          },
WhatAKitty's avatar
WhatAKitty committed
70
        ],
nikogu's avatar
nikogu committed
71 72
      },
      {
nikogu's avatar
nikogu committed
73 74 75 76 77 78 79
        name: '列表页',
        path: 'list',
        icon: 'table',
        children: [
          {
            name: '查询表格',
            path: 'table-list',
80
            component: dynamicWrapper(app, ['rule'], () => import('../routes/List/TableList')),
nikogu's avatar
nikogu committed
81 82 83 84
          },
          {
            name: '标准列表',
            path: 'basic-list',
85
            component: dynamicWrapper(app, ['list'], () => import('../routes/List/BasicList')),
nikogu's avatar
nikogu committed
86 87 88 89
          },
          {
            name: '卡片列表',
            path: 'card-list',
90
            component: dynamicWrapper(app, ['list'], () => import('../routes/List/CardList')),
nikogu's avatar
nikogu committed
91 92
          },
          {
偏右's avatar
偏右 committed
93
            name: '搜索列表',
nikogu's avatar
nikogu committed
94
            path: 'search',
偏右's avatar
偏右 committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108
            component: dynamicWrapper(app, [], () => import('../routes/List/List')),
            children: [{
              name: '搜索列表(项目)',
              path: 'projects',
              component: dynamicWrapper(app, ['list'], () => import('../routes/List/Projects')),
            }, {
              name: '搜索列表(应用)',
              path: 'applications',
              component: dynamicWrapper(app, ['list'], () => import('../routes/List/Applications')),
            }, {
              name: '搜索列表(文章)',
              path: 'articles',
              component: dynamicWrapper(app, ['list'], () => import('../routes/List/Articles')),
            }],
nikogu's avatar
nikogu committed
109 110 111 112 113 114 115 116 117 118 119
          },
        ],
      },
      {
        name: '详情页',
        path: 'profile',
        icon: 'profile',
        children: [
          {
            name: '基础详情页',
            path: 'basic',
120
            component: dynamicWrapper(app, ['profile'], () => import('../routes/Profile/BasicProfile')),
nikogu's avatar
nikogu committed
121 122 123 124
          },
          {
            name: '高级详情页',
            path: 'advanced',
125
            component: dynamicWrapper(app, ['profile'], () => import('../routes/Profile/AdvancedProfile')),
nikogu's avatar
nikogu committed
126 127 128 129 130
          },
        ],
      },
      {
        name: '结果',
afc163's avatar
afc163 committed
131
        path: 'result',
nikogu's avatar
nikogu committed
132 133 134 135 136
        icon: 'check-circle-o',
        children: [
          {
            name: '成功',
            path: 'success',
137
            component: dynamicWrapper(app, [], () => import('../routes/Result/Success')),
nikogu's avatar
nikogu committed
138 139 140 141
          },
          {
            name: '失败',
            path: 'fail',
142
            component: dynamicWrapper(app, [], () => import('../routes/Result/Error')),
nikogu's avatar
nikogu committed
143 144 145 146 147 148 149 150 151 152 153
          },
        ],
      },
      {
        name: '异常',
        path: 'exception',
        icon: 'warning',
        children: [
          {
            name: '403',
            path: '403',
154
            component: dynamicWrapper(app, [], () => import('../routes/Exception/403')),
nikogu's avatar
nikogu committed
155 156 157 158
          },
          {
            name: '404',
            path: '404',
159
            component: dynamicWrapper(app, [], () => import('../routes/Exception/404')),
nikogu's avatar
nikogu committed
160 161 162 163
          },
          {
            name: '500',
            path: '500',
164
            component: dynamicWrapper(app, [], () => import('../routes/Exception/500')),
nikogu's avatar
nikogu committed
165 166 167 168 169 170
          },
        ],
      },
    ],
  },
  {
171
    component: dynamicWrapper(app, [], () => import('../layouts/UserLayout')),
nikogu's avatar
nikogu committed
172 173 174 175 176 177 178 179 180 181 182
    path: '/user',
    layout: 'UserLayout',
    children: [
      {
        name: '帐户',
        icon: 'user',
        path: 'user',
        children: [
          {
            name: '登录',
            path: 'login',
183
            component: dynamicWrapper(app, ['login'], () => import('../routes/User/Login')),
nikogu's avatar
nikogu committed
184 185 186 187
          },
          {
            name: '注册',
            path: 'register',
188
            component: dynamicWrapper(app, ['register'], () => import('../routes/User/Register')),
nikogu's avatar
nikogu committed
189 190 191 192
          },
          {
            name: '注册结果',
            path: 'register-result',
193
            component: dynamicWrapper(app, [], () => import('../routes/User/RegisterResult')),
nikogu's avatar
nikogu committed
194 195 196 197 198 199
          },
        ],
      },
    ],
  },
  {
200
    component: dynamicWrapper(app, [], () => import('../layouts/BlankLayout')),
nikogu's avatar
nikogu committed
201 202 203 204 205 206 207
    layout: 'BlankLayout',
    children: {
      name: '使用文档',
      path: 'http://pro.ant.design/docs/getting-started',
      target: '_blank',
      icon: 'book',
    },
afc163's avatar
afc163 committed
208
  },
nikogu's avatar
nikogu committed
209
];