优化:禁言提示显示操作者 + 被禁言发言改用持久提示

- UserMuted 事件增加 operator 字段,禁言通知显示管理员名字
- 输入框 placeholder 显示操作者名字
- 被禁言用户发言时改为在包厢窗口显示红色持久提示(替代 alert 弹窗)
This commit is contained in:
2026-02-26 23:12:55 +08:00
parent 66f68bab85
commit 2d45e52591
3 changed files with 22 additions and 4 deletions
+3 -1
View File
@@ -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} 分钟"]);
}