From 28e2a935631212ea0def21770d4b9fbefa83f9cb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Apr 2026 13:16:03 +0800 Subject: [PATCH] feat(seo-copy): restore all source scenes --- code/scripts/seo_copy_restore_from_source.php | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/code/scripts/seo_copy_restore_from_source.php b/code/scripts/seo_copy_restore_from_source.php index e9f1287..7c84128 100644 --- a/code/scripts/seo_copy_restore_from_source.php +++ b/code/scripts/seo_copy_restore_from_source.php @@ -19,18 +19,20 @@ function usage(): void $script = basename(__FILE__); echo <</detail/*.json and /play/*.json --target Target root. Defaults to code/data/seo_copy_published + --scenes Optional comma-separated scenes. Defaults to all known scenes found in source --dry-run Preview only, do not write files Examples: php code/scripts/{$script} \\ --host=chuanjiafeng-net \\ --source=code/storage/domain_bootstrap_bundles/chuanjiafeng-compact/data/seo_copy \\ + --scenes=home,category_index,category_list,search,rank_index,rank_list,detail,forge,play \\ --dry-run TXT; @@ -80,6 +82,7 @@ foreach (array_slice($argv, 1) as $strArg) { $strHost = trim((string)($arrArgs['host'] ?? '')); $strSource = trim((string)($arrArgs['source'] ?? '')); $strTarget = trim((string)($arrArgs['target'] ?? base_path('data/seo_copy_published'))); +$strScenes = trim((string)($arrArgs['scenes'] ?? '')); $boolDryRun = !empty($arrArgs['dry-run']); if ($strHost === '' || $strSource === '') { @@ -96,7 +99,33 @@ if (!is_dir($strHostSource)) { exit(2); } -$arrScenes = ['detail', 'play']; +$arrKnownScenes = ['home', 'category_index', 'category_list', 'search', 'rank_index', 'rank_list', 'detail', 'forge', 'play']; +$arrScenes = []; + +if ($strScenes !== '') { + foreach (explode(',', $strScenes) as $strScene) { + $strScene = trim((string)$strScene); + if ($strScene === '' || !in_array($strScene, $arrKnownScenes, true)) { + continue; + } + + $arrScenes[] = $strScene; + } +} else { + foreach ($arrKnownScenes as $strScene) { + if (is_dir($strHostSource . '/' . $strScene)) { + $arrScenes[] = $strScene; + } + } +} + +$arrScenes = array_values(array_unique($arrScenes)); + +if (empty($arrScenes)) { + fwrite(STDERR, "no valid scenes found for host: {$strHost}\n"); + exit(3); +} + $arrSummary = []; foreach ($arrScenes as $strScene) {