Keep the public site readable after import (nbsp, highlighter, wrapping code, compact pager) and finish the admin extras already in this tree: sticky levels, preview, page cache, and live llms.txt. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Blog\Support\PageCacheMiddleware;
|
|
use App\Filament\Pages\PageCache;
|
|
use App\Models\Comment;
|
|
use App\Models\Post;
|
|
use App\Models\User;
|
|
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
|
|
class BlogStats extends BaseWidget
|
|
{
|
|
protected static ?int $sort = 1;
|
|
|
|
protected function getStats(): array
|
|
{
|
|
$cache = PageCacheMiddleware::stats();
|
|
|
|
return [
|
|
Stat::make('文章', Post::published()->count())
|
|
->description('总浏览量 '.number_format((float) Post::sum('views')))
|
|
->icon('heroicon-o-document-text'),
|
|
Stat::make('评论', Comment::query()->where('status', 'published')->count())
|
|
->description('待审核 '.Comment::query()->where('status', 'pending')->count())
|
|
->icon('heroicon-o-chat-bubble-left-right'),
|
|
Stat::make('用户', User::count())
|
|
->icon('heroicon-o-users'),
|
|
Stat::make('页面缓存', $cache['count'].' 条')
|
|
->description('命中率 '.$cache['rate'].'%(命中 '.$cache['hits'].' / 未命中 '.$cache['misses'].',按日滚动)')
|
|
->url(PageCache::getUrl())
|
|
->icon('heroicon-o-bolt'),
|
|
];
|
|
}
|
|
}
|