修复(半自动注入): 平台首页占位值不再抢默认落地页

现象:本地注入浏览器仍跳到 https://www.huya.com/。

原因:开发 Mock 与人工配置把 semi_auto_config_json.browserTargets 默认写成平台首页,
而落地页解析里 browserTargets 优先级最高,导致公共策略的默认落地页永远不生效。

- platform-policy 新增 isPlatformHomepagePlaceholder / resolveBrowserTargetUrl:
  平台首页(huya/weibo/douyu 首页及其带斜杠写法)一律视为「未配置」,
  回落到各平台策略默认落地页;显式自定义 URL 仍然优先。
- createAdminBrowserSession 与 CK 导出的目标 URL 都走同一解析函数。
- 开发 Mock(后端默认值 + 后台造单页默认值)改用策略默认落地页,
  不再产生新的首页占位配置。
- 前端 resolveInjectionTargetUrl 同步同一规则,并补后端 2 条、前端 1 条断言。
This commit is contained in:
yml
2026-12-01 00:15:30 +08:00
parent fe320b5931
commit ab50a9290a
7 changed files with 113 additions and 15 deletions
@@ -48,6 +48,7 @@ import {
type DevDouyuFulfillmentMockResult,
type DevSemiAutoIntegrationResult,
} from '@/services/admin'
import { POST_INJECTION_URLS } from '@/utils/semi-auto-injection'
import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link'
type MockTabKey = 'douyu' | 'semi-auto' | 'affiliate-dash' | 'kuaishou-voucher' | 'open91'
@@ -926,7 +927,7 @@ function SemiAutoMockForm({
platform: 'huya',
quantity: 1,
pageTitle: '虎牙账号授权测试',
browserTargetUrl: 'https://www.huya.com/',
browserTargetUrl: POST_INJECTION_URLS.huya,
connectorMode: defaultMode,
}}
onFinish={onSubmit}
@@ -944,7 +945,8 @@ function SemiAutoMockForm({
onChange={(value: 'huya' | 'weibo') => {
form.setFieldsValue({
pageTitle: value === 'weibo' ? '微博角色绑定测试' : '虎牙账号授权测试',
browserTargetUrl: value === 'weibo' ? 'https://weibo.com/' : 'https://www.huya.com/',
browserTargetUrl:
value === 'weibo' ? POST_INJECTION_URLS.weibo : POST_INJECTION_URLS.huya,
...(value === 'weibo' ? { connectorMode: 'embedded' } : {}),
})
}}
@@ -1031,7 +1033,7 @@ function SemiAutoMockForm({
>
<Input
placeholder={
selectedPlatform === 'weibo' ? 'https://weibo.com/' : 'https://www.huya.com/'
selectedPlatform === 'weibo' ? POST_INJECTION_URLS.weibo : POST_INJECTION_URLS.huya
}
/>
</Form.Item>
+15 -1
View File
@@ -20,6 +20,20 @@ export function resolvePostInjectionUrl(platform: string | null | undefined): st
return ''
}
/**
* 平台首页占位值:历史开发 Mock / 人工配置把它填进 `browserTargets`,
* 等于「没有配置落地页」,必须当作未配置处理(后端同一规则)。
*/
const PLATFORM_HOMEPAGE_PLACEHOLDERS: Record<SemiAutoPlatform, readonly string[]> = {
huya: ['https://www.huya.com', 'https://www.huya.com/'],
weibo: ['https://weibo.com', 'https://weibo.com/'],
}
function isPlatformHomepagePlaceholder(platform: string, url: string): boolean {
if (platform !== 'huya' && platform !== 'weibo') return false
return PLATFORM_HOMEPAGE_PLACEHOLDERS[platform].includes(url.trim().toLowerCase())
}
/** 计算注入时要打开的目标页所需的最小任务信息。 */
export type SemiAutoInjectionTargetTask = {
platform: string
@@ -39,7 +53,7 @@ export function resolveInjectionTargetUrl(task: SemiAutoInjectionTargetTask): st
? task.semiAutoConfig.browserTargets
: []
const configured = String(targets.find((item) => item?.url)?.url || '').trim()
if (configured) return configured
if (configured && !isPlatformHomepagePlaceholder(task.platform, configured)) return configured
const policyTarget = String(task.bindingPolicy?.defaultTargetUrl || '').trim()
if (policyTarget) return policyTarget
return resolvePostInjectionUrl(task.platform)