config.js 8.44 KB
Newer Older
愚道's avatar
愚道 committed
1 2
/* eslint-disable react/destructuring-assignment */

愚道's avatar
愚道 committed
3
// https://umijs.org/config/
愚道's avatar
愚道 committed
4 5

const path = require('path');
愚道's avatar
愚道 committed
6
// const pageRoutes = require('../_routes');
愚道's avatar
愚道 committed
7

愚道's avatar
愚道 committed
8
export default {
愚道's avatar
愚道 committed
9 10 11
  // add for transfer to umi
  plugins: [
    'umi-plugin-dva',
陈帅's avatar
陈帅 committed
12
    'umi-plugin-locale',
愚道's avatar
愚道 committed
13
    // TODO 决定是否使用约定路由,如果使用配置路由那么 umi-plugin-routes 可以去掉了
愚道's avatar
愚道 committed
14 15 16 17 18 19 20 21 22
    // [
    //   'umi-plugin-routes',
    //   {
    //     exclude: [/\.test\.js/],
    //     update(routes) {
    //       return [...pageRoutes, ...routes];
    //     },
    //   },
    // ],
愚道's avatar
愚道 committed
23
  ],
陈帅's avatar
陈帅 committed
24 25 26 27 28 29
  locale: {
    enable: true, // default false
    default: 'zh-CN', // default zh-CN
    baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
    antd: true, // use antd, default is true
  },
愚道's avatar
愚道 committed
30
  // 路由配置
愚道's avatar
愚道 committed
31
  routes: [
愚道's avatar
愚道 committed
32 33 34 35 36 37 38 39 40 41 42 43
    // user
    {
      path: '/user',
      component: './layouts/UserLayout',
      routes: [
        { path: '/user', redirect: '/user/login' },
        { path: '/user/login', component: '/User/Login' },
        { path: '/user/register', component: './User/Register' },
        { path: '/user/register-result', component: './User/RegisterResult' },
      ],
    },
    // app
愚道's avatar
愚道 committed
44 45
    {
      path: '/',
愚道's avatar
愚道 committed
46
      component: './layouts/LoadingPage',
愚道's avatar
愚道 committed
47 48 49
      routes: [
        // dashboard
        { path: '/', redirect: '/dashboard/analysis' },
50 51 52 53 54 55 56 57 58 59
        {
          path: '/dashboard',
          name: 'dashboard',
          icon: 'dashboard',
          routes: [
            { path: '/dashboard/analysis', name: 'analysis', component: './Dashboard/Analysis' },
            { path: '/dashboard/monitor', name: 'monitor', component: './Dashboard/Monitor' },
            { path: '/dashboard/workplace', name: 'workplace', component: './Dashboard/Workplace' },
          ],
        },
愚道's avatar
愚道 committed
60 61
        // forms
        {
62 63 64
          path: '/form',
          icon: 'form',
          name: 'form',
愚道's avatar
愚道 committed
65
          routes: [
66 67 68
            { path: '/form/basic-form', name: 'basicform', component: './Forms/BasicForm' },
            {
              path: '/form/step-form',
陈帅's avatar
陈帅 committed
69
              name: 'stepform',
70 71 72
              component: './Forms/StepForm',
              hideChildren: true,
              routes: [
陈帅's avatar
陈帅 committed
73
                { path: '/form/step-form', name: 'stepform', redirect: '/form/step-form/info' },
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
                { path: '/form/step-form/info', name: 'info', component: './Forms/StepForm/Step1' },
                {
                  path: '/form/step-form/confirm',
                  name: 'confirm',
                  component: './Forms/StepForm/Step2',
                },
                {
                  path: '/form/step-form/result',
                  name: 'result',
                  component: './Forms/StepForm/Step3',
                },
              ],
            },
            {
              path: '/form/advanced-form',
              name: 'advancedform',
              component: './Forms/AdvancedForm',
            },
愚道's avatar
愚道 committed
92 93 94 95
          ],
        },
        // list
        {
96 97 98
          path: '/list',
          icon: 'table',
          name: 'list',
愚道's avatar
愚道 committed
99
          routes: [
100
            { path: '/list/table-list', name: 'searchtable', component: './List/TableList' },
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
            { path: '/list/basic-list', name: 'basiclist', component: './List/BasicList' },
            { path: '/list/card-list', name: 'cardlist', component: './List/CardList' },
            {
              path: '/list/search',
              name: 'searchlist',
              component: './List/List',
              routes: [
                { path: '/list/search/articles', name: 'articles', component: './List/Articles' },
                { path: '/list/search/projects', name: 'projects', component: './List/Projects' },
                {
                  path: '/list/search/applications',
                  name: 'applications',
                  component: './List/Applications',
                },
              ],
            },
愚道's avatar
愚道 committed
117 118
          ],
        },
愚道's avatar
愚道 committed
119
        {
120 121 122
          path: '/profile',
          name: 'profile',
          icon: 'profile',
愚道's avatar
愚道 committed
123
          routes: [
124 125 126
            // profile
            { path: '/profile/basic', name: 'basic', component: './Profile/BasicProfile' },
            { path: '/profile/advanced', name: 'advanced', component: './Profile/AdvancedProfile' },
愚道's avatar
愚道 committed
127 128 129
          ],
        },
        {
130 131 132
          name: 'result',
          icon: 'check-circle-o',
          path: '/result',
愚道's avatar
愚道 committed
133
          routes: [
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 164 165 166
            // result
            { path: '/result/success', name: 'success', component: './Result/Success' },
            { path: '/result/fail', name: 'fail', component: './Result/Error' },
          ],
        },
        {
          name: 'exception',
          icon: 'warning',
          path: '/exception',
          routes: [
            // exception
            { path: '/exception/403', name: 'not-permission', component: './Exception/403' },
            { path: '/exception/404', name: 'not-find', component: './Exception/404' },
            { path: '/exception/500', name: 'server-error', component: './Exception/500' },
            {
              path: '/exception/trigger',
              name: 'trigger',
              hideInMenu: true,
              component: './Exception/triggerException',
            },
          ],
        },
        {
          name: 'account',
          icon: 'user',
          path: '/account',
          routes: [
            {
              path: '/account/center',
              name: 'center',
              component: './Account/Center/Center',
              routes: [
                { path: '/account/center', redirect: '/account/center/articles' },
陈帅's avatar
陈帅 committed
167 168 169 170
                {
                  path: '/account/center/articles',
                  component: './Account/Center/Articles',
                },
171 172 173 174
                {
                  path: '/account/center/applications',
                  component: './Account/Center/Applications',
                },
陈帅's avatar
陈帅 committed
175 176 177 178
                {
                  path: '/account/center/projects',
                  component: './Account/Center/Projects',
                },
179 180
              ],
            },
愚道's avatar
愚道 committed
181
            {
182 183 184 185 186
              path: '/account/settings',
              name: 'settings',
              component: './Account/Settings/Info',
              routes: [
                { path: '/account/settings', redirect: '/account/settings/base' },
陈帅's avatar
陈帅 committed
187 188 189 190
                {
                  path: '/account/settings/base',
                  component: './Account/Settings/BaseView',
                },
191 192 193 194 195 196 197 198 199 200
                {
                  path: '/account/settings/security',
                  component: './Account/Settings/SecurityView',
                },
                { path: '/account/settings/binding', component: './Account/Settings/BindingView' },
                {
                  path: '/account/settings/notification',
                  component: './Account/Settings/NotificationView',
                },
              ],
愚道's avatar
愚道 committed
201 202 203
            },
          ],
        },
愚道's avatar
愚道 committed
204 205 206
      ],
    },
  ],
愚道's avatar
愚道 committed
207

愚道's avatar
愚道 committed
208 209 210
  theme: {
    'card-actions-background': '#f5f8fa',
  },
愚道's avatar
愚道 committed
211
  // entry: 'src/index.js', // TODO remove
愚道's avatar
愚道 committed
212 213 214 215 216 217 218 219 220 221 222
  extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    },
  },
  externals: {
    '@antv/data-set': 'DataSet',
    rollbar: 'rollbar',
  },
  alias: {
愚道's avatar
愚道 committed
223
    components: path.resolve(__dirname, '../src/components/'),
xiaohu's avatar
xiaohu committed
224 225 226
    utils: path.resolve(__dirname, '../src/utils/'),
    assets: path.resolve(__dirname, '../src/assets/'),
    common: path.resolve(__dirname, '../src/common/'),
愚道's avatar
愚道 committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
  },
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
        context.resourcePath.includes('ant.design.pro.less')
      ) {
        return localName;
      }
      const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
      const arr = antdProPath
        .split('/')
        .map(a => a.replace(/([A-Z])/g, '-$1'))
        .map(a => a.toLowerCase());
      return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
    },
  },
陈帅's avatar
陈帅 committed
249
  disableFastClick: true,
250 251 252 253 254 255 256 257 258 259 260 261 262 263
  manifest: {
    name: 'ant-design-pro',
    background_color: '#FFF',
    description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
    display: 'standalone',
    start_url: '/index.html',
    icons: [
      {
        src: '/favicon.png',
        sizes: '48x48',
        type: 'image/png',
      },
    ],
  },
愚道's avatar
愚道 committed
264
};