From e3217a5de94ef3bb3205e881c6bb423f55d20b46 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 10 Sep 2026 19:15:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E8=BD=AC=E5=8F=91=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E5=A5=BD=E5=8F=8B/=E7=BE=A4=E8=81=8A?= =?UTF-8?q?=E5=88=86=E5=BC=80=E5=85=A8=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来是列表整体一个全选按钮,选中后好友和群聊会一起被勾上。改成 好友、群聊两个分组各自独立的全选/取消全选,互不影响,方便只想 批量选中其中一类的场景(比如只发给所有群,不带上私聊好友)。 Co-Authored-By: Claude Sonnet 5 --- .../features/messages/ForwardPickerModal.tsx | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/web/src/features/messages/ForwardPickerModal.tsx b/web/src/features/messages/ForwardPickerModal.tsx index c5be9fea..f27e19fd 100644 --- a/web/src/features/messages/ForwardPickerModal.tsx +++ b/web/src/features/messages/ForwardPickerModal.tsx @@ -55,18 +55,23 @@ export function ForwardPickerModal({ onPick, onClose }: ForwardPickerModalProps) }); }; - const visibleTopics = useMemo(() => filtered.map((c) => c.topic).filter((t): t is string => !!t), [filtered]); - const allVisibleSelected = visibleTopics.length > 0 && visibleTopics.every((t) => selected.has(t)); - const toggleSelectAll = () => { + // 好友/群聊各自独立的全选 -- 一次转发常常只想覆盖其中一类(比如"发给所有群"但不想带上私聊 + // 好友),一个笼统的全选做不到这一点,所以拆成两个独立开关而不是列表整体一个。 + const friendTopics = useMemo(() => friends.map((c) => c.topic).filter((t): t is string => !!t), [friends]); + const groupTopics = useMemo(() => groups.map((c) => c.topic).filter((t): t is string => !!t), [groups]); + const allFriendsSelected = friendTopics.length > 0 && friendTopics.every((t) => selected.has(t)); + const allGroupsSelected = groupTopics.length > 0 && groupTopics.every((t) => selected.has(t)); + + const toggleSectionSelectAll = (topics: string[], allSelected: boolean) => { setSelected((prev) => { - if (allVisibleSelected) { + if (allSelected) { // Only drop the ones the CURRENT search actually shows -- a selection made under an earlier, // now-cleared query shouldn't be wiped out by un-selecting "all" of a narrower view. const next = new Set(prev); - for (const t of visibleTopics) next.delete(t); + for (const t of topics) next.delete(t); return next; } - return new Set([...prev, ...visibleTopics]); + return new Set([...prev, ...topics]); }); }; @@ -121,22 +126,35 @@ export function ForwardPickerModal({ onPick, onClose }: ForwardPickerModalProps) className="ml-2 w-full bg-transparent text-sm outline-none placeholder:text-text-placeholder-2" /> - {visibleTopics.length ? ( - - ) : null}
{friends.length ? ( <> -
好友
+
+ 好友 + +
{friends.map(renderRow)} ) : null} {groups.length ? ( <> -
群聊
+
+ 群聊 + +
{groups.map(renderRow)} ) : null}