From 392f46769cf541a1d6f8bd4104372baa5ea29448 Mon Sep 17 00:00:00 2001 From: lkddi Date: Tue, 14 Apr 2026 21:59:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=A0=E9=87=91=E5=B8=81=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8F=B3=E4=B8=8B=E8=A7=92=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ChatController.php | 8 ++++++++ tests/Feature/ChatControllerTest.php | 3 +++ 2 files changed, 11 insertions(+) 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)