Merge branch 'main' into dev

This commit is contained in:
2026-11-03 10:33:10 +08:00
121 changed files with 5265 additions and 1629 deletions
+40 -10
View File
@@ -87,22 +87,52 @@ export function describeMissingConfigFields(config: MissingConfigCheck): string[
/**
* 面板预览用的示例订单号(与真实 16 位平台订单号形态一致)。
*/
const CLAIM_LINK_PREVIEW_TOKEN = '2628301923197355'
const CLAIM_LINK_PREVIEW_ORDER_NO = '2628301923197355'
/**
* 拼一条领取链接预览:`claimLinkBase` 去尾斜杠 + '/' + token。
* 规则与后端拼装一致(后端用配置里的 `claimLinkBase`)。
* 基址为空返回空串(后端会回退到通用兑换链接)。
* 拼一条领取链接预览:`<claimLinkBase>/<订单号>`。
* 规则与后端一致,历史 `/#/claim`、`/claim` 基址也会归一化为 `/h5/订单号`。
* 基址为空返回空串。
*/
export function buildDouyinMashidaClaimLinkPreview(
claimLinkBase: string,
token = CLAIM_LINK_PREVIEW_TOKEN,
orderNo = CLAIM_LINK_PREVIEW_ORDER_NO,
): string {
const base = String(claimLinkBase ?? '')
.trim()
.replace(/\/+$/, '')
if (!base) return ''
return `${base}/${String(token ?? '').trim()}`
const base = normalizeH5ClaimBase(claimLinkBase)
const normalizedOrderNo = String(orderNo ?? '').trim()
if (!base || !normalizedOrderNo) return ''
return `${base}/${encodeURIComponent(normalizedOrderNo)}`
}
/** 将历史 `/#/claim`、`/claim` 基址归一化为同站点 `/h5`,与后端生成口径一致。 */
function normalizeH5ClaimBase(claimLinkBase: string): string {
const raw = String(claimLinkBase ?? '').trim()
if (!raw) return ''
let url: URL
try {
url = new URL(raw)
} catch {
return ''
}
const pathname = url.pathname.replace(/\/+$/, '')
const h5Match = pathname.match(/\/h5(?:\/|$)/i)
const claimMatch = pathname.match(/\/claim(?:\/|$)/i)
if (h5Match?.index !== undefined) {
url.pathname = `${pathname.slice(0, h5Match.index)}/h5`
} else if (claimMatch?.index !== undefined) {
url.pathname = `${pathname.slice(0, claimMatch.index)}/h5`
} else if (pathname && pathname !== '/') {
url.pathname = `${pathname}/h5`
} else {
url.pathname = '/h5'
}
url.search = ''
url.hash = ''
return url.toString().replace(/\/+$/, '')
}
/**