// https://umijs.org/config/
import { defineConfig } from 'umi';
import { join } from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  history: {
    type: 'hash'
  },
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    // https://umijs.org/zh-CN/plugins/plugin-layout
    locale: true,
    siderWidth: 208,
    ...defaultSettings,
  },
  // https://umijs.org/zh-CN/plugins/plugin-locale
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@ant-design/pro-layout/es/PageLoading',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      layout: false,
      routes: [
        {
          path: '/user/login',
          layout: false,
          name: 'login',
          component: './user/Login',
        },
        {
          path: '/user',
          redirect: '/user/login',
        },
        {
          name: 'register-result',
          icon: 'smile',
          path: '/user/register-result',
          component: './user/register-result',
        },
        {
          name: 'register',
          icon: 'smile',
          path: '/user/register',
          component: './user/register',
        },
        {
          component: '404',
        },
      ],
    },
    {
      path: '/dashboard',
      name: '生涯课程中心',
      icon: 'home',
      component: './dashboard/analysis',
    },
    {
      path: '/course',
      icon: 'table',
      name: '课程管理',
      routes: [
        {
          path: '/course',
          redirect: '/course/subject',
        },
        {
          name: '主题设置',
          icon: 'smile',
          path: '/course/subject',
          component: './course/subject',
        },
        {
          name: '新建主题',
          icon: 'smile',
          path: '/course/subject/step/update/',
          component: './course/subject/step',
          hideInMenu: true,
        },
        {
          name: '编辑主题',
          icon: 'smile',
          path: '/course/subject/step/update/:id',
          component: './course/subject/step',
          hideInMenu: true,
        },
        {
          name: '新建主题',
          icon: 'smile',
          path: '/course/subject/step/create',
          component: './course/subject/step',
          hideInMenu: true,
        },
        {
          name: '课程设置',
          icon: 'smile',
          path: '/course/option',
          component: './course/option',
        },
      ],
    },
    {
      path: '/training',
      icon: 'table',
      name: '培训管理',
      component: './training/option',
    },

    {
      path: '/questionbank',
      icon: 'table',
      name: '题库维护',
      routes: [
        {
          path: '/questionbank',
          redirect: '/questionbank/normal',
        },
        {
          name: '常规题库维护',
          icon: 'smile',
          path: '/questionbank/normal',
          component: './questionbank',
        },
        {
          name: '资质考试题库维护',
          icon: 'smile',
          path: '/questionbank/attestation',
          component: './questionbank',
        },
      ],
    },
    {
      path: '/examinationrules',
      icon: 'table',
      name: '考试规则维护',
      routes: [
        {
          path: '/examinationrules',
          redirect: '/examinationrules/normal',
        },
        {
          name: '模拟考试规则设置',
          icon: 'smile',
          path: '/examinationrules/normal',
          component: './examinationrules/normal',
        },
        {
          //name: '创建模拟考试规则',
          //icon: 'smile',
          path: '/examinationrules/normal/step',
          component: './examinationrules/normal/step',
          hideInMenu: true,
        },
        {
          name: '编辑模拟考试规则',
          icon: 'smile',
          path: '/examinationrules/normal/step/:id',
          component: './examinationrules/normal/step',
          hideInMenu: true,
        },
        {
          name: '资质考试规则设置',
          icon: 'smile',
          path: '/examinationrules/attestation',
          component: './examinationrules/attestation',
        },
        {
          //name: '新建资质考试规则',
          //icon: 'smile',
          path: '/examinationrules/attestation/step',
          component: './examinationrules/attestation/step',
          hideInMenu: true,
        },
        {
          name: '修改资质考试规则维护',
          icon: 'smile',
          path: '/examinationrules/attestation/step/:id',
          component: './examinationrules/attestation/step',
          hideInMenu: true,
        },
      ],
    },
    {
      path: '/examination',
      name: '考试管理',
      icon: 'profile',
      routes: [
        {
          path: '/examination',
          redirect: '/examination/option',
        },
        {
          name: '考试维护',
          path: '/examination/option',
          component: './examination/option',
        },
        {
          name: '报名管理',
          icon: 'smile',
          path: '/examination/option/registration/:id/:type',
          component: './examination/registration',
          hideInMenu: true,
        },
        {
          name: '制证管理',
          icon: 'smile',
          path: '/examination/certificate',
          component: './examination/certificate',
        },
        {
          name: '制证名单',
          icon: 'smile',
          hideInMenu: true,
          path: '/examination/certificate/person/:id/:accreditation_status/:name',
          component: './examination/certificate/person',
        },
      ],
    },
    {
      icon: 'table',
      name: '生涯考试历史统计',
      path: '/history/analysis',
      component: './history/analysis',
    },
    {
      path: '/demo',
      icon: 'table',
      name: 'demo',
      component: './demo',
      hideInMenu: true,
    },
    {
      name: 'exception',
      icon: 'warning',
      path: '/exception',
      hideInMenu: true,
      routes: [
        {
          path: '/exception',
          redirect: '/exception/403',
        },
        {
          name: '403',
          icon: 'smile',
          path: '/exception/403',
          component: './exception/403',
        },
        {
          name: '404',
          icon: 'smile',
          path: '/exception/404',
          component: './exception/404',
        },
        {
          name: '500',
          icon: 'smile',
          path: '/exception/500',
          component: './exception/500',
        },
      ],
    },
    {
      name: '账号信息',
      icon: 'user',
      path: '/account',
      hideInMenu: true,
      routes: [
        {
          path: '/account',
          redirect: '/account/center',
        },
        {
          name: '个人中心',
          icon: 'smile',
          path: '/account/center',
          component: './account/center',
        },
        {
          name: '个人设置',
          icon: 'smile',
          path: '/account/settings',
          component: './account/settings',
        },
      ],
    },
    {
      path: '/',
      redirect: '/dashboard',
    },
    {
      component: '404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
    'primary-color-hover': defaultSettings.primaryColor,
  },
  // esbuild is father build tools
  // https://umijs.org/plugins/plugin-esbuild
  esbuild: {},
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  base: '/',
  publicPath: './', // 发布路径采用相对地址
  manifest: {
    basePath: './',
  },
  // Fast Refresh 热更新
  fastRefresh: {},
  openAPI: [
    {
      requestLibPath: "import { request } from 'umi'",
      // 或者使用在线的版本
      // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
      schemaPath: join(__dirname, 'oneapi.json'),
      mock: false,
    },
    {
      requestLibPath: "import { request } from 'umi'",
      schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
      projectName: 'swagger',
    },
  ],
  nodeModulesTransform: {
    type: 'none',
  },
  mfsu: {},
  webpack5: {},
  exportStatic: {},
});
