修复欢迎语 action 未生效:action select 加隐藏 option[value=欢迎]
This commit is contained in:
@@ -34,6 +34,8 @@
|
|||||||
<option value="拳打">拳打</option>
|
<option value="拳打">拳打</option>
|
||||||
<option value="飞吻">飞吻</option>
|
<option value="飞吻">飞吻</option>
|
||||||
<option value="偷看">偷看</option>
|
<option value="偷看">偷看</option>
|
||||||
|
{{-- 欢迎语专用 action,隐藏不对外显示,JS 临时切换用 --}}
|
||||||
|
<option value="欢迎" style="display:none"></option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,9 @@
|
|||||||
function toggleWelcomeMenu(event) {
|
function toggleWelcomeMenu(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const menu = document.getElementById('welcome-menu');
|
const menu = document.getElementById('welcome-menu');
|
||||||
if (!menu) { return; }
|
if (!menu) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
menu.style.display = menu.style.display === 'none' ? 'block' : 'none';
|
menu.style.display = menu.style.display === 'none' ? 'block' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,11 +139,11 @@
|
|||||||
*/
|
*/
|
||||||
function sendWelcomeTpl(tpl) {
|
function sendWelcomeTpl(tpl) {
|
||||||
const toUser = document.getElementById('to_user')?.value || '大家';
|
const toUser = document.getElementById('to_user')?.value || '大家';
|
||||||
const name = toUser === '大家' ? '大家' : toUser;
|
const name = toUser === '大家' ? '大家' : toUser;
|
||||||
const prefix = window.chatContext?.welcomePrefix || window.chatContext?.username || '';
|
const prefix = window.chatContext?.welcomePrefix || window.chatContext?.username || '';
|
||||||
const body = tpl.replace(/\{name\}/g, name);
|
const body = tpl.replace(/\{name\}/g, name);
|
||||||
// 拼接格式:「部门 职务 姓名:欢迎语」
|
// 拼接格式:「部门 职务 姓名:欢迎语」
|
||||||
const msg = `${prefix}:${body}`;
|
const msg = `${prefix}:${body}`;
|
||||||
|
|
||||||
const input = document.getElementById('content');
|
const input = document.getElementById('content');
|
||||||
if (input) {
|
if (input) {
|
||||||
@@ -149,24 +151,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const menu = document.getElementById('welcome-menu');
|
const menu = document.getElementById('welcome-menu');
|
||||||
if (menu) { menu.style.display = 'none'; }
|
if (menu) {
|
||||||
|
menu.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
// 临时把 action 设为「欢迎」,让消息在聊天窗口以瓦蓝边框样式显示
|
// 临时把 action 设为「欢迎」,让消息在聊天窗口以瓦蓝边框样式显示
|
||||||
const actionSel = document.getElementById('action');
|
const actionSel = document.getElementById('action');
|
||||||
const prevAction = actionSel?.value || '';
|
const prevAction = actionSel?.value || '';
|
||||||
if (actionSel) { actionSel.value = '欢迎'; }
|
if (actionSel) {
|
||||||
|
actionSel.value = '欢迎';
|
||||||
|
}
|
||||||
|
|
||||||
// 自动触发发送
|
// 自动触发发送
|
||||||
sendMessage(null).finally(() => {
|
sendMessage(null).finally(() => {
|
||||||
// 发完后恢复原来的 action
|
// 发完后恢复原来的 action
|
||||||
if (actionSel) { actionSel.value = prevAction; }
|
if (actionSel) {
|
||||||
|
actionSel.value = prevAction;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击页面任意位置,关闭欢迎语浮层
|
// 点击页面任意位置,关闭欢迎语浮层
|
||||||
document.addEventListener('click', function () {
|
document.addEventListener('click', function() {
|
||||||
const menu = document.getElementById('welcome-menu');
|
const menu = document.getElementById('welcome-menu');
|
||||||
if (menu) { menu.style.display = 'none'; }
|
if (menu) {
|
||||||
|
menu.style.display = 'none';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── 动作选择 ──────────────────────────────────────
|
// ── 动作选择 ──────────────────────────────────────
|
||||||
@@ -262,7 +272,7 @@
|
|||||||
|
|
||||||
const headface = (user.headface || '1.gif').toLowerCase();
|
const headface = (user.headface || '1.gif').toLowerCase();
|
||||||
const headImgSrc = headface.startsWith('storage/') ? '/' + headface : '/images/headface/' +
|
const headImgSrc = headface.startsWith('storage/') ? '/' + headface : '/images/headface/' +
|
||||||
headface;
|
headface;
|
||||||
|
|
||||||
// 徽章优先级:职务图标 > 管理员 > VIP
|
// 徽章优先级:职务图标 > 管理员 > VIP
|
||||||
let badges = '';
|
let badges = '';
|
||||||
@@ -288,20 +298,29 @@
|
|||||||
// 单击/双击互斥:单击延迟 250ms 执行,双击取消单击定时器后直接执行双击逻辑
|
// 单击/双击互斥:单击延迟 250ms 执行,双击取消单击定时器后直接执行双击逻辑
|
||||||
let _clickTimer = null;
|
let _clickTimer = null;
|
||||||
item.onclick = () => {
|
item.onclick = () => {
|
||||||
if (_clickTimer) { return; }
|
if (_clickTimer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_clickTimer = setTimeout(() => {
|
_clickTimer = setTimeout(() => {
|
||||||
_clickTimer = null;
|
_clickTimer = null;
|
||||||
toUserSelect.value = username;
|
toUserSelect.value = username;
|
||||||
// 手机端:点击名字时关闭名单抽屉
|
// 手机端:点击名字时关闭名单抽屉
|
||||||
if (typeof closeMobileDrawer === 'function') { closeMobileDrawer(); }
|
if (typeof closeMobileDrawer === 'function') {
|
||||||
|
closeMobileDrawer();
|
||||||
|
}
|
||||||
document.getElementById('content').focus();
|
document.getElementById('content').focus();
|
||||||
}, 250);
|
}, 250);
|
||||||
};
|
};
|
||||||
// 双击打开用户名片弹窗(全局统一入口);手机端同时关闭名单抽屉
|
// 双击打开用户名片弹窗(全局统一入口);手机端同时关闭名单抽屉
|
||||||
item.ondblclick = () => {
|
item.ondblclick = () => {
|
||||||
// 取消尚未执行的单击定时器
|
// 取消尚未执行的单击定时器
|
||||||
if (_clickTimer) { clearTimeout(_clickTimer); _clickTimer = null; }
|
if (_clickTimer) {
|
||||||
if (typeof closeMobileDrawer === 'function') { closeMobileDrawer(); }
|
clearTimeout(_clickTimer);
|
||||||
|
_clickTimer = null;
|
||||||
|
}
|
||||||
|
if (typeof closeMobileDrawer === 'function') {
|
||||||
|
closeMobileDrawer();
|
||||||
|
}
|
||||||
openUserCard(username);
|
openUserCard(username);
|
||||||
};
|
};
|
||||||
targetContainer.appendChild(item);
|
targetContainer.appendChild(item);
|
||||||
@@ -342,7 +361,9 @@
|
|||||||
onlineCount.innerText = count;
|
onlineCount.innerText = count;
|
||||||
onlineCountBottom.innerText = count;
|
onlineCountBottom.innerText = count;
|
||||||
const footer = document.getElementById('online-count-footer');
|
const footer = document.getElementById('online-count-footer');
|
||||||
if (footer) { footer.innerText = count; }
|
if (footer) {
|
||||||
|
footer.innerText = count;
|
||||||
|
}
|
||||||
|
|
||||||
// 派发用户列表更新事件,供手机端抽屉同步
|
// 派发用户列表更新事件,供手机端抽屉同步
|
||||||
window.dispatchEvent(new Event('chatroom:users-updated'));
|
window.dispatchEvent(new Event('chatroom:users-updated'));
|
||||||
@@ -390,7 +411,7 @@
|
|||||||
let timeStrOverride = false;
|
let timeStrOverride = false;
|
||||||
|
|
||||||
// 系统用户名列表(不可被选为聊天对象)
|
// 系统用户名列表(不可被选为聊天对象)
|
||||||
const systemUsers = ['钓鱼播报', '星海小博士', '系统传音', '系统公告', 'AI小班长', '送花播报', '系统'];
|
const systemUsers = ['钓鱼播报', '星海小博士', '系统传音', '系统公告', 'AI小班长', '送花播报', '系统', '欢迎'];
|
||||||
|
|
||||||
// 动作文字映射表:情绪型(着/地,放"对"之前)和动作型(了,替换"对X说")
|
// 动作文字映射表:情绪型(着/地,放"对"之前)和动作型(了,替换"对X说")
|
||||||
const actionTextMap = {
|
const actionTextMap = {
|
||||||
@@ -510,7 +531,8 @@
|
|||||||
return '【' + clickableUser(uName, '#1d4ed8') + '】';
|
return '【' + clickableUser(uName, '#1d4ed8') + '】';
|
||||||
});
|
});
|
||||||
|
|
||||||
html = `<div style="color: #1e40af;">💬 ${parsedContent} <span style="color: #93c5fd; font-size: 11px; font-weight: normal;">(${timeStr})</span></div>`;
|
html =
|
||||||
|
`<div style="color: #1e40af;">💬 ${parsedContent} <span style="color: #93c5fd; font-size: 11px; font-weight: normal;">(${timeStr})</span></div>`;
|
||||||
timeStrOverride = true;
|
timeStrOverride = true;
|
||||||
}
|
}
|
||||||
// 接下来再判断各类发话人
|
// 接下来再判断各类发话人
|
||||||
|
|||||||
Reference in New Issue
Block a user