功能:奖励发放聊天室公告 + 右下角 Toast 通知卡片
后端(AdminCommandController::reward):
- 新增聊天室公开公告消息(系统公告,所有在场用户可见)
- 接收者私信附带 toast_notification 字段触发前端小卡片
- 公告文案:「🪙 [职务人] 向 [目标] 发放了 [N] 枚奖励金币!」
前端:
- 新建 chat/partials/toast-notification.blade.php:
全局右下角 Toast 组件,window.chatToast.show() API
支持 title/message/icon/color/duration/action 配置
多条 Toast 从右下角向上堆叠,独立计时、独立关闭
- chat:message 事件监听中检测 toast_notification 字段,
自动弹出右下角通知卡片(仅接收方可见)
- showFriendToast 迁移至 window.chatToast.show(),
删除 80 行旧实现,代码量净减
- frame.blade.php 引入新 partial
DEVELOPMENT.md:
- 新增 §7.9 chatToast 完整文档(API、使用场景、迁移说明)
- 原 chatBanner 章节编号改为 §7.10
This commit is contained in:
@@ -545,17 +545,42 @@ class AdminCommandController extends Controller
|
||||
'remark' => "发放奖励金币 {$amount} 枚给 {$targetUsername}",
|
||||
]);
|
||||
|
||||
// 向聊天室发送悄悄话通知接收者
|
||||
// ① 聊天室公开公告(所有在场用户可见)
|
||||
$publicMsg = [
|
||||
'id' => $this->chatState->nextMessageId($roomId),
|
||||
'room_id' => $roomId,
|
||||
'from_user' => '系统公告',
|
||||
'to_user' => '',
|
||||
'content' => "🪙 <b>{$admin->username}</b>({$positionName})向 <b>{$targetUsername}</b> 发放了 <b>{$amount}</b> 枚奖励金币!",
|
||||
'is_secret' => false,
|
||||
'font_color' => '#d97706',
|
||||
'action' => '',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
$this->chatState->pushMessage($roomId, $publicMsg);
|
||||
broadcast(new MessageSent($roomId, $publicMsg));
|
||||
SaveMessageJob::dispatch($publicMsg);
|
||||
|
||||
// ② 接收者私信(含 toast_notification 触发右下角小卡片)
|
||||
$freshJjb = $target->fresh()->jjb;
|
||||
$msg = [
|
||||
'id' => $this->chatState->nextMessageId($roomId),
|
||||
'room_id' => $roomId,
|
||||
'from_user' => '系统',
|
||||
'to_user' => $targetUsername,
|
||||
'content' => "🎁 <b>{$admin->username}</b>({$position->name})向你发放了 <b>{$amount}</b> 枚金币奖励!当前金币:{$target->fresh()->jjb} 枚。",
|
||||
'content' => "🎁 <b>{$admin->username}</b>({$positionName})向你发放了 <b>{$amount}</b> 枚金币奖励!当前金币:{$freshJjb} 枚。",
|
||||
'is_secret' => true,
|
||||
'font_color' => '#d97706',
|
||||
'action' => '',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
// 前端 toast-notification 组件识别此字段,弹出右下角通知卡片
|
||||
'toast_notification' => [
|
||||
'title' => '🪙 奖励金币到账',
|
||||
'message' => "<b>{$admin->username}</b>({$positionName})向你发放了 <b>{$amount}</b> 枚金币!",
|
||||
'icon' => '🪙',
|
||||
'color' => '#f59e0b',
|
||||
'duration' => 8000,
|
||||
],
|
||||
];
|
||||
$this->chatState->pushMessage($roomId, $msg);
|
||||
broadcast(new MessageSent($roomId, $msg));
|
||||
|
||||
Reference in New Issue
Block a user