import { getDomainParts, setDomainParts, buildHostUrls } from './domainState' // #ifdef H5 const [p, h] = [window.location.protocol, window.location.host] const isIP = /^\d+\.\d+\.\d+\.\d+:\d+$/.test(h) const [h5Ho, h5Dt] = isIP ? ['44a5c8109e4', 'com'] : h.split('.').slice(-2) const h5Ht = p == 'http:' ? 'https:' : p setDomainParts({ ho: h5Ho, dt: h5Dt, ht: h5Ht }) // #endif const staticConfig = { Code: { StatusOK: 200, StatusFail: 400, StatusSessionExpire: 600, StatusSNotFound: 404, }, Pattern: { Email: /^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i, Phone: /^1[3-9]\d{9}$/, Pin: /^(?!(\d)\1{5})(?!012345)(?!123456)(?!234567)(?!345678)(?!456789)(?!987654)(?!876543)(?!765432)(?!654321)(?!543210)\d{6}$/, Password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{}|;:,.<>?/~]{8,16}$/, Tel: /^0[1-9]{2,3}-\d{5,10}$/, Num: /\d/, NonNegInt: /^\d+$/, // 非负整数 PosInt: /^[1-9]\d*$/, // 正整数 nonnegative: /^\d+(\.\d{1,2})?$/, // 非负数(最多两位小数) englishName: /^[^\u4E00-\u9FA5]+$/, }, } const hostKeys = [ 'HostWs', 'Host80', 'Host00', 'Host85', 'Host04', 'Host90', 'HostShop', 'HostShopImg', 'Host87', 'Host05', 'HostEnter', ] as const type HostKey = (typeof hostKeys)[number] const config: Record = { ...staticConfig, get ho() { return getDomainParts().ho }, get host() { return getDomainParts().ho }, } hostKeys.forEach((key) => { Object.defineProperty(config, key, { enumerable: true, configurable: true, get() { return buildHostUrls()[key as HostKey] }, }) }) export default config as typeof staticConfig & Record & { ho: string host: string }