import { REQUEST_CONFIG } from '../../../config'; /** 获取域名 useLocal: 开发用-是否不用代理的域名,用本地域名 */ export const useDomain = (useLocal = false) => { let origin = '', pathname = ''; if (process.env.NODE_ENV == 'development' && !useLocal) { const [domain] = REQUEST_CONFIG.BASE_URL.match( /^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/ ); origin = domain; pathname = REQUEST_CONFIG.BASE_URL; } else { origin = location.origin; pathname = location.pathname; } const hasSuffix = pathname.match(/\/KasiteWeb\//); return `${origin}${hasSuffix ? '/KasiteWeb' : ''}`; };