修复:管理操作下拉框添加警告和查看私聊选项

- input-bar 下拉新增 '⚠️ 警告' 和 '🔍 查看私聊' 选项
- executeAdminAction 增加 warn/whispers 的交互逻辑
- 修正 warn 参数名匹配后端(username/reason)
- 所有操作项添加 emoji 图标提升辨识度
This commit is contained in:
2026-02-26 23:56:25 +08:00
parent 718d6901ac
commit ec76d39350
2 changed files with 38 additions and 6 deletions

View File

@@ -63,17 +63,23 @@
<select id="admin-action-select"
style="font-size: 11px; padding: 1px 2px; border: 1px solid #8ab; border-radius: 2px; color: #c00;">
<option value="">管理操作 </option>
@if ($user->user_level >= $levelWarn || $room->master == $user->username)
<option value="warn">⚠️ 警告</option>
@endif
@if ($user->user_level >= $levelKick || $room->master == $user->username)
<option value="kick">踢出房间</option>
<option value="kick">👢 踢出房间</option>
@endif
@if ($user->user_level >= $levelMute || $room->master == $user->username)
<option value="mute">禁言</option>
<option value="mute">🔇 禁言</option>
@endif
@if ($user->user_level >= $levelBan)
<option value="ban">封号</option>
<option value="ban">🚫 封号</option>
@endif
@if ($user->user_level >= $levelBanip)
<option value="banip">封IP</option>
<option value="banip">🔒 封IP</option>
@endif
@if ($user->user_level >= $levelKick || $room->master == $user->username)
<option value="whispers">🔍 查看私聊</option>
@endif
</select>
<button type="button" onclick="executeAdminAction()"

View File

@@ -661,13 +661,29 @@
// 操作名称映射
const actionNames = {
warn: '警告',
kick: '踢出',
mute: '禁言',
ban: '封号',
banip: '封IP'
banip: '封IP',
whispers: '查看私聊'
};
const actionName = actionNames[action] || action;
// 查看私聊:直接打开新窗口
if (action === 'whispers') {
window.open(`/command/whispers/${encodeURIComponent(targetUser)}`, '_blank');
select.value = '';
return;
}
// 警告需要输入内容
let warnMessage = '';
if (action === 'warn') {
warnMessage = prompt('请输入警告内容:', '请注意聊天室规则,文明发言!');
if (!warnMessage) return;
}
// 禁言需要输入时长
let duration = 5;
if (action === 'mute') {
@@ -687,8 +703,18 @@
room_id: window.chatContext.roomId
};
if (action === 'mute') body.duration = duration;
if (action === 'warn') body.reason = warnMessage;
const res = await fetch(`/user/${encodeURIComponent(targetUser)}/${action}`, {
// 警告走 /command/warn 路由,其他走 /user/{username}/{action}
let url;
if (action === 'warn') {
body.username = targetUser;
url = '/command/warn';
} else {
url = `/user/${encodeURIComponent(targetUser)}/${action}`;
}
const res = await fetch(url, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute(