修复:管理操作下拉框添加警告和查看私聊选项
- input-bar 下拉新增 '⚠️ 警告' 和 '🔍 查看私聊' 选项 - executeAdminAction 增加 warn/whispers 的交互逻辑 - 修正 warn 参数名匹配后端(username/reason) - 所有操作项添加 emoji 图标提升辨识度
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user