From 87bdfcef7cc690fe7fd8fce678aa0ca10d4197f5 Mon Sep 17 00:00:00 2001 From: JSR Date: Wed, 18 Mar 2026 21:45:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E6=AD=A3?= =?UTF-8?q?=E6=96=B9=E5=BD=A2=E7=BD=91=E6=A0=BC=E5=AF=86=E5=BA=A6=E5=B9=B6?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=AD=97=E6=AF=8D=E4=BE=A7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home.tsx | 90 ++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 62c56e7..ab015c9 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -329,10 +329,6 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = }, [students, searchKeyword, sortType, matchStudentName]) const groupedStudents = useMemo(() => { - if (layoutType === "squareGrid") { - return [{ key: "all", students: sortedStudents }] - } - if (sortType === "score" || (sortType === "alphabet" && searchKeyword)) { return [{ key: "all", students: sortedStudents }] } @@ -349,6 +345,16 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = .map(([key, students]) => ({ key, students })) }, [sortedStudents, sortType, searchKeyword, layoutType]) + const firstStudentIdByGroup = useMemo(() => { + const result = new Map() + groupedStudents.forEach((group) => { + if (group.key === "all") return + const first = group.students[0] + if (first) result.set(group.key, first.id) + }) + return result + }, [groupedStudents]) + const groupedReasons = useMemo(() => { const groups: Record = {} reasons.forEach((r) => { @@ -869,6 +875,14 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = position: "relative", aspectRatio: "1 / 1", }} + ref={(el) => { + groupedStudents.forEach((group) => { + if (group.key === "all") return + if (firstStudentIdByGroup.get(group.key) === student.id) { + groupRefs.current[group.key] = el + } + }) + }} > = ({ canEdit, isPortraitMode = false }) = overflow: "visible", boxShadow: isQuickActionMode ? "0 8px 18px rgba(22, 119, 255, 0.18)" : undefined, }} - styles={{ body: { height: "100%", padding: "10px" } }} + styles={{ body: { height: "100%", padding: "8px" } }} > {rankBadge && (
= ({ canEdit, isPortraitMode = false }) = src={student.avatarUrl} alt={student.name} style={{ - width: "52px", - height: "52px", - borderRadius: "14px", + width: "42px", + height: "42px", + borderRadius: "12px", objectFit: "cover", flexShrink: 0, boxShadow: `0 4px 10px ${avatarColor}40`, @@ -926,16 +940,16 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = ) : (
1 ? "16px" : "20px", + fontSize: avatarText.length > 1 ? "14px" : "18px", flexShrink: 0, boxShadow: `0 4px 10px ${avatarColor}40`, }} @@ -943,19 +957,6 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = {avatarText}
)} -
- {student.name} -
{isQuickActionMode ? ( ) : ( - 0 ? "success" : student.score < 0 ? "error" : "default"} - style={{ fontWeight: "bold", marginInlineEnd: 0 }} +
- {student.score > 0 ? `+${student.score}` : student.score} - +
+ {student.name} +
+ 0 ? "success" : student.score < 0 ? "error" : "default"} + style={{ fontWeight: "bold", marginInlineEnd: 0 }} + > + {student.score > 0 ? `+${student.score}` : student.score} + +
)}
@@ -1001,8 +1026,8 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) =
{sortedStudents.map((student, idx) => renderStudentSquareCard(student, idx))} @@ -1253,7 +1278,6 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = const shouldShowQuickNav = groupedStudents.length > 1 && - layoutType !== "squareGrid" && sortType !== "score" && !(sortType === "alphabet" && searchKeyword)