diff --git a/resources/views/chat/partials/layout/input-bar.blade.php b/resources/views/chat/partials/layout/input-bar.blade.php index 0358529..23704ad 100644 --- a/resources/views/chat/partials/layout/input-bar.blade.php +++ b/resources/views/chat/partials/layout/input-bar.blade.php @@ -34,6 +34,8 @@ + {{-- 欢迎语专用 action,隐藏不对外显示,JS 临时切换用 --}} + diff --git a/resources/views/chat/partials/scripts.blade.php b/resources/views/chat/partials/scripts.blade.php index 83ad890..075cec1 100644 --- a/resources/views/chat/partials/scripts.blade.php +++ b/resources/views/chat/partials/scripts.blade.php @@ -125,7 +125,9 @@ function toggleWelcomeMenu(event) { event.stopPropagation(); const menu = document.getElementById('welcome-menu'); - if (!menu) { return; } + if (!menu) { + return; + } menu.style.display = menu.style.display === 'none' ? 'block' : 'none'; } @@ -137,11 +139,11 @@ */ function sendWelcomeTpl(tpl) { const toUser = document.getElementById('to_user')?.value || '大家'; - const name = toUser === '大家' ? '大家' : toUser; + const name = toUser === '大家' ? '大家' : toUser; 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'); if (input) { @@ -149,24 +151,32 @@ } const menu = document.getElementById('welcome-menu'); - if (menu) { menu.style.display = 'none'; } + if (menu) { + menu.style.display = 'none'; + } // 临时把 action 设为「欢迎」,让消息在聊天窗口以瓦蓝边框样式显示 const actionSel = document.getElementById('action'); const prevAction = actionSel?.value || ''; - if (actionSel) { actionSel.value = '欢迎'; } + if (actionSel) { + actionSel.value = '欢迎'; + } // 自动触发发送 sendMessage(null).finally(() => { // 发完后恢复原来的 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'); - if (menu) { menu.style.display = 'none'; } + if (menu) { + menu.style.display = 'none'; + } }); // ── 动作选择 ────────────────────────────────────── @@ -262,7 +272,7 @@ const headface = (user.headface || '1.gif').toLowerCase(); const headImgSrc = headface.startsWith('storage/') ? '/' + headface : '/images/headface/' + - headface; + headface; // 徽章优先级:职务图标 > 管理员 > VIP let badges = ''; @@ -288,20 +298,29 @@ // 单击/双击互斥:单击延迟 250ms 执行,双击取消单击定时器后直接执行双击逻辑 let _clickTimer = null; item.onclick = () => { - if (_clickTimer) { return; } + if (_clickTimer) { + return; + } _clickTimer = setTimeout(() => { _clickTimer = null; toUserSelect.value = username; // 手机端:点击名字时关闭名单抽屉 - if (typeof closeMobileDrawer === 'function') { closeMobileDrawer(); } + if (typeof closeMobileDrawer === 'function') { + closeMobileDrawer(); + } document.getElementById('content').focus(); }, 250); }; // 双击打开用户名片弹窗(全局统一入口);手机端同时关闭名单抽屉 item.ondblclick = () => { // 取消尚未执行的单击定时器 - if (_clickTimer) { clearTimeout(_clickTimer); _clickTimer = null; } - if (typeof closeMobileDrawer === 'function') { closeMobileDrawer(); } + if (_clickTimer) { + clearTimeout(_clickTimer); + _clickTimer = null; + } + if (typeof closeMobileDrawer === 'function') { + closeMobileDrawer(); + } openUserCard(username); }; targetContainer.appendChild(item); @@ -342,7 +361,9 @@ onlineCount.innerText = count; onlineCountBottom.innerText = count; const footer = document.getElementById('online-count-footer'); - if (footer) { footer.innerText = count; } + if (footer) { + footer.innerText = count; + } // 派发用户列表更新事件,供手机端抽屉同步 window.dispatchEvent(new Event('chatroom:users-updated')); @@ -390,7 +411,7 @@ let timeStrOverride = false; // 系统用户名列表(不可被选为聊天对象) - const systemUsers = ['钓鱼播报', '星海小博士', '系统传音', '系统公告', 'AI小班长', '送花播报', '系统']; + const systemUsers = ['钓鱼播报', '星海小博士', '系统传音', '系统公告', 'AI小班长', '送花播报', '系统', '欢迎']; // 动作文字映射表:情绪型(着/地,放"对"之前)和动作型(了,替换"对X说") const actionTextMap = { @@ -510,7 +531,8 @@ return '【' + clickableUser(uName, '#1d4ed8') + '】'; }); - html = `
💬 ${parsedContent} (${timeStr})
`; + html = + `
💬 ${parsedContent} (${timeStr})
`; timeStrOverride = true; } // 接下来再判断各类发话人