重构:双击用户名统一走 openUserCard 全局函数
- 新增全局 openUserCard() 函数,所有双击用户名入口统一调用 - 聊天消息区 clickableUser 的 ondblclick 改为 openUserCard - 右侧用户列表双击简化为调用 openUserCard - 移除输入栏底部的管理操作下拉框和执行按钮 - 管理操作统一通过双击用户名 → 名片弹窗执行
This commit is contained in:
@@ -58,33 +58,6 @@
|
|||||||
<option value="1">上下分</option>
|
<option value="1">上下分</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
{{-- 管理操作(根据权限显示) --}}
|
|
||||||
@if ($user->user_level >= $levelKick || $room->master == $user->username)
|
|
||||||
<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>
|
|
||||||
@endif
|
|
||||||
@if ($user->user_level >= $levelMute || $room->master == $user->username)
|
|
||||||
<option value="mute">🔇 禁言</option>
|
|
||||||
@endif
|
|
||||||
@if ($user->user_level >= $levelBan)
|
|
||||||
<option value="ban">🚫 封号</option>
|
|
||||||
@endif
|
|
||||||
@if ($user->user_level >= $levelBanip)
|
|
||||||
<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()"
|
|
||||||
style="font-size: 11px; padding: 1px 6px; background: #c44; color: #fff; border: none; border-radius: 2px; cursor: pointer;">执行</button>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if (
|
@if (
|
||||||
$user->user_level >= (int) \App\Models\Sysparam::getValue('level_announcement', '10') ||
|
$user->user_level >= (int) \App\Models\Sysparam::getValue('level_announcement', '10') ||
|
||||||
|
|||||||
@@ -162,20 +162,8 @@
|
|||||||
toUserSelect.value = username;
|
toUserSelect.value = username;
|
||||||
document.getElementById('content').focus();
|
document.getElementById('content').focus();
|
||||||
};
|
};
|
||||||
// 双击打开用户名片弹窗
|
// 双击打开用户名片弹窗(全局统一入口)
|
||||||
item.ondblclick = () => {
|
item.ondblclick = () => openUserCard(username);
|
||||||
if (username !== window.chatContext.username) {
|
|
||||||
// 触发 Alpine.js 用户名片弹窗
|
|
||||||
const modalContainer = document.getElementById('user-modal-container');
|
|
||||||
if (modalContainer && modalContainer.__x) {
|
|
||||||
modalContainer.__x.$data.fetchUser(username);
|
|
||||||
} else if (modalContainer) {
|
|
||||||
// Alpine v3 使用 _x_dataStack
|
|
||||||
const alpineData = Alpine.$data(modalContainer);
|
|
||||||
if (alpineData) alpineData.fetchUser(username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
userList.appendChild(item);
|
userList.appendChild(item);
|
||||||
|
|
||||||
if (username !== window.chatContext.username) {
|
if (username !== window.chatContext.username) {
|
||||||
@@ -236,6 +224,21 @@
|
|||||||
document.getElementById('content').focus();
|
document.getElementById('content').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局函数:双击用户名打开名片弹窗
|
||||||
|
*
|
||||||
|
* 聊天消息区和右侧用户列表统一调用此函数。
|
||||||
|
* 通过 Alpine.js 的 fetchUser 方法加载用户资料并显示弹窗。
|
||||||
|
*/
|
||||||
|
function openUserCard(username) {
|
||||||
|
if (username === window.chatContext.username) return;
|
||||||
|
const el = document.getElementById('user-modal-container');
|
||||||
|
if (el) {
|
||||||
|
const data = Alpine.$data(el);
|
||||||
|
if (data) data.fetchUser(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 双击用户名 → 在包厢窗口(say2)显示用户基本信息
|
* 双击用户名 → 在包厢窗口(say2)显示用户基本信息
|
||||||
*/
|
*/
|
||||||
@@ -288,7 +291,7 @@
|
|||||||
if (systemUsers.includes(uName)) {
|
if (systemUsers.includes(uName)) {
|
||||||
return `<span class="msg-user" style="color: ${color};">${uName}</span>`;
|
return `<span class="msg-user" style="color: ${color};">${uName}</span>`;
|
||||||
}
|
}
|
||||||
return `<span class="msg-user" style="color: ${color}; cursor: pointer;" onclick="switchTarget('${uName}')" ondblclick="showUserInfoInSay2('${uName}')">${uName}</span>`;
|
return `<span class="msg-user" style="color: ${color}; cursor: pointer;" onclick="switchTarget('${uName}')" ondblclick="openUserCard('${uName}')">${uName}</span>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取发言者头像
|
// 获取发言者头像
|
||||||
|
|||||||
Reference in New Issue
Block a user