fix(seo-copy): enrich legacy detail play payloads
This commit is contained in:
@@ -1199,6 +1199,10 @@ class VideoService
|
||||
? SeoCopyStore::getPreferredPageData($strHost, $strScene, $arrPageKeys)
|
||||
: [];
|
||||
|
||||
if (!empty($arrData)) {
|
||||
$arrData = $this->mergeLegacySeoCopyWithDefault($strHost, $strScene, $arrPageKeys, $arrData);
|
||||
}
|
||||
|
||||
if (!empty($arrData)) {
|
||||
$arrData = $this->interpolateSeoCopyData($arrData, $this->buildSeoCopyTokens($strScene, $arrOptions));
|
||||
}
|
||||
@@ -1210,6 +1214,57 @@ class VideoService
|
||||
return $this->normalizeSeoCopyBlock($strScene, $arrData);
|
||||
}
|
||||
|
||||
private function mergeLegacySeoCopyWithDefault(string $strHost, string $strScene, array $arrPageKeys, array $arrData): array
|
||||
{
|
||||
if (!in_array($strScene, ['detail', 'play'], true)) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$arrSpecificKeys = array_values(array_filter($arrPageKeys, static function ($strPageKey): bool {
|
||||
$strPageKey = trim((string)$strPageKey);
|
||||
return $strPageKey !== '' && $strPageKey !== 'default';
|
||||
}));
|
||||
|
||||
if (empty($arrSpecificKeys)) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$boolLegacySpecificPayload = empty($arrData['guide_cards'])
|
||||
&& empty($arrData['title_template'])
|
||||
&& empty($arrData['keywords_template'])
|
||||
&& empty($arrData['description_template']);
|
||||
|
||||
if (!$boolLegacySpecificPayload) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$arrDefaultData = SeoCopyStore::getPreferredPageData($strHost, $strScene, ['default']);
|
||||
if (empty($arrDefaultData)) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$arrMerged = array_merge($arrDefaultData, $arrData);
|
||||
|
||||
foreach (['guide_cards', 'title_template', 'keywords_template', 'description_template'] as $strField) {
|
||||
if (empty($arrData[$strField]) && !empty($arrDefaultData[$strField])) {
|
||||
$arrMerged[$strField] = $arrDefaultData[$strField];
|
||||
}
|
||||
}
|
||||
|
||||
$arrLeadMap = [
|
||||
'detail' => ['detail_body_lead', 'detail_play_link_lead', 'detail_body_tail', 'detail_faq'],
|
||||
'play' => ['play_intro', 'play_meta_note', 'play_body_lead', 'play_body_next'],
|
||||
];
|
||||
|
||||
foreach ((array)($arrLeadMap[$strScene] ?? []) as $strField) {
|
||||
if (!empty($arrDefaultData[$strField])) {
|
||||
$arrMerged[$strField] = $arrDefaultData[$strField];
|
||||
}
|
||||
}
|
||||
|
||||
return $arrMerged;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSONDocument / 对象 / array 统一转数组(递归)
|
||||
*/
|
||||
|
||||
@@ -3608,6 +3608,55 @@ php code/scripts/seo_copy_front_verify.php chuanjiafeng.net category_list dian-y
|
||||
2. 其次 host 自己的 `default.json`
|
||||
3. 最后才是通用 fallback
|
||||
|
||||
另外,本轮继续往下排查后又确认了一层:
|
||||
|
||||
1. 有些 host 虽然存在细粒度 `detail/play` page-key 文件
|
||||
2. 但这些具体文件本身是旧低配格式
|
||||
3. 它们没有 `title_template / keywords_template / description_template / guide_cards`
|
||||
4. 同时文案主体比 `default.json` 更通用
|
||||
|
||||
典型样本:
|
||||
|
||||
1. `jpjdxs-com/detail/76342.json`
|
||||
2. `jpjdxs-com/play/76342-play-douban-1.json`
|
||||
|
||||
这类文件会继续压住 `default.json`,导致页面仍然表现得像“引导文退化”。
|
||||
|
||||
所以这轮又补了一层兼容:
|
||||
|
||||
1. 如果 `detail/play` 命中的具体 page-key 文件属于旧低配格式
|
||||
2. 则自动合并 `default.json` 里的 richer 字段
|
||||
3. 重点补入:
|
||||
- `guide_cards`
|
||||
- `title_template`
|
||||
- `keywords_template`
|
||||
- `description_template`
|
||||
- `detail_body_lead / detail_play_link_lead / detail_body_tail / detail_faq`
|
||||
- `play_intro / play_meta_note / play_body_lead / play_body_next`
|
||||
|
||||
这样可以尽量保留具体 page-key 已有的主题信息,同时恢复默认版更成熟的引导结构。
|
||||
|
||||
### 5.1 这一层兼容的实测现象
|
||||
|
||||
当前前台实测已经出现分层结果:
|
||||
|
||||
1. `jpjdxs.com` 播放页真实页面已出现:
|
||||
- `当前为色降2之血玫瑰播放页`
|
||||
- `如果你已在详情页确认...`
|
||||
- `播放前建议...`
|
||||
- `先看线路`
|
||||
2. 同站详情页暂时仍显示旧通用句式
|
||||
|
||||
这更像:
|
||||
|
||||
1. 代码逻辑已经生效
|
||||
2. 但详情页前台仍可能被页面缓存 / 反向代理缓存顶住
|
||||
|
||||
后续如果继续验证,不要只看一轮 curl,就直接下结论说“修复无效”,要先区分:
|
||||
|
||||
1. 代码逻辑未生效
|
||||
2. 还是前台缓存未刷新
|
||||
|
||||
### 6. 对后续 Codex 的明确提醒
|
||||
|
||||
后面如果再看到:
|
||||
|
||||
Reference in New Issue
Block a user