main.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import '/@/design/index.less';
  2. // Register windi
  3. import 'virtual:windi.css';
  4. // Register icon sprite
  5. import 'virtual:svg-icons-register';
  6. import App from './App.vue';
  7. import { createApp } from 'vue';
  8. import { initAppConfigStore } from '/@/logics/initAppConfig';
  9. import { setupErrorHandle } from '/@/logics/error-handle';
  10. import { router, setupRouter } from '/@/router';
  11. import { setupRouterGuard } from '/@/router/guard';
  12. import { setupStore } from '/@/store';
  13. import { setupGlobDirectives } from '/@/directives';
  14. import { setupI18n } from '/@/locales/setupI18n';
  15. import { registerGlobComp } from '/@/components/registerGlobComp';
  16. // Do not introduce on-demand in local development?
  17. // In the local development for introduce on-demand, the number of browser requests will increase by about 20%.
  18. // Which may slow down the browser refresh.
  19. // Therefore, all are introduced in local development, and only introduced on demand in the production environment
  20. if (import.meta.env.DEV) {
  21. import('ant-design-vue/dist/antd.less');
  22. }
  23. async function bootstrap() {
  24. const app = createApp(App);
  25. // Configure store
  26. setupStore(app);
  27. // Initialize internal system configuration
  28. initAppConfigStore();
  29. // Register global components
  30. registerGlobComp(app);
  31. // Multilingual configuration
  32. await setupI18n(app);
  33. // Configure routing
  34. setupRouter(app);
  35. // router-guard
  36. setupRouterGuard(router);
  37. // Register global directive
  38. setupGlobDirectives(app);
  39. // Configure global error handling
  40. setupErrorHandle(app);
  41. // Mount when the route is ready
  42. // https://next.router.vuejs.org/api/#isready
  43. await router.isReady();
  44. app.mount('#app', true);
  45. }
  46. void bootstrap();