main.ts 1.6 KB

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