Просмотр исходного кода

fix(admin): allow clearing textbook covers

Persist empty cover list as null so removing all images can be saved, and show explicit cleared-state feedback after save.

Made-with: Cursor
yemeishu 1 месяц назад
Родитель
Сommit
5ef63c5076

+ 3 - 14
app/Filament/Resources/TextbookResource/Pages/ManageTextbookCovers.php

@@ -141,18 +141,6 @@ class ManageTextbookCovers extends Page
 
     public function saveCovers(): void
     {
-        if ($this->coverUrls === []) {
-            $this->saveFeedback = '当前没有可保存的配图,请先上传并加入列表。';
-            $this->saveFeedbackType = 'warning';
-
-            \Filament\Notifications\Notification::make()
-                ->title('暂无可保存图片')
-                ->warning()
-                ->send();
-
-            return;
-        }
-
         \Log::info('ManageTextbookCovers::saveCovers start', [
             'record_id' => $this->recordId,
             'count' => count($this->coverUrls),
@@ -192,11 +180,12 @@ class ManageTextbookCovers extends Page
             'saved_count' => count($this->coverUrls),
         ]);
 
-        $this->saveFeedback = '保存成功(' . now()->format('H:i:s') . ')';
+        $isCleared = ($this->coverUrls === []);
+        $this->saveFeedback = ($isCleared ? '已清空并保存' : '保存成功') . '(' . now()->format('H:i:s') . ')';
         $this->saveFeedbackType = 'success';
 
         \Filament\Notifications\Notification::make()
-            ->title('配图已保存')
+            ->title($isCleared ? '配图已清空' : '配图已保存')
             ->success()
             ->send();
     }