From 094ab4409462dc6b7c64ce15d24c2eaa0ca282bc Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 7 May 2026 23:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20refactor(im):=20joinMentionSegme?= =?UTF-8?q?nts=20=E7=94=A8=20flatMap=20=E6=9B=BF=E4=BB=A3=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=BC=8F=20push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 少一个可变 out + 命令式 forEach,意图更直观 Co-Authored-By: Claude Opus 4.7 --- src/views/im/utils/message.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/views/im/utils/message.ts b/src/views/im/utils/message.ts index 4cd801220..172a86a3c 100644 --- a/src/views/im/utils/message.ts +++ b/src/views/im/utils/message.ts @@ -47,14 +47,11 @@ export function joinMentionSegments( separator: string, resolveName: (userId: number) => string ): TipSegment[] { - const out: TipSegment[] = [] - userIds.forEach((id, index) => { - if (index > 0) { - out.push(tipText(separator)) - } - out.push(tipMention(id, resolveName(id))) - }) - return out + return userIds.flatMap((id, index) => + index === 0 + ? [tipMention(id, resolveName(id))] + : [tipText(separator), tipMention(id, resolveName(id))] + ) } // ==================== 引用消息 ====================