fix(admin): 平台推送地址优先回显已配置的公网域名

- 引入 resolveDouyinMashidaPublicOrigin 从已配置的 claimLinkBase/certLink 提取公网域名
- 更新后台面板 message_url 展示逻辑,即使从 localhost 访问也清晰呈现已配置的公网推送地址
- 向平台订阅推送时使用已解析的公网域名,避免错误推送 localhost
- 补充前端单元测试并通过全量构建校验
This commit is contained in:
yml2213
2026-10-10 20:18:23 +08:00
parent fa1a67a03d
commit 73de90ea4f
3 changed files with 75 additions and 11 deletions
@@ -8,6 +8,7 @@ import {
buildDouyinMashidaMessageUrl,
describeMissingConfigFields,
isLocalDevBaseUrl,
resolveDouyinMashidaPublicOrigin,
} from '../src/utils/douyin-mashida.ts'
/** 固定顺序:接入开关 / 商户uid / 用户秘钥 / 兑换链接 */
@@ -126,3 +127,19 @@ test('发消息模板提示:没有 {link} 就等于没给买家链接', () =>
assert.equal(describeMessageTemplateWarning(''), '')
assert.match(describeMessageTemplateWarning('您的订单已发货'), /\{link\}/)
})
test('resolveDouyinMashidaPublicOrigin:从已配置的 claimLinkBase 或 certLink 提取公网 origin', () => {
assert.equal(
resolveDouyinMashidaPublicOrigin('https://nonsecretly-posttracheal-amado.ngrok-free.dev/h5'),
'https://nonsecretly-posttracheal-amado.ngrok-free.dev',
)
assert.equal(
resolveDouyinMashidaPublicOrigin('', 'https://my-domain.com/h5'),
'https://my-domain.com',
)
assert.equal(
resolveDouyinMashidaPublicOrigin('', '', 'http://localhost:5173'),
'http://localhost:5173',
)
})