main.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import '/@/design/index.less';
  2. import 'virtual:windi.css';
  3. import { createApp } from 'vue';
  4. import App from './App.vue';
  5. import { initAppConfigStore } from '/@/logics/initAppConfig';
  6. import router, { setupRouter } from '/@/router';
  7. import { setupRouterGuard } from '/@/router/guard';
  8. import { setupStore } from '/@/store';
  9. import { setupErrorHandle } from '/@/logics/error-handle';
  10. import { setupGlobDirectives } from '/@/directives';
  11. import { setupI18n } from '/@/locales/setupI18n';
  12. import { registerGlobComp } from '/@/components/registerGlobComp';
  13. // Register icon Sprite
  14. import 'virtual:svg-icons-register';
  15. // Do not introduce` on-demand in local development?
  16. // In the local development for on-demand introduction, 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 () => {
  23. const app = createApp(App);
  24. // Configure vuex 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();
  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. if (import.meta.env.DEV) {
  45. window.__APP__ = app;
  46. }
  47. })();