修复:管理操作下拉框添加警告和查看私聊选项
- input-bar 下拉新增 '⚠️ 警告' 和 '🔍 查看私聊' 选项 - executeAdminAction 增加 warn/whispers 的交互逻辑 - 修正 warn 参数名匹配后端(username/reason) - 所有操作项添加 emoji 图标提升辨识度
This commit is contained in:
@@ -63,17 +63,23 @@
|
|||||||
<select id="admin-action-select"
|
<select id="admin-action-select"
|
||||||
style="font-size: 11px; padding: 1px 2px; border: 1px solid #8ab; border-radius: 2px; color: #c00;">
|
style="font-size: 11px; padding: 1px 2px; border: 1px solid #8ab; border-radius: 2px; color: #c00;">
|
||||||
<option value="">管理操作 ▾</option>
|
<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)
|
@if ($user->user_level >= $levelKick || $room->master == $user->username)
|
||||||
<option value="kick">踢出房间</option>
|
<option value="kick">👢 踢出房间</option>
|
||||||
@endif
|
@endif
|
||||||
@if ($user->user_level >= $levelMute || $room->master == $user->username)
|
@if ($user->user_level >= $levelMute || $room->master == $user->username)
|
||||||
<option value="mute">禁言</option>
|
<option value="mute">🔇 禁言</option>
|
||||||
@endif
|
@endif
|
||||||
@if ($user->user_level >= $levelBan)
|
@if ($user->user_level >= $levelBan)
|
||||||
<option value="ban">封号</option>
|
<option value="ban">🚫 封号</option>
|
||||||
@endif
|
@endif
|
||||||
@if ($user->user_level >= $levelBanip)
|
@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
|
@endif
|
||||||
</select>
|
</select>
|
||||||
<button type="button" onclick="executeAdminAction()"
|
<button type="button" onclick="executeAdminAction()"
|
||||||
|
|||||||
@@ -661,13 +661,29 @@
|
|||||||
|
|
||||||
// 操作名称映射
|
// 操作名称映射
|
||||||
const actionNames = {
|
const actionNames = {
|
||||||
|
warn: '警告',
|
||||||
kick: '踢出',
|
kick: '踢出',
|
||||||
mute: '禁言',
|
mute: '禁言',
|
||||||
ban: '封号',
|
ban: '封号',
|
||||||
banip: '封IP'
|
banip: '封IP',
|
||||||
|
whispers: '查看私聊'
|
||||||
};
|
};
|
||||||
const actionName = actionNames[action] || action;
|
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;
|
let duration = 5;
|
||||||
if (action === 'mute') {
|
if (action === 'mute') {
|
||||||
@@ -687,8 +703,18 @@
|
|||||||
room_id: window.chatContext.roomId
|
room_id: window.chatContext.roomId
|
||||||
};
|
};
|
||||||
if (action === 'mute') body.duration = duration;
|
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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute(
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute(
|
||||||
|
|||||||
Reference in New Issue
Block a user