清理:移除已废弃的 executeAdminAction 函数(约90行)
管理操作已迁移到名片弹窗(user-actions.blade.php),输入栏下拉也已移除
This commit is contained in:
@@ -584,97 +584,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ── 管理操作执行(下拉选择 + 目标用户) ─────────────
|
||||
async function executeAdminAction() {
|
||||
const select = document.getElementById('admin-action-select');
|
||||
if (!select) return;
|
||||
const action = select.value;
|
||||
if (!action) {
|
||||
alert('请先选择一个管理操作。');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取聊天对象下拉框中选中的用户作为目标
|
||||
const toUserSelect = document.getElementById('to_user');
|
||||
const targetUser = toUserSelect ? toUserSelect.value : '';
|
||||
|
||||
if (!targetUser || targetUser === '大家') {
|
||||
alert('请先在「对...说」下拉中选择要操作的用户。');
|
||||
return;
|
||||
}
|
||||
|
||||
// 操作名称映射
|
||||
const actionNames = {
|
||||
warn: '警告',
|
||||
kick: '踢出',
|
||||
mute: '禁言',
|
||||
ban: '封号',
|
||||
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') {
|
||||
const input = prompt('请输入禁言时长(分钟):', '5');
|
||||
if (!input) return;
|
||||
duration = parseInt(input) || 5;
|
||||
}
|
||||
|
||||
// 二次确认
|
||||
const confirmMsg = action === 'banip' ?
|
||||
`⚠️ 严重操作:确定要封禁 ${targetUser} 的IP地址吗?该用户将被封号+封IP!` :
|
||||
`确定要对 ${targetUser} 执行「${actionName}」操作吗?`;
|
||||
if (!confirm(confirmMsg)) return;
|
||||
|
||||
try {
|
||||
const body = {
|
||||
room_id: window.chatContext.roomId
|
||||
};
|
||||
if (action === 'mute') body.duration = duration;
|
||||
if (action === 'warn') body.reason = warnMessage;
|
||||
|
||||
// 警告走 /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(
|
||||
'content'),
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
});
|
||||
const data = await res.json();
|
||||
alert(data.message);
|
||||
} catch (e) {
|
||||
alert('操作失败:' + e.message);
|
||||
}
|
||||
select.value = ''; // 重置下拉
|
||||
}
|
||||
|
||||
// ── 设置房间公告 ─────────────────────────────────────
|
||||
async function promptAnnouncement() {
|
||||
|
||||
Reference in New Issue
Block a user