diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php index 6d93e3e..f19bf6b 100644 --- a/app/Http/Controllers/ChatController.php +++ b/app/Http/Controllers/ChatController.php @@ -1298,6 +1298,14 @@ class ChatController extends Controller 'font_color' => '#b45309', 'action' => '', 'sent_at' => now()->toDateTimeString(), + // 接收方收到消息时,在右下角弹到账提示卡片。 + 'toast_notification' => [ + 'title' => '💰 赠金币到账', + 'message' => "{$sender->username} 向你赠送了 {$amount} 枚金币!", + 'icon' => '💰', + 'color' => '#f59e0b', + 'duration' => 8000, + ], ]; // 推入 Redis + WebSocket + 异步落库,保持与普通私聊一致的展示与历史记录行为。 diff --git a/tests/Feature/ChatControllerTest.php b/tests/Feature/ChatControllerTest.php index 79e700a..95163bc 100644 --- a/tests/Feature/ChatControllerTest.php +++ b/tests/Feature/ChatControllerTest.php @@ -309,6 +309,9 @@ class ChatControllerTest extends TestCase $this->assertNotNull($giftMessage); $this->assertTrue((bool) ($giftMessage['is_secret'] ?? false)); + $this->assertSame('💰 赠金币到账', $giftMessage['toast_notification']['title'] ?? null); + $this->assertSame('💰', $giftMessage['toast_notification']['icon'] ?? null); + $this->assertSame('#f59e0b', $giftMessage['toast_notification']['color'] ?? null); // 赠送方查看房间历史时,应保留这条私聊通知。 $senderHistory = $this->actingAs($sender)