feat: 前台整页响应缓存(匿名 GET,浏览量走 track-view 独立端点)+ 后台缓存管理页 + 侧边栏 nav-groups 负 margin 归零

This commit is contained in:
ak
2026-08-11 21:53:09 +08:00
parent a5429b3ea4
commit 7622cd8e2a
21 changed files with 317 additions and 1 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace App\Filament\Pages;
use App\Blog\Support\PageCacheMiddleware;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
class CacheManager extends Page
{
protected static \UnitEnum|string|null $navigationGroup = '管理';
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-bolt';
protected static ?string $navigationLabel = '缓存管理';
protected string $view = 'filament.pages.cache-manager';
public function flushPages(): void
{
PageCacheMiddleware::flush();
Notification::make()->title('前台页面缓存已清空')->success()->send();
}
public function flushSidebar(): void
{
foreach (['blog.sidebar.categories', 'blog.sidebar.recent_posts', 'blog.sidebar.recent_comments', 'blog.sidebar.hot_tags', 'blog.sidebar.links', 'blog.sidebar.stats'] as $key) {
Cache::forget($key);
}
Notification::make()->title('侧边栏缓存已清空')->success()->send();
}
public function flushSettings(): void
{
\App\Models\Setting::flushCache();
Cache::forget('attach.legacy_ids');
Notification::make()->title('设置缓存已清空')->success()->send();
}
public function flushAll(): void
{
PageCacheMiddleware::flush();
\App\Models\Setting::flushCache();
Cache::flush();
Notification::make()->title('全部缓存已清空')->success()->send();
}
public function recompile(): void
{
Artisan::call('view:clear');
Artisan::call('route:clear');
Artisan::call('config:clear');
Notification::make()->title('视图/路由/配置缓存已重建')->success()->send();
}
public function getPageCacheCountProperty(): int
{
return PageCacheMiddleware::count();
}
}