main.ts 1.6 KB

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