From 231611af846822f2e05d4161aa6ca1a16d244879 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Sat, 7 Feb 2026 20:43:44 +0800 Subject: [PATCH] feat(s2a): Add expandable group list with truncation in ProfileCard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add expanded state to ProfileCard component for toggling group visibility - Implement MAX_VISIBLE constant to limit initial group display to 4 items - Add toggle button to show/hide remaining groups with count indicator - Display "收起" (collapse) when expanded, "+N 个分组" (N groups) when collapsed - Wrap group grid in container div to accommodate expand/collapse button - Improve UX for profiles with many groups by preventing excessive card height --- frontend/src/pages/S2AConfig.tsx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/S2AConfig.tsx b/frontend/src/pages/S2AConfig.tsx index ce7f143..68d8a43 100644 --- a/frontend/src/pages/S2AConfig.tsx +++ b/frontend/src/pages/S2AConfig.tsx @@ -598,10 +598,15 @@ function ProfileCard({ profile, isActive, isActivating, groupNameCache, onActiva onDelete: () => void }) { const [confirming, setConfirming] = useState(false) + const [expanded, setExpanded] = useState(false) let parsedGroups: number[] = [] try { parsedGroups = JSON.parse(profile.group_ids || '[]') } catch { /* ignore */ } + const MAX_VISIBLE = 4 + const visibleGroups = expanded ? parsedGroups : parsedGroups.slice(0, MAX_VISIBLE) + const hiddenCount = parsedGroups.length - MAX_VISIBLE + return ( {/* 活动标记 */} @@ -636,13 +641,23 @@ function ProfileCard({ profile, isActive, isActivating, groupNameCache, onActiva {/* 分组列表 */} {parsedGroups.length > 0 && ( -
- {parsedGroups.map(id => ( -
- {groupNameCache[id] || `#${id}`} - {groupNameCache[id] && #{id}} -
- ))} +
+
+ {visibleGroups.map(id => ( +
+ {groupNameCache[id] || `#${id}`} + {groupNameCache[id] && #{id}} +
+ ))} +
+ {hiddenCount > 0 && ( + + )}
)}