// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { UMI_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  history: { type: 'hash' },
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  define: {
    'process.env.API_SERVER': 'http://47.92.229.12:8888',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      name: 'page',
      path: '/front',
      component: './Front',
    },
    {
      name: 'detail',
      path: '/home/detail/:id?',
      component: './Front/detail',
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          authority: ['admin', 'user'],
          routes: [
            {
              path: '/',
              redirect: '/article/article-page',
            },
            {
              hideInMenu: true,
              name: 'list.caseUpdate',
              path: 'article/article-page/update/:id?',
              component: './Case/CasePage/update',
            },
            {
              name: 'list.case',
              icon: 'fileSearch',
              path: 'article',
              routes: [
                {
                  name: 'casePage',
                  path: 'article-page',
                  component: './Case/CasePage',
                },
                {
                  name: 'level',
                  path: 'level',
                  component: './Case/level',
                },
                {
                  name: 'category',
                  path: 'category',
                  component: './Case/Category',
                },
              ],
            },
            {
              name: 'list.maintain',
              icon: 'idcard',
              path: 'maintain',
              routes: [
                {
                  name: 'user',
                  path: 'user',
                  component: './MainTain/User',
                },
              ],
            },
            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[UMI_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
});
