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.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\Posts\Pages;
|
|
|
|
use App\Filament\Resources\Posts\PostResource;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditPost extends EditRecord
|
|
{
|
|
protected static string $resource = PostResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('preview')
|
|
->label('预览')
|
|
->icon('heroicon-o-eye')
|
|
->color('gray')
|
|
->url(fn (): string => $this->record->url)
|
|
->openUrlInNewTab(),
|
|
DeleteAction::make(),
|
|
];
|
|
}
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
// 表单只包含部分 meta 键(插件注入的价格/会员标记等),合并保留其他插件写入的键(如解锁用户)
|
|
if (array_key_exists('meta', $data)) {
|
|
$data['meta'] = array_merge($this->record->meta ?? [], $data['meta'] ?? []);
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|