5f30220609
- 任命/撤销事件增加 type 字段区分类型 - 任命:全屏礼花 + 紫色弹窗 + 紫色系统消息 - 撤销:灰色弹窗 + 灰色系统消息,无礼花 - 消息分发:操作者/被操作者显示在私聊面板,其他人显示在公屏 - 系统消息加随机鼓励语(各5条轮换) - ChatStateService 修复 Redis key 前缀扫描问题(getAllActiveRoomIds) - 用户名片折叠优化:管理员视野、职务履历均可折叠 - 管理操作 + 职务操作合并为「🔧 管理操作」折叠区 - 悄悄话改为「🎁 送礼物」按钮,礼物面板内联展开
75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:开发日志发布广播事件
|
|
* 当管理员发布新的开发日志并勾选"通知大厅"时触发
|
|
* 广播至 Room ID=1(星光大厅)的 presence 频道
|
|
* 前端监听此事件并在聊天消息区显示系统通知(含可点击的查看详情链接)
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Models\DevChangelog;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PresenceChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class ChangelogPublished implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* 构造函数:传入触发通知的日志对象
|
|
*
|
|
* @param DevChangelog $changelog 刚发布的开发日志
|
|
*/
|
|
public function __construct(
|
|
public readonly DevChangelog $changelog,
|
|
) {}
|
|
|
|
/**
|
|
* 广播频道:仅向 Room 1(星光大厅)的 presence 频道广播
|
|
* 复用现有聊天室频道机制,无需额外配置
|
|
*
|
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
|
*/
|
|
public function broadcastOn(): array
|
|
{
|
|
return [
|
|
// 固定广播至 Room ID = 1 的大厅频道
|
|
new PresenceChannel('room.1'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 广播事件名称(前端 .listen('ChangelogPublished', ...) 监听此名称)
|
|
*/
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'ChangelogPublished';
|
|
}
|
|
|
|
/**
|
|
* 广播携带的数据(前端可直接访问)
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'version' => $this->changelog->version,
|
|
'title' => $this->changelog->title,
|
|
'type' => $this->changelog->type,
|
|
'type_label' => $this->changelog->type_label,
|
|
// 前端点击后跳转的目标 URL,自动锚定至对应版本
|
|
'url' => url('/changelog').'#v'.$this->changelog->version,
|
|
];
|
|
}
|
|
}
|