优化了一些文件 增加多店铺

This commit is contained in:
yml
2026-04-09 01:31:47 +08:00
parent c2ec3aa6d2
commit e4ab1f559e
43 changed files with 1839 additions and 91 deletions
+56
View File
@@ -167,6 +167,21 @@ function applyEnvOverrides(baseConfig) {
nextConfig.platforms.agiso.appSecret = agisoAppSecret
}
const agisoTradeDetailEndpoint = String(process.env.AGISO_TRADE_DETAIL_ENDPOINT || '').trim()
if (agisoTradeDetailEndpoint) {
nextConfig.platforms.agiso.tradeDetail.endpoint = agisoTradeDetailEndpoint
}
const agisoTradeDetailApiVersion = String(process.env.AGISO_TRADE_DETAIL_API_VERSION || '').trim()
if (agisoTradeDetailApiVersion) {
nextConfig.platforms.agiso.tradeDetail.apiVersion = agisoTradeDetailApiVersion
}
const agisoTradeDetailTimeoutMs = parseInteger(process.env.AGISO_TRADE_DETAIL_TIMEOUT_MS)
if (agisoTradeDetailTimeoutMs !== null) {
nextConfig.platforms.agiso.tradeDetail.timeoutMs = agisoTradeDetailTimeoutMs
}
const agisoAppId = String(process.env.AGISO_APP_ID || '').trim()
if (agisoAppId) {
nextConfig.platforms.agiso.messaging.appId = agisoAppId
@@ -202,6 +217,11 @@ function applyEnvOverrides(baseConfig) {
nextConfig.platforms.agiso.messaging.messageTemplate = agisoMessageTemplate
}
const agisoShops = parseJsonObject(process.env.AGISO_SHOPS_JSON)
if (agisoShops) {
nextConfig.platforms.agiso.messaging.shops = normalizeAgisoMessagingShops(agisoShops)
}
return nextConfig
}
@@ -308,3 +328,39 @@ function parseJsonArray(rawValue) {
return null
}
}
function normalizeAgisoMessagingShops(rawValue) {
const output = {}
for (const [shopId, config] of Object.entries(rawValue || {})) {
const normalizedShopId = String(shopId || '').trim()
if (!normalizedShopId || !isPlainObject(config)) {
continue
}
const next = {}
const enabled = normalizeBooleanLike(config.enabled)
if (enabled !== null) {
next.enabled = enabled
}
for (const key of ['shopName', 'accessToken', 'messageTemplate', 'appSecret', 'apiVersion', 'sendMessageEndpoint']) {
const value = String(config[key] || '').trim()
if (value) {
next[key] = value
}
}
output[normalizedShopId] = next
}
return output
}
function normalizeBooleanLike(value) {
if (typeof value === 'boolean') {
return value
}
return parseBoolean(value)
}