优化店铺配置相关

This commit is contained in:
yml
2026-04-14 16:15:17 +08:00
parent ed45eab26c
commit bb47d168a9
20 changed files with 425 additions and 198 deletions
-71
View File
@@ -6,7 +6,6 @@ import process from 'node:process'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
/** @typedef {import('../types/runtime-config.js').AgisoMessagingShopsConfig} AgisoMessagingShopsConfig */
/** @typedef {import('../types/runtime-config.js').RuntimeConfig} RuntimeConfig */
const require = createRequire(import.meta.url)
@@ -235,16 +234,6 @@ function applyEnvOverrides(baseConfig) {
}
}
const agisoAppId = String(process.env.AGISO_APP_ID || '').trim()
if (agisoAppId) {
nextConfig.platforms.agiso.messaging.appId = agisoAppId
}
const agisoAccessToken = String(process.env.AGISO_ACCESS_TOKEN || '').trim()
if (agisoAccessToken) {
nextConfig.platforms.agiso.messaging.accessToken = agisoAccessToken
}
const agisoMessageAppSecret = String(process.env.AGISO_MESSAGE_APP_SECRET || '').trim()
if (agisoMessageAppSecret) {
nextConfig.platforms.agiso.messaging.appSecret = agisoMessageAppSecret
@@ -265,21 +254,6 @@ function applyEnvOverrides(baseConfig) {
nextConfig.platforms.agiso.messaging.enabled = agisoMessagingEnabled
}
const agisoMessageTemplate = String(process.env.AGISO_MESSAGE_TEMPLATE || '').trim()
if (agisoMessageTemplate) {
nextConfig.platforms.agiso.messaging.messageTemplate = agisoMessageTemplate
}
const agisoAutoDeliveryMessageTemplate = String(process.env.AGISO_AUTO_DELIVERY_MESSAGE_TEMPLATE || '').trim()
if (agisoAutoDeliveryMessageTemplate) {
nextConfig.platforms.agiso.messaging.autoDeliveryMessageTemplate = agisoAutoDeliveryMessageTemplate
}
const agisoShops = parseJsonObject(process.env.AGISO_SHOPS_JSON)
if (agisoShops) {
nextConfig.platforms.agiso.messaging.shops = normalizeAgisoMessagingShops(agisoShops)
}
const proofMode = String(process.env.TENCENT_REDEEM_PROOF_MODE || '').trim()
if (proofMode) {
nextConfig.redeem.proofMode = proofMode
@@ -360,21 +334,6 @@ function parseInteger(rawValue) {
return Number.isFinite(parsed) ? parsed : null
}
function parseJsonObject(rawValue) {
const normalized = String(rawValue || '').trim()
if (!normalized) {
return null
}
try {
const parsed = JSON.parse(normalized)
return isPlainObject(parsed) ? parsed : null
} catch {
return null
}
}
function parseJsonArray(rawValue) {
const normalized = String(rawValue || '').trim()
@@ -390,36 +349,6 @@ function parseJsonArray(rawValue) {
}
}
function normalizeAgisoMessagingShops(rawValue) {
/** @type {AgisoMessagingShopsConfig} */
const output = {}
for (const [shopId, config] of Object.entries(rawValue || {})) {
const normalizedShopId = String(shopId || '').trim()
if (!normalizedShopId || !isPlainObject(config)) {
continue
}
/** @type {AgisoMessagingShopsConfig[string]} */
const next = {}
const enabled = normalizeBooleanLike(config.enabled)
if (enabled !== null) {
next.enabled = enabled
}
for (const key of ['shopName', 'accessToken', 'messageTemplate', 'autoDeliveryMessageTemplate', '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