import { createApp } from 'vue';
import { HpsfirManageBaseUI, HpsfirManageBaseUIApp, HpsfirComponentsMap, HpsfirManageBaseOption } from 'hpsfir-managebase-ui';
import 'hpsfir-managebase-ui/lib/lib.css';
import './style/global.scss';
import { initApi } from './hooks/useApi';

const allComponents: HpsfirComponentsMap = {};
const viewRequireCnt = require.context('./views', true, /index\.vue$/u);
viewRequireCnt.keys().forEach((key) => {
  const keySplits = key.split('/');
  const dirname = keySplits[keySplits.length - 2];
  console.log(dirname);
  allComponents[dirname!] = () => viewRequireCnt(key).default || viewRequireCnt(key);
});

initApi('/api');

createApp(HpsfirManageBaseUIApp)
  .use(HpsfirManageBaseUI, {
    siteName: 'HpsfirManageBaseUI',
    baseApiPath: '/api',
    viewMap: allComponents,
    description: '描述',
    logo: '/logo.png',
  } as HpsfirManageBaseOption)
  .mount('#app');
