attach-environment-config.ts 807 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
const envMap = new Map([
  ['baseUrl', 'BaseUrl'],
  ['remoteModelUrl', 'remoteDynaPath'],
  ['dcSystem', 'mockDcSystemId'],
  ['enablePermission', 'enablePermissionValid'],
]);

export async function attachEnvironmentConfig(): Promise<void> {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const env = (window as any).Environment;

  // environment.js里的值覆盖到ibiz.env里,名称不一致的按envMap映射去修改。
  Object.keys(ibiz.env).forEach(key => {
    const key2 = envMap.has(key) ? envMap.get(key)! : key;
    if (env[key2] != null) {
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      (ibiz.env as any)[key] = env[key2];
    }
  });

  if (env.AppTitle) {
    document.title = env.AppTitle;
  }

  ibiz.log.setLevel(ibiz.env.logLevel);
}