index.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import type { GlobConfig } from '/#/config';
  2. import { getAppEnvConfig } from '/@/utils/env';
  3. import { windows } from "rimraf";
  4. export const useGlobSetting = (): Readonly<GlobConfig> => {
  5. const {
  6. VITE_GLOB_APP_TITLE,
  7. VITE_GLOB_API_URL,
  8. VITE_GLOB_APP_SHORT_NAME,
  9. VITE_GLOB_API_URL_PREFIX,
  10. VITE_GLOB_APP_CAS_BASE_URL,
  11. VITE_GLOB_APP_OPEN_SSO,
  12. VITE_GLOB_APP_OPEN_QIANKUN,
  13. VITE_GLOB_DOMAIN_URL,
  14. VITE_GLOB_ONLINE_VIEW_URL,
  15. } = getAppEnvConfig();
  16. // if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
  17. // warn(
  18. // `VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`
  19. // );
  20. // }
  21. // 短标题:替换shortName的下划线为空格
  22. let shortTitle = VITE_GLOB_APP_SHORT_NAME.replace(/_/g, " ");
  23. let title = VITE_GLOB_APP_TITLE;
  24. // TODO:: 待域名申请好之后修改配置
  25. const domain = window.location.hostname;
  26. if (domain.includes('sohoeb2b')) {
  27. shortTitle = '苏豪通';
  28. title = '苏豪通'; // Use the imported image for this domain
  29. } else {
  30. shortTitle = 'AdWeb';
  31. title = 'AdWeb'; // Use the imported image for other domains
  32. }
  33. // Take global configuration
  34. const glob: Readonly<GlobConfig> = {
  35. title: title,
  36. domainUrl: VITE_GLOB_DOMAIN_URL,
  37. apiUrl: VITE_GLOB_API_URL,
  38. shortName: VITE_GLOB_APP_SHORT_NAME,
  39. shortTitle: shortTitle,
  40. openSso: VITE_GLOB_APP_OPEN_SSO,
  41. openQianKun: VITE_GLOB_APP_OPEN_QIANKUN,
  42. casBaseUrl: VITE_GLOB_APP_CAS_BASE_URL,
  43. urlPrefix: VITE_GLOB_API_URL_PREFIX,
  44. uploadUrl: VITE_GLOB_DOMAIN_URL,
  45. viewUrl: VITE_GLOB_ONLINE_VIEW_URL,
  46. };
  47. window._CONFIG['domianURL'] = VITE_GLOB_DOMAIN_URL;
  48. return glob as Readonly<GlobConfig>;
  49. };