feat: AI 任务同步执行、评论垃圾管理、会员导航分组、多 AI 配置
- 评论 AI 审核/文章润色改为同步执行(站点无 queue worker,任务曾永久卡队列, 导致垃圾评论滞留待审核、润色毫无效果);审核在响应结束后经 terminating 触发 - 评论表:修复 approve 闭包里误嵌入 recordUrl 的坏链;新增「非垃圾」恢复发布、 批量「标为垃圾」、工具栏「清空垃圾评论」;各操作补充通知反馈 - 会员套餐/订阅/订单移入新导航组「会员」 - LlmClient 支持多服务商 profile;AI 设置页可添加多个 AI 并为审核/润色/封面 分别指定服务商(不指定用默认配置);封面生成同步支持 profile - AI 设置页:润色改同步并即时展示结果,按钮加 loading;删除无 workerman 的 WebSocket 进度区块
This commit is contained in:
@@ -7,12 +7,15 @@ namespace App\Filament\Resources\Comments\Tables;
|
||||
|
||||
use App\Models\Comment;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class CommentsTable
|
||||
{
|
||||
@@ -74,21 +77,68 @@ class CommentsTable
|
||||
->color('success')
|
||||
->visible(fn (Comment $record) => $record->status !== 'published')
|
||||
->action(function (Comment $record): void {
|
||||
$record->update(['status' => 'published'])
|
||||
->recordUrl(null)
|
||||
->recordAction(null);
|
||||
$record->update(['status' => 'published']);
|
||||
$record->post?->increment('comment_count');
|
||||
Notification::make()->title('评论已通过')->success()->send();
|
||||
}),
|
||||
Action::make('spam')
|
||||
->label('垃圾')
|
||||
->icon('heroicon-o-x-mark')
|
||||
->color('danger')
|
||||
->visible(fn (Comment $record) => $record->status !== 'spam')
|
||||
->action(fn (Comment $record) => $record->update(['status' => 'spam'])),
|
||||
->action(function (Comment $record): void {
|
||||
if ($record->status === 'published') {
|
||||
$record->post?->decrement('comment_count');
|
||||
}
|
||||
$record->update(['status' => 'spam']);
|
||||
Notification::make()->title('已标记为垃圾评论')->success()->send();
|
||||
}),
|
||||
Action::make('notSpam')
|
||||
->label('非垃圾')
|
||||
->icon('heroicon-o-check-badge')
|
||||
->color('success')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('标记为非垃圾')
|
||||
->modalDescription('该评论将恢复为已发布状态。')
|
||||
->visible(fn (Comment $record) => $record->status === 'spam')
|
||||
->action(function (Comment $record): void {
|
||||
$record->update(['status' => 'published']);
|
||||
$record->post?->increment('comment_count');
|
||||
Notification::make()->title('已恢复发布')->success()->send();
|
||||
}),
|
||||
EditAction::make(),
|
||||
])
|
||||
->recordUrl(null)
|
||||
->recordAction(null)
|
||||
->toolbarActions([
|
||||
Action::make('purgeSpam')
|
||||
->label('清空垃圾评论')
|
||||
->icon('heroicon-o-trash')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('清空垃圾评论')
|
||||
->modalDescription(fn (): string => '将永久删除全部 '.Comment::query()->where('status', 'spam')->count().' 条垃圾评论,不可恢复。')
|
||||
->visible(fn (): bool => Comment::query()->where('status', 'spam')->exists())
|
||||
->action(function (): void {
|
||||
$count = Comment::query()->where('status', 'spam')->count();
|
||||
Comment::query()->where('status', 'spam')->delete();
|
||||
Notification::make()->title("已删除 {$count} 条垃圾评论")->success()->send();
|
||||
}),
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('markSpam')
|
||||
->label('标为垃圾')
|
||||
->icon('heroicon-o-x-mark')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->action(function (Collection $records): void {
|
||||
$records->each(function (Comment $record): void {
|
||||
if ($record->status === 'published') {
|
||||
$record->post?->decrement('comment_count');
|
||||
}
|
||||
$record->update(['status' => 'spam']);
|
||||
});
|
||||
Notification::make()->title('已标记 '.$records->count().' 条为垃圾评论')->success()->send();
|
||||
}),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user