优化:禁言提示显示操作者 + 被禁言发言改用持久提示
- UserMuted 事件增加 operator 字段,禁言通知显示管理员名字 - 输入框 placeholder 显示操作者名字 - 被禁言用户发言时改为在包厢窗口显示红色持久提示(替代 alert 弹窗)
This commit is contained in:
@@ -32,6 +32,7 @@ class UserMuted implements ShouldBroadcast
|
||||
public readonly string $username,
|
||||
public readonly int $muteTime,
|
||||
public readonly string $message = '',
|
||||
public readonly string $operator = '',
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -54,12 +55,13 @@ class UserMuted implements ShouldBroadcast
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
$statusMessage = $this->message ?: ($this->muteTime > 0
|
||||
? "用户 [{$this->username}] 已被禁言 {$this->muteTime} 分钟。"
|
||||
? "管理员 [{$this->operator}] 已将 [{$this->username}] 禁言 {$this->muteTime} 分钟。"
|
||||
: "用户 [{$this->username}] 已被解除禁言。");
|
||||
|
||||
return [
|
||||
'username' => $this->username,
|
||||
'mute_time' => $this->muteTime,
|
||||
'operator' => $this->operator,
|
||||
'message' => $statusMessage,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -178,7 +178,12 @@ class AdminCommandController extends Controller
|
||||
SaveMessageJob::dispatch($msg);
|
||||
|
||||
// 广播禁言事件(前端禁用输入框)
|
||||
broadcast(new \App\Events\UserMuted($roomId, $targetUsername, $duration, "管理员 {$admin->username} 已将您禁言 {$duration} 分钟"));
|
||||
broadcast(new \App\Events\UserMuted(
|
||||
roomId: $roomId,
|
||||
username: $targetUsername,
|
||||
muteTime: $duration,
|
||||
operator: $admin->username,
|
||||
));
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => "已禁言 {$targetUsername} {$duration} 分钟"]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user