main.ts 945 B

12345678910111213141516171819202122232425262728293031
  1. import { initPreferences } from '@vben/preferences';
  2. import { unmountGlobalLoading } from '@vben/utils';
  3. import { overridesPreferences } from './preferences';
  4. /**
  5. * 应用初始化完成之后再进行页面加载渲染
  6. */
  7. async function initApplication() {
  8. // name用于指定项目唯一标识
  9. // 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
  10. const env = import.meta.env.PROD ? 'prod' : 'dev';
  11. const appVersion = import.meta.env.VITE_APP_VERSION;
  12. const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
  13. // app偏好设置初始化
  14. await initPreferences({
  15. namespace,
  16. overrides: overridesPreferences,
  17. });
  18. // 启动应用并挂载
  19. // vue应用主要逻辑及视图
  20. const { bootstrap } = await import('./bootstrap');
  21. await bootstrap(namespace);
  22. // 移除并销毁loading
  23. unmountGlobalLoading();
  24. }
  25. initApplication();