import { createApp } from 'vue';
import router, { setupRouter } from './router';
import { setupStore } from '@/store';
import './main.scss';
import 'element-plus/dist/index.css';
import App from './App.vue';
import { setupElement } from '@/plugins';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';

import 'virtual:svg-icons-register';

dayjs.locale('zh-cn');

async function bootstrap() {
  const app = createApp(App);

  // 全局完整引入 element 组件
  setupElement(app);

  // 挂载状态管理
  setupStore(app);
  //优先挂载一下 Provider 解决路由守卫，Axios中可使用，Dialog，Message 等之类组件
  // appProvider.mount('#appProvider', true);

  // 挂载路由
  await setupRouter(app);

  // 路由准备就绪后挂载APP实例
  await router.isReady();
  app.mount('#app', true);
}

void bootstrap();
