import { router } from '@pica-cli/vue-cli-plugin-pica-cli-plugin/auto';
import { toggleSkeletonRouter } from 'mn-template/plugins/toggleSkeleton.js';
import handleAllRouter from '../public_uat';
// 问诊订单管理
const diagnosisList = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/diagnosis-list.vue')),
    'diagnosisList'
  );
const diagnosisIm = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/diagnosis-im.vue')),
    'diagnosisIm'
  );
const diagnosisLive = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/diagnosis-live.vue')),
    'diagnosisLive'
  );
const serviceList = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/service-list.vue')),
    'serviceList'
  );
const assistList = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/assist-list.vue')),
    'assistList'
  );
const diagnosisEditor = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/diagnosis-editor.vue')),
    'diagnosisEditor'
  );
const diagnosisListNew = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/diagnosis-list-new.vue')),
    'diagnosisListNew'
  );
const downList = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/down-list.vue')),
    'downList'
  );
const operation = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/operation.vue')),
    'downList'
  );
const workbench = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/workbench.vue')),
    'workbench'
  );
const administrators = (r) =>
  require.ensure(
    [],
    () => r(require('@/views/IM/diagnosis-admin/administrators.vue')),
    'administrators'
  );
const Layout = (r) =>
  require.ensure([], () => r(require('@/views/layout/Layout.vue')), 'Layout');

const routerConfig = [
  {
    path: '/',
    component: Layout,
    mode: 'history',
    children: [
      {
        path: '',
        redirect: '/diagnosis-list',
      },
      {
        path: '/diagnosis-list',
        component: diagnosisList,
        meta: {
          keepAlive: true, // 需要被缓存
        },
      },
      {
        path: '/diagnosis-im',
        component: diagnosisIm,
      },
      {
        path: '/diagnosis-live',
        component: diagnosisLive,
      },
      {
        path: '/service-List',
        component: serviceList,
      },
      {
        path: '/assist-list',
        component: assistList,
      },
      {
        path: '/diagnosis-editor',
        component: diagnosisEditor,
      },
      {
        path: '/diagnosis-list-new',
        component: diagnosisListNew,
      },
      {
        path: '/down-list',
        component: downList,
      },
      {
        path: '/operation',
        component: operation,
      },
      {
        path: '/workbench',
        component: workbench,
      },
      {
        path: '/administrators',
        component: administrators,
      },
    ],
  },
];
router.beforeEach(async (to, from, next) => {
  toggleSkeletonRouter(to, from);
  next();
});
router.addRoutes(routerConfig);
if (process.env.VUE_APP_ENV == 'uat') {
  const routerInfo = {
    routerConfig: routerConfig,
  };
  handleAllRouter(routerInfo);
}
