Commit 2d28ba59 authored by GuanHua's avatar GuanHua

feat:根据pass配置动态配置渠道商城路由

parent 5698db1b
import BASE_CONFIG from '../base.config.json' import BASE_CONFIG from '../base.config.json'
import { MALL_ROUTE_USE_CONFIG } from '../config' import { checkUrl } from '../utils'
const shopInfo = BASE_CONFIG.web.shopInfo const shopInfo = BASE_CONFIG.web.shopInfo
let webChannelInfo = shopInfo.filter(item => item.environment === 1 && item.type === 3)[0] // 渠道商城 let webChannelInfo = shopInfo.filter(item => item.environment === 1 && item.type === 3)[0] // 渠道商城
let webChannelPointInfo = shopInfo.filter(item => item.environment === 1 && item.type === 5)[0] // 渠道积分商城 let webChannelPointInfo = shopInfo.filter(item => item.environment === 1 && item.type === 5)[0] // 渠道积分商城
const checkUrl = (url, defaultUrl) => {
if (url) {
if (url.indexOf('/') > -1) {
return url
} else {
return `/${url}`
}
} else {
return defaultUrl
}
}
const defaultChannelRoute = '/channelmall' // 默认渠道商城根路径 const defaultChannelRoute = '/channelmall' // 默认渠道商城根路径
const defaultIChannelPointRoute = '/pointsMall' // 默认渠道积分商城路径 const defaultIChannelPointRoute = '/pointsMall' // 默认渠道积分商城路径
const rootRoute = MALL_ROUTE_USE_CONFIG ? checkUrl(webChannelInfo.url, defaultChannelRoute) : defaultChannelRoute const rootRoute = process.env.USE_ROUTE_CONFIG ? checkUrl(webChannelInfo.url, defaultChannelRoute) : defaultChannelRoute
const pointMallRoute = MALL_ROUTE_USE_CONFIG ? checkUrl(webChannelPointInfo.url, defaultIChannelPointRoute) : defaultIChannelPointRoute const pointMallRoute = process.env.USE_ROUTE_CONFIG ? checkUrl(webChannelPointInfo.url, defaultIChannelPointRoute) : defaultIChannelPointRoute
const ChannelRoute = { const ChannelRoute = {
path: rootRoute, path: rootRoute,
......
...@@ -3,7 +3,6 @@ import routes from './router' ...@@ -3,7 +3,6 @@ import routes from './router'
import proxy from './proxy' import proxy from './proxy'
import theme from './lingxi.theme.config' import theme from './lingxi.theme.config'
export const MALL_ROUTE_USE_CONFIG = process.env.USE_ROUTE_CONFIG || true // 是否使用pass平台配置的商城子域名
const OPEN_THEME_BUILD = process.env.NODE_ENV === 'production' ? true : false // 是否开启动态主题 const OPEN_THEME_BUILD = process.env.NODE_ENV === 'production' ? true : false // 是否开启动态主题
const config: any = { const config: any = {
......
import shopRoute from '../shopRoutes' import shopRoute from '../shopRoutes'
import channelRoute from '../channelRoutes' import channelRoute from '../channelRoutes'
import ichannelRoute from '../selfchannelRoutes' import ichannelRoute from '../selfchannelRoutes'
import { MALL_ROUTE_USE_CONFIG } from '../config'
import BASE_CONFIG from '../base.config.json' import BASE_CONFIG from '../base.config.json'
import { checkUrl } from '../utils'
const shopInfo = BASE_CONFIG.web.shopInfo const shopInfo = BASE_CONFIG.web.shopInfo
// let webMallInfo = shopInfo.filter(item => item.environment === 1 && item.type === 1)[0] // 企业商城 // let webMallInfo = shopInfo.filter(item => item.environment === 1 && item.type === 1)[0] // 企业商城
let webPointMallInfo = shopInfo.filter(item => item.environment === 1 && item.type === 2)[0] // 积分商城 let webPointMallInfo = shopInfo.filter(item => item.environment === 1 && item.type === 2)[0] // 积分商城
const defaultPointMallRoute = '/pointsMall' // 积分商城默认路径 const defaultPointMallRoute = '/pointsMall' // 积分商城默认路径
const pointMallRoute = MALL_ROUTE_USE_CONFIG ? webPointMallInfo.url || defaultPointMallRoute : defaultPointMallRoute const pointMallRoute = process.env.USE_ROUTE_CONFIG ? checkUrl(webPointMallInfo.url, defaultPointMallRoute) : defaultPointMallRoute
console.log(process.env.USE_ROUTE_CONFIG, checkUrl(webPointMallInfo.url, defaultPointMallRoute), pointMallRoute, "pointMallRoute")
const mallRoute = { const mallRoute = {
path: '/', path: '/',
......
import BASE_CONFIG from '../base.config.json' import BASE_CONFIG from '../base.config.json'
import { MALL_ROUTE_USE_CONFIG } from '../config' import { checkUrl } from '../utils'
const shopInfo = BASE_CONFIG.web.shopInfo const shopInfo = BASE_CONFIG.web.shopInfo
let webIChannelInfo = shopInfo.filter(item => item.environment === 1 && item.type === 4)[0] // 渠道自有商城 let webIChannelInfo = shopInfo.filter(item => item.environment === 1 && item.type === 4)[0] // 渠道自有商城
let webChannelPointInfo = shopInfo.filter(item => item.environment === 1 && item.type === 5)[0] // 渠道积分商城 let webChannelPointInfo = shopInfo.filter(item => item.environment === 1 && item.type === 5)[0] // 渠道积分商城
const checkUrl = (url, defaultUrl) => {
if (url) {
if (url.indexOf('/') > -1) {
return url
} else {
return `/${url}`
}
} else {
return defaultUrl
}
}
const defaultIChannelRoute = '/ichannelmall' // 默认渠道商城根路径 const defaultIChannelRoute = '/ichannelmall' // 默认渠道商城根路径
const defaultIChannelPointRoute = '/pointsMall' // 默认渠道积分商城路径 const defaultIChannelPointRoute = '/pointsMall' // 默认渠道积分商城路径
const rootRoute = MALL_ROUTE_USE_CONFIG ? checkUrl(webIChannelInfo.url, defaultIChannelRoute) : defaultIChannelRoute const rootRoute = process.env.USE_ROUTE_CONFIG ? checkUrl(webIChannelInfo.url, defaultIChannelRoute) : defaultIChannelRoute
const pointMallRoute = MALL_ROUTE_USE_CONFIG ? checkUrl(webChannelPointInfo.url, defaultIChannelPointRoute) : defaultIChannelPointRoute const pointMallRoute = process.env.USE_ROUTE_CONFIG ? checkUrl(webChannelPointInfo.url, defaultIChannelPointRoute) : defaultIChannelPointRoute
const selfChannelRoute = { const selfChannelRoute = {
path: rootRoute, path: rootRoute,
......
export const checkUrl = (url, defaultUrl) => {
if (url && typeof url === 'string') {
if (url.indexOf('/') > -1) {
return url.trim()
} else {
return `/${url}`.trim()
}
} else {
return defaultUrl
}
}
\ No newline at end of file
...@@ -14,12 +14,12 @@ interface newRootObject extends RootObject { ...@@ -14,12 +14,12 @@ interface newRootObject extends RootObject {
ichannelRootRoute: string; ichannelRootRoute: string;
} }
const checkUrl = (url, defaultUrl) => { export const checkUrl = (url, defaultUrl) => {
if (url) { if (url && typeof url === 'string') {
if (url.indexOf('/') > -1) { if (url.indexOf('/') > -1) {
return url return url.trim()
} else { } else {
return `/${url}` return `/${url}`.trim()
} }
} else { } else {
return defaultUrl return defaultUrl
......
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