From a35789ec4c0ce8b428694614a32bc15c13791cbd Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 2 Nov 2026 15:05:01 +0800 Subject: [PATCH] Align free Shadowrocket ID category and article names --- .../Commands/AlignShadowrocketNaming.php | 35 +++++++++++++++++++ .../Controllers/Api/v1/ArticlesController.php | 2 ++ app/Services/ShadowrocketNaming.php | 11 ++++++ .../SHADOWROCKET_NAMING_2026-11-02.md | 7 ++++ .../pages/articles/appleid/header.blade.php | 4 +-- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 app/Console/Commands/AlignShadowrocketNaming.php create mode 100644 app/Services/ShadowrocketNaming.php create mode 100644 docs/maintenance/SHADOWROCKET_NAMING_2026-11-02.md diff --git a/app/Console/Commands/AlignShadowrocketNaming.php b/app/Console/Commands/AlignShadowrocketNaming.php new file mode 100644 index 00000000..278258c7 --- /dev/null +++ b/app/Console/Commands/AlignShadowrocketNaming.php @@ -0,0 +1,35 @@ +where('sSlug', 'shadowrocketids')->lockForUpdate()->sole(); + $rows = DB::table('articles')->where('iCategoryId', $category->id)->lockForUpdate()->get(['id', 'sTitle', 'sTitleSub']); + $changes = $rows->filter(fn ($r) => ShadowrocketNaming::align($r->sTitle) !== $r->sTitle || ShadowrocketNaming::align($r->sTitleSub ?? '') !== ($r->sTitleSub ?? '')); + if (! $this->option('apply')) return $changes->count(); + if ($changes->isEmpty() && $category->sName === '免费小火箭ID') return 0; + $directory = storage_path('app/private/category-backups'); + if (! is_dir($directory)) mkdir($directory, 0700, true); + $backup = $directory.'/shadowrocket-naming-'.Str::uuid().'.json'; + if (file_put_contents($backup, json_encode(['category' => $category, 'articles' => $rows], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)) === false) throw new \RuntimeException('Backup failed'); + chmod($backup, 0600); + DB::table('categories')->where('id', $category->id)->update(['sName' => '免费小火箭ID', 'sDescription' => ShadowrocketNaming::align($category->sDescription ?? '')]); + foreach ($changes as $row) DB::table('articles')->where('id', $row->id)->update(['sTitle' => ShadowrocketNaming::align($row->sTitle), 'sTitleSub' => ShadowrocketNaming::align($row->sTitleSub ?? '')]); + return $changes->count(); + }); + $this->info(json_encode(['apply' => (bool) $this->option('apply'), 'articles' => $count], JSON_UNESCAPED_UNICODE)); + return self::SUCCESS; + } +} diff --git a/app/Http/Controllers/Api/v1/ArticlesController.php b/app/Http/Controllers/Api/v1/ArticlesController.php index 6104c37e..cebeca22 100644 --- a/app/Http/Controllers/Api/v1/ArticlesController.php +++ b/app/Http/Controllers/Api/v1/ArticlesController.php @@ -114,6 +114,8 @@ public function receiveShadowrocketids(Request $oRequest) $sArticle = $aData["content"] ?? ''; $sTitle = $aData["title"] ?? ''; $sTitleSub = $aData["title_sub"] ?? ''; + $sTitle = \App\Services\ShadowrocketNaming::align($sTitle); + $sTitleSub = \App\Services\ShadowrocketNaming::align($sTitleSub); $aArticleTags = $aData["tags"] ?? []; $sSlug = 'ssi'.date("Ymd"); // $sImgAuthor = "tg_xiuren_a"; diff --git a/app/Services/ShadowrocketNaming.php b/app/Services/ShadowrocketNaming.php new file mode 100644 index 00000000..0282ab2e --- /dev/null +++ b/app/Services/ShadowrocketNaming.php @@ -0,0 +1,11 @@ +
-

{{ $oArticle->created_at?->format('n月j日') }}免费苹果ID

-

App Store 共享账号,按地区选择使用。

+

{{ $oArticle->created_at?->format('n月j日') }}免费小火箭ID

+

用于下载小火箭的 App Store 共享账号,按地区选择使用。

@if($oArticle->sThumb) 狗狗主题插画