- 任命/撤销事件增加 type 字段区分类型 - 任命:全屏礼花 + 紫色弹窗 + 紫色系统消息 - 撤销:灰色弹窗 + 灰色系统消息,无礼花 - 消息分发:操作者/被操作者显示在私聊面板,其他人显示在公屏 - 系统消息加随机鼓励语(各5条轮换) - ChatStateService 修复 Redis key 前缀扫描问题(getAllActiveRoomIds) - 用户名片折叠优化:管理员视野、职务履历均可折叠 - 管理操作 + 职务操作合并为「🔧 管理操作」折叠区 - 悄悄话改为「🎁 送礼物」按钮,礼物面板内联展开
74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:任命公告广播事件
|
|
* 任命操作成功后向对应聊天室 PresenceChannel 推送任命消息,
|
|
* 前端接收后展示全屏礼花动画和隆重公告弹窗。
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PresenceChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class AppointmentAnnounced implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* 构建任命公告事件
|
|
*
|
|
* @param int $roomId 广播目标房间 ID
|
|
* @param string $targetUsername 被任命用户名
|
|
* @param string $positionIcon 职务图标
|
|
* @param string $positionName 职务名称
|
|
* @param string $departmentName 所属部门名称
|
|
* @param string $operatorName 任命人用户名
|
|
*/
|
|
public function __construct(
|
|
public readonly int $roomId,
|
|
public readonly string $targetUsername,
|
|
public readonly string $positionIcon,
|
|
public readonly string $positionName,
|
|
public readonly string $departmentName,
|
|
public readonly string $operatorName,
|
|
public readonly string $type = 'appoint', // appoint | revoke
|
|
) {}
|
|
|
|
/**
|
|
* 广播至目标房间的 PresenceChannel
|
|
*
|
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
|
*/
|
|
public function broadcastOn(): array
|
|
{
|
|
return [
|
|
new PresenceChannel('room.'.$this->roomId),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 广播数据
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'type' => $this->type,
|
|
'target_username' => $this->targetUsername,
|
|
'position_icon' => $this->positionIcon,
|
|
'position_name' => $this->positionName,
|
|
'department_name' => $this->departmentName,
|
|
'operator_name' => $this->operatorName,
|
|
];
|
|
}
|
|
}
|