main.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import 'uno.css';
  2. import '@/design/index.less';
  3. import '@/components/VxeTable/src/css/index.scss';
  4. import 'ant-design-vue/dist/reset.css';
  5. // Register icon sprite
  6. import 'virtual:svg-icons-register';
  7. import { createApp } from 'vue';
  8. import 'vxe-table/lib/style.css';
  9. import { registerGlobComp } from '@/components/registerGlobComp';
  10. import { setupGlobDirectives } from '@/directives';
  11. import { setupI18n } from '@/locales/setupI18n';
  12. import { setupErrorHandle } from '@/logics/error-handle';
  13. import { initAppConfigStore } from '@/logics/initAppConfig';
  14. import { router, setupRouter } from '@/router';
  15. import { setupRouterGuard } from '@/router/guard';
  16. import { setupStore } from '@/store';
  17. import App from './App.vue';
  18. declare global {
  19. interface Window {
  20. updateFavicon: (url: string) => void;
  21. }
  22. }
  23. // 定义全局的更新 favicon 函数
  24. window.updateFavicon = function (url: string) {
  25. let link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
  26. if (!link) {
  27. link = document.createElement('link') as HTMLLinkElement;
  28. link.rel = 'icon';
  29. document.head.appendChild(link);
  30. }
  31. link.href = url;
  32. };
  33. async function bootstrap() {
  34. const app = createApp(App);
  35. app.config.warnHandler = () => {
  36. // 在这里处理或记录警告
  37. };
  38. // Configure store
  39. // 配置 store
  40. setupStore(app);
  41. // Initialize internal system configuration
  42. // 初始化内部系统配置
  43. initAppConfigStore();
  44. // Register global components
  45. // 注册全局组件
  46. registerGlobComp(app);
  47. // Multilingual configuration
  48. // 多语言配置
  49. // Asynchronous case: language files may be obtained from the server side
  50. // 异步案例:语言文件可能从服务器端获取
  51. await setupI18n(app);
  52. // Configure routing
  53. // 配置路由
  54. setupRouter(app);
  55. // router-guard
  56. // 路由守卫
  57. setupRouterGuard(router);
  58. // Register global directive
  59. // 注册全局指令
  60. setupGlobDirectives(app);
  61. // Configure global error handling
  62. // 配置全局错误处理
  63. setupErrorHandle(app);
  64. if (process.env.NODE_ENV === 'development') {
  65. app.config.warnHandler = () => {};
  66. }
  67. // https://next.router.vuejs.org/api/#isready
  68. // await router.isReady();
  69. app.mount('#app');
  70. }
  71. bootstrap();