This commit is contained in:
Your Name
2026-04-19 20:50:02 +08:00
parent d469c4b93d
commit 53a1d7e4fd
12 changed files with 801 additions and 91 deletions

View File

@@ -1057,7 +1057,7 @@ class Site extends BaseController
protected function domainExternalSeoSummaryRoot(): string
{
return $this->bootstrapCodeRoot() . '/public/_admin_templates/domain-seo-external/latest';
return $this->bootstrapCodeRoot() . '/storage/external-seo/latest';
}
protected function domainExternalSeoManualImportRoot(): string
@@ -1067,12 +1067,12 @@ class Site extends BaseController
protected function domainExternalSeoSnapshotRunRoot(): string
{
return $this->bootstrapCodeRoot() . '/public/_admin_templates/domain-seo-external/snapshot-runs';
return $this->bootstrapCodeRoot() . '/storage/external-seo/snapshot-runs';
}
protected function domainExternalSeoSnapshotValidateRunRoot(): string
{
return $this->bootstrapCodeRoot() . '/public/_admin_templates/domain-seo-external/snapshot-validate-runs';
return $this->bootstrapCodeRoot() . '/storage/external-seo/snapshot-validate-runs';
}
protected function domainExternalSeoStorageRoot(): string
@@ -1122,6 +1122,18 @@ class Site extends BaseController
return $strPath;
}
protected function storageRelativePath(string $strPath): string
{
$strStorageRoot = rtrim($this->bootstrapCodeRoot() . '/storage/', '/');
$strPath = str_replace('\\', '/', $strPath);
$strStorageRoot = str_replace('\\', '/', $strStorageRoot);
if (str_starts_with($strPath, $strStorageRoot . '/')) {
return substr($strPath, strlen($strStorageRoot . '/'));
}
return $strPath;
}
protected function bootstrapTemplateKey(?string $strTemplate): string
{
$strTemplate = strtolower(trim((string)$strTemplate));
@@ -2180,8 +2192,8 @@ class Site extends BaseController
$intLimit
);
$arrSummary = DomainExternalSeoSummaryHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
@@ -2215,8 +2227,8 @@ class Site extends BaseController
$intLimit
);
$arrSummary = DomainExternalSeoTrendHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
@@ -2334,8 +2346,8 @@ class Site extends BaseController
'mapped_hosts_count' => (int)($arrResult['mapped_hosts_count'] ?? 0),
'provider_summary' => $arrProviderSummary,
'real_summary_status' => (string)($arrRealSummary['status'] ?? ''),
'summary_json_path' => $this->publicRelativePath((string)($arrRealSummary['summary_json_path'] ?? '')),
'summary_html_path' => $this->publicRelativePath((string)($arrRealSummary['summary_html_path'] ?? '')),
'summary_json_path' => $this->storageRelativePath((string)($arrRealSummary['summary_json_path'] ?? '')),
'summary_html_path' => $this->storageRelativePath((string)($arrRealSummary['summary_html_path'] ?? '')),
]);
} catch (\Throwable $Throwable) {
return $this->error('9999', '上传 Search Console property map 失败:' . $Throwable->getMessage());
@@ -2348,8 +2360,8 @@ class Site extends BaseController
$intDays = max(1, min(30, (int)$Request->get('days', 7)));
$arrSummary = DomainExternalSeoSearchConsoleProviderPlanHelper::buildSummary($this->bootstrapCodeRoot(), $intDays);
$arrSummary = DomainExternalSeoSearchConsoleProviderPlanHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取 Search Console provider 计划失败:' . $Throwable->getMessage());
@@ -2362,8 +2374,8 @@ class Site extends BaseController
$intDays = max(1, min(30, (int)$Request->get('days', 7)));
$arrSummary = DomainExternalSeoSearchConsoleFetchHelper::buildSummary($this->bootstrapCodeRoot(), $intDays);
$arrSummary = DomainExternalSeoSearchConsoleFetchHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取 Search Console fetch 摘要失败:' . $Throwable->getMessage());
@@ -2375,8 +2387,8 @@ class Site extends BaseController
try {
$arrSummary = DomainExternalSeoBaiduProviderPlanHelper::buildSummary($this->bootstrapCodeRoot());
$arrSummary = DomainExternalSeoBaiduProviderPlanHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取百度 provider 计划失败:' . $Throwable->getMessage());
@@ -2389,8 +2401,8 @@ class Site extends BaseController
$intLimit = max(1, min(200, (int)$Request->get('limit', 50)));
$arrSummary = DomainExternalSeoBaiduPushSummaryHelper::buildSummary($this->bootstrapCodeRoot(), $intLimit);
$arrSummary = DomainExternalSeoBaiduPushSummaryHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取百度推送观察摘要失败:' . $Throwable->getMessage());
@@ -2439,8 +2451,8 @@ class Site extends BaseController
$intLimit = max(1, min(300, (int)$Request->get('limit', 100)));
$arrQueue = DomainExternalSeoBaiduPushAttentionQueueHelper::buildQueue($this->bootstrapCodeRoot(), $intLimit);
$arrQueue = DomainExternalSeoBaiduPushAttentionQueueHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrQueue);
$arrQueue['summary_json_path'] = $this->publicRelativePath((string)($arrQueue['summary_json_path'] ?? ''));
$arrQueue['summary_html_path'] = $this->publicRelativePath((string)($arrQueue['summary_html_path'] ?? ''));
$arrQueue['summary_json_path'] = $this->storageRelativePath((string)($arrQueue['summary_json_path'] ?? ''));
$arrQueue['summary_html_path'] = $this->storageRelativePath((string)($arrQueue['summary_html_path'] ?? ''));
return $this->success($arrQueue);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取百度推送异常队列失败:' . $Throwable->getMessage());
@@ -2453,8 +2465,8 @@ class Site extends BaseController
$intLimit = max(1, min(100, (int)$Request->get('limit', 20)));
$arrSummary = DomainExternalSeoBaiduPushTrendHelper::buildSummary($this->bootstrapCodeRoot(), $intLimit);
$arrSummary = DomainExternalSeoBaiduPushTrendHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取百度推送趋势摘要失败:' . $Throwable->getMessage());
@@ -2467,8 +2479,8 @@ class Site extends BaseController
$intLimit = max(1, min(100, (int)$Request->get('limit', 20)));
$arrSummary = DomainExternalSeoBaiduFeedbackSummaryHelper::buildSummary($this->bootstrapCodeRoot(), $intLimit);
$arrSummary = DomainExternalSeoBaiduFeedbackSummaryHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取百度反馈摘要失败:' . $Throwable->getMessage());
@@ -2481,8 +2493,8 @@ class Site extends BaseController
$intLimit = max(1, min(100, (int)$Request->get('limit', 20)));
$arrSummary = DomainExternalSeoSiteQueryProbeHelper::buildSummary($this->bootstrapCodeRoot(), $intLimit);
$arrSummary = DomainExternalSeoSiteQueryProbeHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取百度 site: 收录探测失败:' . $Throwable->getMessage());
@@ -2509,8 +2521,8 @@ class Site extends BaseController
$intLimit = max(1, min(300, (int)$Request->get('limit', 100)));
$arrQueue = DomainExternalSeoAizhanKeywordAttentionQueueHelper::buildQueue($this->bootstrapCodeRoot(), $intLimit);
$arrQueue = DomainExternalSeoAizhanKeywordAttentionQueueHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrQueue);
$arrQueue['summary_json_path'] = $this->publicRelativePath((string)($arrQueue['summary_json_path'] ?? ''));
$arrQueue['summary_html_path'] = $this->publicRelativePath((string)($arrQueue['summary_html_path'] ?? ''));
$arrQueue['summary_json_path'] = $this->storageRelativePath((string)($arrQueue['summary_json_path'] ?? ''));
$arrQueue['summary_html_path'] = $this->storageRelativePath((string)($arrQueue['summary_html_path'] ?? ''));
return $this->success($arrQueue);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取爱站关键词异常队列失败:' . $Throwable->getMessage());
@@ -2523,8 +2535,8 @@ class Site extends BaseController
$intLimit = max(1, min(100, (int)$Request->get('limit', 20)));
$arrSummary = DomainExternalSeoAizhanKeywordTrendHelper::buildSummary($this->bootstrapCodeRoot(), $intLimit);
$arrSummary = DomainExternalSeoAizhanKeywordTrendHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取爱站关键词趋势摘要失败:' . $Throwable->getMessage());
@@ -2568,40 +2580,40 @@ class Site extends BaseController
$arrResult = DomainExternalSeoSnapshotHelper::ingestSnapshots((array)$arrSnapshots, $strSource);
$strRunRoot = DomainExternalSeoSnapshotRunHelper::createRunRoot($this->domainExternalSeoSnapshotRunRoot(), 'snapshot_push');
$arrResult = DomainExternalSeoSnapshotRunHelper::writeRunArtifacts(
$this->bootstrapCodeRoot() . '/public',
$this->bootstrapCodeRoot() . '/storage',
$strRunRoot,
$arrResult,
(array)$arrSnapshots
);
$arrResult['run_root'] = $this->publicRelativePath($strRunRoot);
$arrResult['summary_json_path'] = $this->publicRelativePath((string)($arrResult['summary_json_path'] ?? ''));
$arrResult['summary_html_path'] = $this->publicRelativePath((string)($arrResult['summary_html_path'] ?? ''));
$arrResult['payload_json_path'] = $this->publicRelativePath((string)($arrResult['payload_json_path'] ?? ''));
$arrResult['run_root'] = $this->storageRelativePath($strRunRoot);
$arrResult['summary_json_path'] = $this->storageRelativePath((string)($arrResult['summary_json_path'] ?? ''));
$arrResult['summary_html_path'] = $this->storageRelativePath((string)($arrResult['summary_html_path'] ?? ''));
$arrResult['payload_json_path'] = $this->storageRelativePath((string)($arrResult['payload_json_path'] ?? ''));
$arrOverview = DomainExternalSeoCnOverviewHelper::buildOverview(14, 10);
$arrOverview = DomainExternalSeoCnOverviewHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrOverview);
$arrOverview['summary_json_path'] = $this->publicRelativePath((string)($arrOverview['summary_json_path'] ?? ''));
$arrOverview['summary_html_path'] = $this->publicRelativePath((string)($arrOverview['summary_html_path'] ?? ''));
$arrOverview['summary_json_path'] = $this->storageRelativePath((string)($arrOverview['summary_json_path'] ?? ''));
$arrOverview['summary_html_path'] = $this->storageRelativePath((string)($arrOverview['summary_html_path'] ?? ''));
$arrSnapshotTrend = DomainExternalSeoSnapshotTrendHelper::buildSummary($this->domainExternalSeoSnapshotRunRoot(), 10);
$arrSnapshotTrend = DomainExternalSeoSnapshotTrendHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSnapshotTrend);
$arrSnapshotTrend['summary_json_path'] = $this->publicRelativePath((string)($arrSnapshotTrend['summary_json_path'] ?? ''));
$arrSnapshotTrend['summary_html_path'] = $this->publicRelativePath((string)($arrSnapshotTrend['summary_html_path'] ?? ''));
$arrSnapshotTrend['summary_json_path'] = $this->storageRelativePath((string)($arrSnapshotTrend['summary_json_path'] ?? ''));
$arrSnapshotTrend['summary_html_path'] = $this->storageRelativePath((string)($arrSnapshotTrend['summary_html_path'] ?? ''));
$arrResult['post_ingest_overview'] = $arrOverview;
$arrResult['post_ingest_snapshot_trend'] = $arrSnapshotTrend;
$arrResult = DomainExternalSeoSnapshotRunHelper::writeRunArtifacts(
$this->bootstrapCodeRoot() . '/public',
$this->bootstrapCodeRoot() . '/storage',
$strRunRoot,
$arrResult,
(array)$arrSnapshots
);
$arrResult['summary_json_path'] = $this->publicRelativePath((string)($arrResult['summary_json_path'] ?? ''));
$arrResult['summary_html_path'] = $this->publicRelativePath((string)($arrResult['summary_html_path'] ?? ''));
$arrResult['payload_json_path'] = $this->publicRelativePath((string)($arrResult['payload_json_path'] ?? ''));
$arrResult['summary_json_path'] = $this->storageRelativePath((string)($arrResult['summary_json_path'] ?? ''));
$arrResult['summary_html_path'] = $this->storageRelativePath((string)($arrResult['summary_html_path'] ?? ''));
$arrResult['payload_json_path'] = $this->storageRelativePath((string)($arrResult['payload_json_path'] ?? ''));
$arrSnapshotTrend = DomainExternalSeoSnapshotTrendHelper::buildSummary($this->domainExternalSeoSnapshotRunRoot(), 10);
$arrSnapshotTrend = DomainExternalSeoSnapshotTrendHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSnapshotTrend);
$arrSnapshotTrend['summary_json_path'] = $this->publicRelativePath((string)($arrSnapshotTrend['summary_json_path'] ?? ''));
$arrSnapshotTrend['summary_html_path'] = $this->publicRelativePath((string)($arrSnapshotTrend['summary_html_path'] ?? ''));
$arrSnapshotTrend['summary_json_path'] = $this->storageRelativePath((string)($arrSnapshotTrend['summary_json_path'] ?? ''));
$arrSnapshotTrend['summary_html_path'] = $this->storageRelativePath((string)($arrSnapshotTrend['summary_html_path'] ?? ''));
$arrResult['post_ingest_snapshot_trend'] = $arrSnapshotTrend;
return $this->success($arrResult);
} catch (\Throwable $Throwable) {
@@ -2651,15 +2663,15 @@ class Site extends BaseController
$arrResult = DomainExternalSeoSnapshotSchemaHelper::validateSnapshots((array)$arrSnapshots);
$strRunRoot = DomainExternalSeoSnapshotValidateRunHelper::createRunRoot($this->domainExternalSeoSnapshotValidateRunRoot(), 'snapshot_validate');
$arrResult = DomainExternalSeoSnapshotValidateRunHelper::writeRunArtifacts(
$this->bootstrapCodeRoot() . '/public',
$this->bootstrapCodeRoot() . '/storage',
$strRunRoot,
$arrResult,
(array)$arrSnapshots
);
$arrResult['run_root'] = $this->publicRelativePath($strRunRoot);
$arrResult['summary_json_path'] = $this->publicRelativePath((string)($arrResult['summary_json_path'] ?? ''));
$arrResult['summary_html_path'] = $this->publicRelativePath((string)($arrResult['summary_html_path'] ?? ''));
$arrResult['payload_json_path'] = $this->publicRelativePath((string)($arrResult['payload_json_path'] ?? ''));
$arrResult['run_root'] = $this->storageRelativePath($strRunRoot);
$arrResult['summary_json_path'] = $this->storageRelativePath((string)($arrResult['summary_json_path'] ?? ''));
$arrResult['summary_html_path'] = $this->storageRelativePath((string)($arrResult['summary_html_path'] ?? ''));
$arrResult['payload_json_path'] = $this->storageRelativePath((string)($arrResult['payload_json_path'] ?? ''));
return $this->success($arrResult);
} catch (\Throwable $Throwable) {
@@ -2944,8 +2956,8 @@ class Site extends BaseController
$intDays = max(1, min(30, (int)$Request->get('days', 7)));
$arrSummary = DomainExternalSeoRealSummaryHelper::buildSummary($this->bootstrapCodeRoot(), $intDays);
$arrSummary = DomainExternalSeoRealSummaryHelper::writeArtifacts($this->domainExternalSeoSummaryRoot(), $arrSummary);
$arrSummary['summary_json_path'] = $this->publicRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->publicRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
$arrSummary['summary_json_path'] = $this->storageRelativePath((string)($arrSummary['summary_json_path'] ?? ''));
$arrSummary['summary_html_path'] = $this->storageRelativePath((string)($arrSummary['summary_html_path'] ?? ''));
return $this->success($arrSummary);
} catch (\Throwable $Throwable) {
return $this->error('9999', '读取真实站外 summary 骨架失败:' . $Throwable->getMessage());
@@ -3021,8 +3033,8 @@ class Site extends BaseController
'real_metrics_available' => !empty($arrRealSummary['real_metrics_available']),
'real_summary_provider' => (string)($arrRealSummary['provider_key'] ?? ''),
'metrics' => (array)($arrRealSummary['metrics'] ?? []),
'summary_json_path' => $this->publicRelativePath((string)($arrRealSummary['summary_json_path'] ?? '')),
'summary_html_path' => $this->publicRelativePath((string)($arrRealSummary['summary_html_path'] ?? '')),
'summary_json_path' => $this->storageRelativePath((string)($arrRealSummary['summary_json_path'] ?? '')),
'summary_html_path' => $this->storageRelativePath((string)($arrRealSummary['summary_html_path'] ?? '')),
]);
} catch (\Throwable $Throwable) {
return $this->error('9999', '导入站外手工报表失败:' . $Throwable->getMessage());

View File

@@ -35,17 +35,17 @@ class SeoCollector extends BaseController
protected function summaryRoot(): string
{
return $this->publicRoot() . '/_admin_templates/domain-seo-external/latest';
return $this->storageRoot() . '/external-seo/latest';
}
protected function snapshotRunRoot(): string
{
return $this->publicRoot() . '/_admin_templates/domain-seo-external/snapshot-runs';
return $this->storageRoot() . '/external-seo/snapshot-runs';
}
protected function snapshotValidateRunRoot(): string
{
return $this->publicRoot() . '/_admin_templates/domain-seo-external/snapshot-validate-runs';
return $this->storageRoot() . '/external-seo/snapshot-validate-runs';
}
protected function spiderCrawlLatestRoot(): string
@@ -138,15 +138,15 @@ class SeoCollector extends BaseController
$result = DomainExternalSeoSnapshotSchemaHelper::validateSnapshots((array)$snapshots);
$runRoot = DomainExternalSeoSnapshotValidateRunHelper::createRunRoot($this->snapshotValidateRunRoot(), 'snapshot_validate');
$result = DomainExternalSeoSnapshotValidateRunHelper::writeRunArtifacts(
$this->publicRoot(),
$this->storageRoot(),
$runRoot,
$result,
(array)$snapshots
);
$result['run_root'] = $this->publicRelativePath($runRoot);
$result['summary_json_path'] = $this->publicRelativePath((string)($result['summary_json_path'] ?? ''));
$result['summary_html_path'] = $this->publicRelativePath((string)($result['summary_html_path'] ?? ''));
$result['payload_json_path'] = $this->publicRelativePath((string)($result['payload_json_path'] ?? ''));
$result['run_root'] = $this->storageRelativePath($runRoot);
$result['summary_json_path'] = $this->storageRelativePath((string)($result['summary_json_path'] ?? ''));
$result['summary_html_path'] = $this->storageRelativePath((string)($result['summary_html_path'] ?? ''));
$result['payload_json_path'] = $this->storageRelativePath((string)($result['payload_json_path'] ?? ''));
return $this->success($result);
} catch (\Throwable $throwable) {
@@ -166,37 +166,37 @@ class SeoCollector extends BaseController
$result = DomainExternalSeoSnapshotHelper::ingestSnapshots((array)$snapshots, $source);
$runRoot = DomainExternalSeoSnapshotRunHelper::createRunRoot($this->snapshotRunRoot(), 'snapshot_push');
$result = DomainExternalSeoSnapshotRunHelper::writeRunArtifacts(
$this->publicRoot(),
$this->storageRoot(),
$runRoot,
$result,
(array)$snapshots
);
$result['run_root'] = $this->publicRelativePath($runRoot);
$result['summary_json_path'] = $this->publicRelativePath((string)($result['summary_json_path'] ?? ''));
$result['summary_html_path'] = $this->publicRelativePath((string)($result['summary_html_path'] ?? ''));
$result['payload_json_path'] = $this->publicRelativePath((string)($result['payload_json_path'] ?? ''));
$result['run_root'] = $this->storageRelativePath($runRoot);
$result['summary_json_path'] = $this->storageRelativePath((string)($result['summary_json_path'] ?? ''));
$result['summary_html_path'] = $this->storageRelativePath((string)($result['summary_html_path'] ?? ''));
$result['payload_json_path'] = $this->storageRelativePath((string)($result['payload_json_path'] ?? ''));
$overview = DomainExternalSeoCnOverviewHelper::buildOverview(14, 10);
$overview = DomainExternalSeoCnOverviewHelper::writeArtifacts($this->summaryRoot(), $overview);
$overview['summary_json_path'] = $this->publicRelativePath((string)($overview['summary_json_path'] ?? ''));
$overview['summary_html_path'] = $this->publicRelativePath((string)($overview['summary_html_path'] ?? ''));
$overview['summary_json_path'] = $this->storageRelativePath((string)($overview['summary_json_path'] ?? ''));
$overview['summary_html_path'] = $this->storageRelativePath((string)($overview['summary_html_path'] ?? ''));
$snapshotTrend = DomainExternalSeoSnapshotTrendHelper::buildSummary($this->snapshotRunRoot(), 10);
$snapshotTrend = DomainExternalSeoSnapshotTrendHelper::writeArtifacts($this->summaryRoot(), $snapshotTrend);
$snapshotTrend['summary_json_path'] = $this->publicRelativePath((string)($snapshotTrend['summary_json_path'] ?? ''));
$snapshotTrend['summary_html_path'] = $this->publicRelativePath((string)($snapshotTrend['summary_html_path'] ?? ''));
$snapshotTrend['summary_json_path'] = $this->storageRelativePath((string)($snapshotTrend['summary_json_path'] ?? ''));
$snapshotTrend['summary_html_path'] = $this->storageRelativePath((string)($snapshotTrend['summary_html_path'] ?? ''));
$result['post_ingest_overview'] = $overview;
$result['post_ingest_snapshot_trend'] = $snapshotTrend;
$result = DomainExternalSeoSnapshotRunHelper::writeRunArtifacts(
$this->publicRoot(),
$this->storageRoot(),
$runRoot,
$result,
(array)$snapshots
);
$result['summary_json_path'] = $this->publicRelativePath((string)($result['summary_json_path'] ?? ''));
$result['summary_html_path'] = $this->publicRelativePath((string)($result['summary_html_path'] ?? ''));
$result['payload_json_path'] = $this->publicRelativePath((string)($result['payload_json_path'] ?? ''));
$result['summary_json_path'] = $this->storageRelativePath((string)($result['summary_json_path'] ?? ''));
$result['summary_html_path'] = $this->storageRelativePath((string)($result['summary_html_path'] ?? ''));
$result['payload_json_path'] = $this->storageRelativePath((string)($result['payload_json_path'] ?? ''));
return $this->success($result);
} catch (\Throwable $throwable) {

View File

@@ -6,12 +6,12 @@ namespace app\common\helper;
class DomainExternalSeoSnapshotRunIndexHelper
{
protected static function publicRelativePath(string $strPath): string
protected static function storageRelativePath(string $strPath): string
{
$strPublicRoot = str_replace('\\', '/', rtrim(dirname(__DIR__, 3) . '/public', '/'));
$strStorageRoot = str_replace('\\', '/', rtrim(dirname(__DIR__, 3) . '/storage', '/'));
$strPath = str_replace('\\', '/', $strPath);
if (str_starts_with($strPath, $strPublicRoot . '/')) {
return substr($strPath, strlen($strPublicRoot . '/'));
if (str_starts_with($strPath, $strStorageRoot . '/')) {
return substr($strPath, strlen($strStorageRoot . '/'));
}
return $strPath;
@@ -60,7 +60,7 @@ class DomainExternalSeoSnapshotRunIndexHelper
$arrItems[] = [
'run_id' => basename($strRunRoot),
'run_root_public' => self::publicRelativePath($strRunRoot),
'run_root_public' => self::storageRelativePath($strRunRoot),
'source' => (string)($arrSummary['source'] ?? ''),
'received_count' => $intReceivedCount,
'inserted_count' => (int)($arrSummary['inserted_count'] ?? 0),
@@ -82,9 +82,9 @@ class DomainExternalSeoSnapshotRunIndexHelper
'post_ingest_snapshot_trend' => (array)($arrSummary['post_ingest_snapshot_trend'] ?? []),
'post_ingest_health_label' => (string)(($arrSummary['post_ingest_overview']['health_label'] ?? '')),
'post_ingest_trend_label' => (string)(($arrSummary['post_ingest_snapshot_trend']['success_trend']['label'] ?? '')),
'summary_json_path' => self::publicRelativePath($strSummaryPath),
'summary_html_path' => self::publicRelativePath($strRunRoot . '/snapshot-ingest.summary.html'),
'payload_json_path' => self::publicRelativePath($strRunRoot . '/snapshots.payload.json'),
'summary_json_path' => self::storageRelativePath($strSummaryPath),
'summary_html_path' => self::storageRelativePath($strRunRoot . '/snapshot-ingest.summary.html'),
'payload_json_path' => self::storageRelativePath($strRunRoot . '/snapshots.payload.json'),
'updated_at' => date(DATE_ATOM, (int)(filemtime($strSummaryPath) ?: time())),
];
}

View File

@@ -6,12 +6,12 @@ namespace app\common\helper;
class DomainExternalSeoSnapshotValidateRunIndexHelper
{
protected static function publicRelativePath(string $strPath): string
protected static function storageRelativePath(string $strPath): string
{
$strPublicRoot = str_replace('\\', '/', rtrim(dirname(__DIR__, 3) . '/public', '/'));
$strStorageRoot = str_replace('\\', '/', rtrim(dirname(__DIR__, 3) . '/storage', '/'));
$strPath = str_replace('\\', '/', $strPath);
if (str_starts_with($strPath, $strPublicRoot . '/')) {
return substr($strPath, strlen($strPublicRoot . '/'));
if (str_starts_with($strPath, $strStorageRoot . '/')) {
return substr($strPath, strlen($strStorageRoot . '/'));
}
return $strPath;
@@ -50,7 +50,7 @@ class DomainExternalSeoSnapshotValidateRunIndexHelper
$arrItems[] = [
'run_id' => basename($strRunRoot),
'run_root_public' => self::publicRelativePath($strRunRoot),
'run_root_public' => self::storageRelativePath($strRunRoot),
'received_count' => $intReceivedCount,
'valid_count' => (int)($arrSummary['valid_count'] ?? 0),
'error_count' => $intErrorCount,
@@ -63,9 +63,9 @@ class DomainExternalSeoSnapshotValidateRunIndexHelper
'warnings' => (array)($arrSummary['warnings'] ?? []),
'error_buckets' => (array)($arrSummary['error_buckets'] ?? []),
'warning_buckets' => (array)($arrSummary['warning_buckets'] ?? []),
'summary_json_path' => self::publicRelativePath($strSummaryPath),
'summary_html_path' => self::publicRelativePath($strRunRoot . '/snapshot-validate.summary.html'),
'payload_json_path' => self::publicRelativePath($strRunRoot . '/snapshots.payload.json'),
'summary_json_path' => self::storageRelativePath($strSummaryPath),
'summary_html_path' => self::storageRelativePath($strRunRoot . '/snapshot-validate.summary.html'),
'payload_json_path' => self::storageRelativePath($strRunRoot . '/snapshots.payload.json'),
'updated_at' => date(DATE_ATOM, (int)(filemtime($strSummaryPath) ?: time())),
];
}

View File

@@ -1710,7 +1710,13 @@ class SiteStyle
{
if (!$domainRow) return null;
$raw = is_array($domainRow) ? ($domainRow['t_cfg'] ?? null) : ($domainRow->t_cfg ?? null);
return $raw ? json_decode($raw, true) : null;
if (is_array($raw)) {
return $raw;
}
if (!is_string($raw) || trim($raw) === '') {
return null;
}
return json_decode($raw, true);
}
private static function writeDbConfig($domainRow, array $cfg): void