Commit 882739ad authored by Bill's avatar Bill
parents 20b8848e fd06c499
......@@ -45,6 +45,7 @@ const config: any = {
mfsu: {},
antd: {},
locale: {
default: 'zh-CN',
antd: true,
// 默认情况下,当前语言环境的识别按照:localStorage 中 umi_locale 值 > 浏览器检测 > default 设置的默认语言 > 中文
baseNavigator: true,
......
......@@ -88,7 +88,7 @@
"copy-to-clipboard": "^3.3.1",
"crypto-js": "^4.0.0",
"dayjs": "^1.10.7",
"god": "0.2.11",
"god": "0.2.12",
"immutability-helper": "^3.1.1",
"js-cookie": "^2.2.1",
"lingxi-design-ui": "^2.0.19",
......
import { GlobalConfig } from '@/global/config'
import { getTopDomainByHost, getDefaultEnterprise, getChannelInfo, getIChannelInfo } from '@/utils'
import {
getInfoCenterUrl,
getlogisticsCenterUrl,
getManufactureCenterUrl,
getSrmCenterUrl,
getTopDomain,
} from '@/utils/getDomain'
export const NOT_CHANGE_VALUE = 'hello, world'
// socket的链接地址, 默认会使用后端接口网关地址
......@@ -14,13 +21,16 @@ export const REQUEST_HEADER = 'http://'
/**
* 顶域
*/
export const TOP_DOMAIN = process.env.NODE_ENV !== 'development' ? getTopDomainByHost(GlobalConfig.global.siteInfo.siteUrl, true) : 'lingxidev.com'
const env = process.env.NODE_ENV
export const TOP_DOMAIN = getTopDomain(env, 'lingxidev.com')
export const TOP_DOMAIN_NO_PORT = getTopDomain(env, 'lingxidev.com', true)
// export const TOP_DOMAIN = getTopDomainByHost(GlobalConfig.global.siteInfo.siteUrl)
/**
* 获取平台首页子域名
*/
const getPlatformSubDomain = (defaultSubDomian: string) => {
const getPlatformSubDomain = (defaultSubDomian: string) => {
const siteUrl = GlobalConfig.global.siteInfo.siteUrl
return siteUrl.split('.')[0] || defaultSubDomian
}
......@@ -52,22 +62,22 @@ export const ICHANNEL_CENTER_URL = `${REQUEST_HEADER}${iChannelInfo ? iChannelIn
/**
* 行情资讯域名
*/
export const INFO_CENTER_URL = `${REQUEST_HEADER}info.${TOP_DOMAIN}`
export const INFO_CENTER_URL = getInfoCenterUrl(TOP_DOMAIN)
/**
* 企业采购域名
*/
export const SRM_CENTER_URL = `${REQUEST_HEADER}srm.${TOP_DOMAIN}`
export const SRM_CENTER_URL = getSrmCenterUrl(TOP_DOMAIN)
/**
* 物流服务域名
*/
export const LOGISTICS_CENTER_URL = `${REQUEST_HEADER}logistics.${TOP_DOMAIN}`
export const LOGISTICS_CENTER_URL = getlogisticsCenterUrl(TOP_DOMAIN)
/**
* 加工服务域名
*/
export const MANUFACTURE_CENTER_URL = `${REQUEST_HEADER}manufacture.${TOP_DOMAIN}`
export const MANUFACTURE_CENTER_URL = getManufactureCenterUrl(TOP_DOMAIN)
export const MALL_TYPE = {
......@@ -100,9 +110,9 @@ export enum LAYOUT_TYPE {
* 企业商城
*/
mall = 'mall',
/**
* 自营商城
*/
/**
* 自营商城
*/
own = 'own',
/**
* 店铺(店铺商城)
......
import { GlobalConfig } from '@/global/config'
/**
* 请求头
*/
export const REQUEST_HEADER = 'http://'
export const getTopDomainByHost = (url: string, isPort = false): string => {
if (!url) return ''
// 如果后缀带有端口号, 则把端口号也加上
const splitUrl = url.split(':')
if (splitUrl.length > 1 && isPort) {
return `${splitUrl[0].split('.').slice(-2).join('.')}`
}
return url.split('.').slice(-2).join('.')
}
/**
* 获取顶域
*/
export const getTopDomain = (env: string = 'production', defaultTopDomain: string = 'lingxidev.com', isPort: boolean = false) => {
return env !== 'development' ? getTopDomainByHost(GlobalConfig.global.siteInfo.siteUrl, isPort) : defaultTopDomain
}
/**
* 获取平台首页子域名
*/
const getPlatformSubDomain = (defaultSubDomian: string) => {
const siteUrl = GlobalConfig.global.siteInfo.siteUrl
return siteUrl.split('.')[0] || defaultSubDomian
}
/**
* 获取平台首页域名
*/
export const getPlatformDomain = (topDomain: string, defaultSubDomian: string = 'lx-www') => {
return `${REQUEST_HEADER}${getPlatformSubDomain(defaultSubDomian)}.${topDomain}`
}
/**
* 会员中心域名
*/
export const getMemberCenterUrl = (topDomain: string, defaultSubDomian: string = 'lx-member') => {
return `${REQUEST_HEADER}${defaultSubDomian}.${topDomain}`
}
export const getDefaultEnterprise = () => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { environment: number; type: number, property?: any }) => item.environment === 1 && item.type === 1 && item.property === 1)
const defaultMall = webMallList.filter((item: any) => item.isDefault === 1)[0]
let result: any = undefined
if (defaultMall) {
result = defaultMall
} else {
if (webMallList && webMallList.length > 0) {
result = webMallList[0]
}
}
return result
}
const enterpriseInfo = getDefaultEnterprise()
/**
* 企业商城域名
*/
export const getEnterpriseCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${enterpriseInfo ? enterpriseInfo.url : 'lx-b2b'}.${topDomain}`
}
export const getChannelInfo = () => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { environment: number; type: number }) => item.environment === 1 && item.type === 3)
return webMallList[0]
}
export const getIChannelInfo = () => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { environment: number; type: number }) => item.environment === 1 && item.type === 4)
return webMallList[0]
}
const channelInfo = getChannelInfo()
const iChannelInfo = getIChannelInfo()
/**
* 渠道商城子域名
*/
export const getChannelCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${channelInfo ? channelInfo.url : 'lx-channel'}.${topDomain}`
}
/**
* 自有渠道商城子域名
*/
export const getIChannelCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${iChannelInfo ? iChannelInfo.url : 'lx-ichannel'}.${topDomain}`
}
const getShopInfoByType = (type: number) => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: any) => item.type === type)
return webMallList[0]
}
const infoDetail = getShopInfoByType(9)
const srmDetail = getShopInfoByType(6)
const logisticsDetail = getShopInfoByType(7)
const manufactureDetail = getShopInfoByType(8)
/**
* 行情资讯域名
*/
export const getInfoCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${infoDetail ? infoDetail.url : 'lx-info'}.${topDomain}`
}
/**
* 企业采购域名
*/
export const getSrmCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${srmDetail ? srmDetail.url : 'lx-srm'}.${topDomain}`
}
/**
* 物流服务域名
*/
export const getlogisticsCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${logisticsDetail ? logisticsDetail.url : 'lx-logistics'}.${topDomain}`
}
/**
* 加工服务域名
*/
export const getManufactureCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${manufactureDetail ? manufactureDetail.url : 'lx-manufacture'}.${topDomain}`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment