Files
laralog/app/Filament/Pages/PageCache.php
T
gouki d041622531
Build and Deploy / verify (push) Successful in 10s
Build and Deploy / deploy (push) Successful in 17s
feat: post cover filter + admin AI cover action, restyle page-cache admin
- 抽 CoverGenerator 服务(covers:generate 与后台共用),内部强制同步产出 card 转换
- 文章列表:新增封面状态图标列、「有/无封面/完全无图」筛选、行内「生成封面」AI 操作
- 页面缓存:统计改为原生 StatsOverviewWidget(缓存页数/总大小/命中率/时长),
  缓存明细表重排(表头、悬停、URL 截断、图标删除按钮、空状态)
2026-10-14 23:48:57 +00:00

91 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Pages;
use App\Blog\Support\PageCacheMiddleware;
use App\Filament\Widgets\PageCacheStats;
use App\Models\Setting;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Cache;
class PageCache extends Page
{
protected static \UnitEnum|string|null $navigationGroup = '管理';
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-bolt';
protected static ?string $navigationLabel = '页面缓存';
protected static ?string $title = '页面缓存';
protected static ?string $slug = 'page-cache';
protected static ?int $navigationSort = 20;
protected string $view = 'filament.pages.page-cache';
/**
* @return list<array{key: string, url: string, cached_at: string, size: int, expires_at: string}>
*/
public function getEntriesProperty(): array
{
return PageCacheMiddleware::entries();
}
public function flushPageCache(): void
{
PageCacheMiddleware::flush();
Notification::make()->title('前台页面缓存已清空')->success()->send();
}
public function flushAllCache(): void
{
PageCacheMiddleware::flush();
Setting::flushCache();
Cache::flush();
Notification::make()->title('全部缓存已清空')->success()->send();
}
public function resetStats(): void
{
PageCacheMiddleware::resetStats();
Notification::make()->title('命中统计已重置')->success()->send();
}
public function forgetEntry(string $key): void
{
PageCacheMiddleware::forget($key);
Notification::make()->title('已删除这条缓存')->success()->send();
}
protected function getHeaderWidgets(): array
{
return [
PageCacheStats::class,
];
}
protected function getHeaderActions(): array
{
return [
Action::make('resetStats')
->label('重置统计')
->color('gray')
->action(fn () => $this->resetStats()),
Action::make('flushPageCache')
->label('清空前台缓存')
->color('warning')
->action(fn () => $this->flushPageCache()),
Action::make('flushAllCache')
->label('清空全部缓存')
->color('danger')
->requiresConfirmation()
->action(fn () => $this->flushAllCache()),
];
}
}