import './styles/tailwindbase.css';
import 'element-plus/dist/index.css';
import './styles/index.scss';
import 'element-plus/theme-chalk/display.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import 'nprogress/nprogress.css';
import VueKonva from 'vue-konva';

import { createApp } from 'vue';
import App from './App.vue';
// import VueKonva from 'vue-konva';
import router, { setupRouter } from './router';
import { setupStore } from '@/store';
import 'virtual:svg-icons-register';
import { setupElement, setupDirectives, setupCustomComponents } from '@/plugins';
// import VueKonva from 'vue-konva';

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

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

  // 注册全局自定义组件
  setupCustomComponents(app);

  // 注册全局自定义指令，如：v-permission权限指令
  setupDirectives(app);

  // 注册全局方法，如：app.config.globalProperties.$message = message
  //setupGlobalMethods(app);

  // 挂载状态管理
  setupStore(app);

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

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

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

void bootstrap();
