// 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',
        },
      ],
    },
    {
      name: '首页',
      icon: 'dashboard',
      path: '/dashboard/workplace',
      component: './dashboard/workplace',
    },
    {
      name: '考试首页',
      icon: 'dashboard',
      path: '/dashboard/qualification/:examination_id',
      component: './dashboard/qualification',
      hideInMenu: true,
    },
    {
      name: '资质考试答题',
      icon: 'dashboard',
      path: '/dashboard/qualification/examAnswer/:examination_id/:rule_id/:examination_name/:time',
      component: './dashboard/qualification/examAnswer',
      hideInMenu: true,
    },
    {
      name: '资质考试結果頁面',
      icon: 'dashboard',
      path: '/dashboard/qualification/result/:pass_score/:score/:sum_score/:examination_id/:examination_name/:time',
      component: './dashboard/qualification/result',
      hideInMenu: true,
    },
    {
      name: '考试报名',
      icon: 'dashboard',
      hideInMenu: true,
      path: '/registration',
      routes: [
        {
          name: '报名',
          icon: 'smile',
          path: '/registration/:examination_id',
          component: './registration',
        },
        {
          name: '成功',
          icon: 'smile',
          path: '/registration/success/:msg',
          component: './registration/success',
          hideInMenu: true,
        },
      ]
    },
    {
      name: '课程学习',
      icon: 'table',
      path: '/course',
      routes: [
        {
          path: '/course',
          redirect: '/course/subject',
        },
        {
          name: '课程学习',
          icon: 'smile',
          path: '/course/subject',
          component: './course/subject',
        },
        {
          name: '课程列表',
          icon: 'smile',
          path: '/course/list/:msg',
          component: './course/list',
          hideInMenu: true,
        },
        {
          name: '课节列表',
          icon: 'smile',
          path: '/course/detail/:msg',
          component: './course/detail',
          hideInMenu: true,
        },
      ],
    },
    {
      name: '模拟考试',
      icon: 'dashboard',
      path: '/mockExamination',
      routes: [
        {
          icon: 'dashboard',
          path: '/mockExamination',
          redirect: '/mockExamination/chapterExamination',
        },
        {
          name: '章节模拟考试',
          path: '/mockExamination/chapterExamination',
          component: './mockExamination/chapterExamination',

        },
        {
          name: '章节模拟考试',
          path: '/mockExamination/chapterExamination/chapterList/:data_id/:data_type/:subject_id',
          component: './mockExamination/chapterList',
          hideInMenu: true,
        },
        {
          name: '章节模拟练习-开始考试',
          path: '/mockExamination/chapterExamination/chapterList/chapterListPaper/:info',
          component: './mockExamination/chapterListPaper',
          hideInMenu: true,
        },
        {
          name: '章节模拟练习-错题本',
          path: '/mockExamination/chapterExamination/chapterList/chapterErrorListPaper/:info',
          component: './mockExamination/chapterErrorListPaper',
          hideInMenu: true,
        },
        {
          name: '综合模拟考试',
          icon: 'smile',
          path: '/mockExamination/index',
          component: './mockExamination/index',
        },
        {
          name: '综合模拟考试答题',
          icon: 'smile',
          path: '/mockExamination/index/paper/:rules_id/:rules_time',
          component: './mockExamination/paper',
          hideInMenu: true,
        },
        {
          name: '综合模拟考试结果',
          icon: 'smile',
          path: '/mockExamination/index/success/:time/:pass_score/:score/:sum_score/:rules_name',
          component: './mockExamination/paper/success',
          hideInMenu: true,
        },
      ]
    },
    // {
    //   path: '/examination',
    //   icon: 'table',
    //   name: '资质考试',
    //   routes: [
    //     {
    //       name: '考试概况(暂时废弃)',
    //       icon: 'smile',
    //       path: '/examination/intro',
    //       component: './examination/intro',
    //       hideInMenu: true,
    //     },
    //     {
    //       name: '考试信息',
    //       icon: 'smile',
    //       path: '/examination/info/:examination_id',
    //       component: './examination/info',
    //       hideInMenu: true,
    //     },
    //     {
    //       name: '考试试卷',
    //       icon: 'smile',
    //       path: '/examination/paper',
    //       component: './examination/paper',
    //     },
    //   ],
    // },
    {
      name: '个人中心',
      icon: 'dashboard',
      path: '/personalCenter',
      component: './personalCenter/index',
    },
    {
      name: 'analysis',
      icon: 'dashboard',
      path: '/dashboard/analysis',
      component: './dashboard/analysis',
      hideInMenu: true,
    },
    {
      path: '/profile',
      name: 'profile',
      icon: 'profile',
      hideInMenu: true,
      routes: [
        {
          path: '/profile',
          redirect: '/profile/basic',
        },
        {
          name: 'basic',
          icon: 'smile',
          path: '/profile/basic',
          component: './profile/basic',
        },
        {
          name: 'advanced',
          icon: 'smile',
          path: '/profile/advanced',
          component: './profile/advanced',
        },
      ],
    },
    {
      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: 'account',
      icon: 'user',
      path: '/account',
      hideInMenu: true,
      routes: [
        {
          path: '/account',
          redirect: '/personalCenter',
        },
        {
          name: 'center',
          icon: 'smile',
          path: '/account/center',
          component: './personalCenter/index',
        },
        {
          name: 'settings',
          icon: 'smile',
          path: '/account/settings',
          component: './account/settings',
        },
      ],
    },
    {
      path: '/',
      redirect: '/dashboard/workplace',
    },
    {
      component: '404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': 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: {},
  nodeModulesTransform: {
    type: 'none',
  },
  mfsu: {},
  webpack5: {},
  exportStatic: {},
});
