From fc82ed3d7ef0b7efd9aa6ca4addb41d4d121b7b3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 27 Apr 2026 14:30:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(input):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B2=98=E8=B4=B4=E6=96=87=E4=BB=B6=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E7=AE=80=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conversation/components/input/MessageInput.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/views/im/home/pages/conversation/components/input/MessageInput.vue b/src/views/im/home/pages/conversation/components/input/MessageInput.vue index 390c9f0a9..8b4106c7f 100644 --- a/src/views/im/home/pages/conversation/components/input/MessageInput.vue +++ b/src/views/im/home/pages/conversation/components/input/MessageInput.vue @@ -347,8 +347,8 @@ function onPaste(e: ClipboardEvent) { // 1. 优先扫 clipboardData.items 找文件类型条目(截图、拖入的图片 / 文件等) const items = e.clipboardData?.items if (items?.length) { - // TODO @AI:这了有 linter 报错; - for (const item of items) { + for (let i = 0; i < items.length; i++) { + const item = items[i] if (item.kind !== 'file') { continue } @@ -452,9 +452,10 @@ function detectAtMention() { const node = range.startContainer const offset = range.startOffset const before = (node.textContent || '').slice(0, offset) - // (?:^|\s) 强制 @ 前是行首或空白,避免 email-like "test@example.com" 误触发 - // match[1] 是关键词;@ 符号位置 = offset - keyword.length - 1 - const match = before.match(/(?:^|\s)@([^\s@]*)$/) + // 直接找最近的 @:不限制前置字符,对齐微信"中文紧贴 @ 也能联想"(你好@张三、,@张三 都触发); + // 代价是 email-like "test@example.com" 也会触发,但聊天输入里粘 email 的概率低, + // 且用户按 Esc 即可关浮层;兜底由 [^\s@] 保证一旦输入空格 / 第二个 @ 就停下 + const match = before.match(/@([^\s@]*)$/) if (!match) { closeMention() return