feat: 后台侧边栏紧凑化(13rem + 自定义 CSS)+ 博客设置改 Tab 六分区(站点/外观/订阅SEO/评论/附件/维护),补回时间格式/评论排序/缩略图/水印等 sablog 设置项并接入实际使用
This commit is contained in:
@@ -29,7 +29,7 @@ class PostController extends Controller
|
||||
|
||||
$comments = $post->comments()
|
||||
->where('status', 'published')
|
||||
->latest('created_at')
|
||||
->orderBy('created_at', (int) blog_setting('comment_order', 1) === 1 ? 'asc' : 'desc')
|
||||
->paginate(20);
|
||||
|
||||
$contentHtml = $this->renderer->render($post);
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BlogSettings extends Page
|
||||
@@ -33,18 +33,35 @@ class BlogSettings extends Page
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill([
|
||||
// 站点
|
||||
'site_name' => Setting::get('site_name', config('blog.name')),
|
||||
'site_description' => Setting::get('site_description', config('blog.description')),
|
||||
'site_icp' => Setting::get('site_icp', config('blog.icp')),
|
||||
// 外观
|
||||
'active_theme' => Setting::get('active_theme', config('themes.default')),
|
||||
'per_page' => Setting::get('per_page', config('blog.per_page')),
|
||||
'list_shownum' => Setting::get('list_shownum', '50'),
|
||||
'listtime' => Setting::get('listtime', 'Y-m-d'),
|
||||
'normaltime' => Setting::get('normaltime', 'Y-m-d H:i'),
|
||||
// 订阅与 SEO
|
||||
'rss_num' => Setting::get('rss_num', config('blog.rss_num')),
|
||||
'rss_ttl' => Setting::get('rss_ttl', '30'),
|
||||
'seo_default_keywords' => Setting::get('seo_default_keywords', ''),
|
||||
'seo_default_description' => Setting::get('seo_default_description', ''),
|
||||
// 评论
|
||||
'comment_audit' => Setting::get('comment_audit', '0'),
|
||||
'comment_order' => Setting::get('comment_order', '1'),
|
||||
'comment_min_len' => Setting::get('comment_min_len', config('blog.comment_min_len')),
|
||||
'comment_max_len' => Setting::get('comment_max_len', config('blog.comment_max_len')),
|
||||
'comment_post_space' => Setting::get('comment_post_space', config('blog.comment_post_space')),
|
||||
'rss_num' => Setting::get('rss_num', config('blog.rss_num')),
|
||||
'seo_default_keywords' => Setting::get('seo_default_keywords', ''),
|
||||
'seo_default_description' => Setting::get('seo_default_description', ''),
|
||||
'comment_timeformat' => Setting::get('comment_timeformat', 'Y-m-d H:i'),
|
||||
// 附件
|
||||
'attachments_thumbs' => Setting::get('attachments_thumbs', '1'),
|
||||
'attachments_thumbs_size' => Setting::get('attachments_thumbs_size', '500x500'),
|
||||
'watermark' => Setting::get('watermark', '0'),
|
||||
'watermark_size' => Setting::get('watermark_size', '300x300'),
|
||||
'watermarktrans' => Setting::get('watermarktrans', '100'),
|
||||
// 维护
|
||||
'site_closed' => Setting::get('site_closed', '0'),
|
||||
'site_closed_note' => Setting::get('site_closed_note', ''),
|
||||
]);
|
||||
@@ -54,40 +71,59 @@ class BlogSettings extends Page
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('站点信息')
|
||||
->schema([
|
||||
TextInput::make('site_name')->label('站点名称')->required(),
|
||||
TextInput::make('site_description')->label('站点描述')->columnSpanFull(),
|
||||
TextInput::make('site_icp')->label('ICP 备案号'),
|
||||
]),
|
||||
Section::make('主题')
|
||||
->schema([
|
||||
Select::make('active_theme')
|
||||
->label('激活主题')
|
||||
->options(collect(app(\App\Blog\Support\ThemeManager::class)->all())->pluck('title', 'name')),
|
||||
]),
|
||||
Section::make('列表与订阅')
|
||||
->schema([
|
||||
TextInput::make('per_page')->label('每页文章数')->numeric(),
|
||||
TextInput::make('rss_num')->label('RSS 文章数')->numeric(),
|
||||
]),
|
||||
Section::make('评论')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Toggle::make('comment_audit')->label('新评论需审核')->default(false),
|
||||
TextInput::make('comment_min_len')->label('评论最短字数')->numeric(),
|
||||
TextInput::make('comment_max_len')->label('评论最长字数')->numeric(),
|
||||
TextInput::make('comment_post_space')->label('评论间隔(秒)')->numeric(),
|
||||
]),
|
||||
Section::make('SEO 默认值')
|
||||
->schema([
|
||||
TextInput::make('seo_default_keywords')->label('默认关键词'),
|
||||
TextInput::make('seo_default_description')->label('默认描述')->columnSpanFull(),
|
||||
]),
|
||||
Section::make('维护')
|
||||
->schema([
|
||||
Toggle::make('site_closed')->label('关闭站点')->default(false),
|
||||
TextInput::make('site_closed_note')->label('关闭说明'),
|
||||
Tabs::make('settings-tabs')
|
||||
->tabs([
|
||||
Tab::make('站点')
|
||||
->schema([
|
||||
TextInput::make('site_name')->label('站点名称')->required(),
|
||||
TextInput::make('site_description')->label('站点描述')->columnSpanFull(),
|
||||
TextInput::make('site_icp')->label('ICP 备案号'),
|
||||
]),
|
||||
Tab::make('外观')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('active_theme')
|
||||
->label('激活主题')
|
||||
->columnSpanFull()
|
||||
->options(collect(app(\App\Blog\Support\ThemeManager::class)->all())->pluck('title', 'name')),
|
||||
TextInput::make('per_page')->label('首页每页文章数')->numeric(),
|
||||
TextInput::make('list_shownum')->label('列表每页数量')->numeric()->helperText('分类/标签/搜索等列表页'),
|
||||
TextInput::make('listtime')->label('列表时间格式')->placeholder('Y-m-d'),
|
||||
TextInput::make('normaltime')->label('详情时间格式')->placeholder('Y-m-d H:i'),
|
||||
]),
|
||||
Tab::make('订阅与 SEO')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('rss_num')->label('RSS 文章数')->numeric(),
|
||||
TextInput::make('rss_ttl')->label('RSS TTL(分钟)')->numeric(),
|
||||
TextInput::make('seo_default_keywords')->label('默认关键词')->columnSpanFull(),
|
||||
TextInput::make('seo_default_description')->label('默认描述')->columnSpanFull(),
|
||||
]),
|
||||
Tab::make('评论')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Toggle::make('comment_audit')->label('新评论需审核')->default(false),
|
||||
Select::make('comment_order')->label('评论排序')
|
||||
->options(['1' => '正序(旧在前)', '0' => '倒序(新在前)']),
|
||||
TextInput::make('comment_min_len')->label('最短字数')->numeric(),
|
||||
TextInput::make('comment_max_len')->label('最长字数')->numeric(),
|
||||
TextInput::make('comment_post_space')->label('评论间隔(秒)')->numeric(),
|
||||
TextInput::make('comment_timeformat')->label('评论时间格式')->placeholder('Y-m-d H:i'),
|
||||
]),
|
||||
Tab::make('附件')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Toggle::make('attachments_thumbs')->label('生成缩略图')->default(true),
|
||||
TextInput::make('attachments_thumbs_size')->label('缩略图尺寸')->placeholder('500x500'),
|
||||
Toggle::make('watermark')->label('图片水印')->default(false),
|
||||
TextInput::make('watermark_size')->label('水印触发尺寸')->placeholder('300x300'),
|
||||
TextInput::make('watermarktrans')->label('水印透明度(%)')->numeric(),
|
||||
]),
|
||||
Tab::make('维护')
|
||||
->schema([
|
||||
Toggle::make('site_closed')->label('关闭站点')->default(false),
|
||||
TextInput::make('site_closed_note')->label('关闭说明')->columnSpanFull(),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->statePath('data');
|
||||
|
||||
+3
-2
@@ -95,9 +95,10 @@ class Post extends Model implements HasMedia
|
||||
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
[$tw, $th] = array_pad(explode('x', strtolower((string) blog_setting('attachments_thumbs_size', '500x500'))), 2, '500');
|
||||
$this->addMediaConversion('thumb')
|
||||
->width(500)
|
||||
->height(500)
|
||||
->width((int) $tw)
|
||||
->height((int) $th)
|
||||
->performOnCollections('attachments');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -26,5 +28,21 @@ class AppServiceProvider extends ServiceProvider
|
||||
foreach (glob(base_path('plugins/*/database/migrations')) ?: [] as $path) {
|
||||
$this->loadMigrationsFrom($path);
|
||||
}
|
||||
|
||||
// 后台侧边栏紧凑化(更窄的菜单项)
|
||||
Filament::serving(function () {
|
||||
Filament::registerRenderHook(
|
||||
PanelsRenderHook::STYLES_AFTER,
|
||||
fn () => Blade::render(<<<'HTML'
|
||||
<style>
|
||||
.fi-sidebar-nav { padding-inline: 0.4rem; }
|
||||
.fi-sidebar-nav .fi-sidebar-item-button { padding-inline: 0.6rem; border-radius: 0.5rem; }
|
||||
.fi-sidebar-nav .fi-sidebar-item-label { font-size: 0.82rem; }
|
||||
.fi-sidebar-nav .fi-sidebar-group-label { font-size: 0.68rem; letter-spacing: 0.04em; }
|
||||
.fi-sidebar-brand { padding-block: 0.9rem; }
|
||||
</style>
|
||||
HTML)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
'primary' => Color::Sky,
|
||||
])
|
||||
->brandName(config('blog.name'))
|
||||
->sidebarWidth('13rem')
|
||||
->navigationGroups([
|
||||
NavigationGroup::make('内容'),
|
||||
NavigationGroup::make('管理'),
|
||||
|
||||
Reference in New Issue
Block a user