| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { initPreferences } from '@velofex/preferences';
- import { unmountGlobalLoading } from '@velofex/utils';
- import { overridesPreferences } from './preferences';
- import { mountWindowBridge } from './utils/window-bridge';
- function mountLegacyIconStyles() {
- if (typeof document === 'undefined') {
- return;
- }
- const styleId = 'webb-legacy-icon-style';
- const iconBase = import.meta.env.PROD ? '' : 'https://edesign.shalu.com';
- const href = `${iconBase}/Content/Lib/component/icons/icon.css?v=2.2.0`;
- const existing = document.querySelector<HTMLLinkElement>(`#${styleId}`);
- if (existing) {
- existing.href = href;
- return;
- }
- const link = document.createElement('link');
- link.id = styleId;
- link.rel = 'stylesheet';
- link.href = href;
- document.head.append(link);
- }
- /**
- * 应用初始化完成之后再进行页面加载渲染
- */
- async function initApplication() {
- mountLegacyIconStyles();
- mountWindowBridge();
- // name用于指定项目唯一标识
- // 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
- const env = import.meta.env.PROD ? 'prod' : 'dev';
- const appVersion = import.meta.env.VITE_APP_VERSION;
- const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
- // app偏好设置初始化
- await initPreferences({
- namespace,
- overrides: overridesPreferences,
- });
- // 启动应用并挂载
- // vue应用主要逻辑及视图
- const { bootstrap } = await import('./bootstrap');
- await bootstrap(namespace);
- // 移除并销毁loading
- unmountGlobalLoading();
- }
- initApplication();
|