main.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import '/@/design/index.less';
  2. import '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 local development is introduced, and the production environment is introduced on demand
  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. // Register icon Sprite
  19. import 'vite-plugin-svg-icons/register';
  20. import { isDevMode } from '/@/utils/env';
  21. (async () => {
  22. const app = createApp(App);
  23. // Register global components
  24. registerGlobComp(app);
  25. // Multilingual configuration
  26. await setupI18n(app);
  27. // Configure routing
  28. setupRouter(app);
  29. // Configure vuex store
  30. setupStore(app);
  31. // Register global directive
  32. setupGlobDirectives(app);
  33. // Configure global error handling
  34. setupErrorHandle(app);
  35. // Mount when the route is ready
  36. await router.isReady();
  37. app.mount('#app', true);
  38. // The development environment takes effect
  39. if (isDevMode()) {
  40. // app.config.performance = true;
  41. window.__APP__ = app;
  42. }
  43. })();