import type { GlobConfig } from '/#/config'; import { getAppEnvConfig, getHomePath } from '/@/utils/env'; // 读取ip地址 let domainUrl = '', logoUrl = '', homePath = '', title = ''; const getUrl = () => { return new Promise((resolve, reject) => { try { fetch(VUE_APP_URL.baseUrl + '/ventanaly-device/safety/orgParams/queryDefault', { method: 'GET', cache: 'no-cache', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }) .then((response) => response.json()) .then((data) => { debugger; if (data.result) { title = data.result['systemTitle'] ? data.result['systemTitle'] : ''; logoUrl = data.result['logoIcon'] ? data.result['logoIcon'] : ''; const homePathKey = data.result['defaultTheme'] ? data.result['defaultTheme'] : ''; homePath = getHomePath(homePathKey); const faviconIcon = document.getElementById('faviconIcon'); if (faviconIcon) { faviconIcon.setAttribute('href', `${VUE_APP_URL.baseUrl}/sys/common/static/${logoUrl}`); } resolve(null); } else { reject(); } }); } catch (error) { reject(error); } }); }; export async function getRemoteSetting(){ debugger if (!title) { try { await getUrl(); } catch (error) {} } }; export const useGlobSetting = (): Readonly => { if (!title) { try { getUrl(); } catch (error) {} } const { VITE_GLOB_APP_TITLE, VITE_GLOB_API_URL, VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_PREFIX, VITE_GLOB_APP_CAS_BASE_URL, VITE_GLOB_APP_OPEN_SSO, VITE_GLOB_APP_OPEN_QIANKUN, VITE_GLOB_DOMAIN_URL, VITE_GLOB_ONLINE_VIEW_URL, VITE_3D_MODAL_ARR, } = getAppEnvConfig(); if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) { // warn( // `VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.` // ); } if (import.meta.env.DEV) { domainUrl = VITE_GLOB_DOMAIN_URL; } else if (import.meta.env.PROD) { domainUrl = VUE_APP_URL.baseUrl; } // Take global configuration const glob: Readonly = { logoUrl: logoUrl, title: title, domainUrl: domainUrl, apiUrl: VITE_GLOB_API_URL, shortName: VITE_GLOB_APP_SHORT_NAME, openSso: VITE_GLOB_APP_OPEN_SSO, openQianKun: VITE_GLOB_APP_OPEN_QIANKUN, casBaseUrl: VITE_GLOB_APP_CAS_BASE_URL, urlPrefix: VITE_GLOB_API_URL_PREFIX, uploadUrl: domainUrl, viewUrl: VITE_GLOB_ONLINE_VIEW_URL, modalUrlArr: VITE_3D_MODAL_ARR, homePath: homePath, }; return glob as Readonly; };