竖屏改为纵向紧凑列表并消除横向滚动

This commit is contained in:
JSR
2026-03-18 21:20:41 +08:00
parent 040a2ab4b3
commit b64efe8a6c
2 changed files with 51 additions and 16 deletions
+7 -2
View File
@@ -155,7 +155,7 @@ export function ContentArea({
/> />
</div> </div>
<Content style={{ flex: 1, overflowY: "auto" }}> <Content style={{ flex: 1, overflowY: "auto", overflowX: "hidden" }}>
<Suspense <Suspense
fallback={ fallback={
<div <div
@@ -175,7 +175,12 @@ export function ContentArea({
<Routes> <Routes>
<Route <Route
path="/" path="/"
element={<Home canEdit={permission === "admin" || permission === "points"} />} element={
<Home
canEdit={permission === "admin" || permission === "points"}
isPortraitMode={isPortraitMode}
/>
}
/> />
<Route path="/students" element={<StudentManager canEdit={permission === "admin"} />} /> <Route path="/students" element={<StudentManager canEdit={permission === "admin"} />} />
<Route <Route
+44 -14
View File
@@ -55,7 +55,12 @@ const T9_KEY_MAP: Record<string, string> = {
z: "9", z: "9",
} }
export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => { interface HomeProps {
canEdit: boolean
isPortraitMode?: boolean
}
export const Home: React.FC<HomeProps> = ({ canEdit, isPortraitMode = false }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [students, setStudents] = useState<student[]>([]) const [students, setStudents] = useState<student[]>([])
const [reasons, setReasons] = useState<reason[]>([]) const [reasons, setReasons] = useState<reason[]>([])
@@ -535,7 +540,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
overflow: "visible", overflow: "visible",
boxShadow: isQuickActionMode ? "0 8px 18px rgba(22, 119, 255, 0.18)" : undefined, boxShadow: isQuickActionMode ? "0 8px 18px rgba(22, 119, 255, 0.18)" : undefined,
}} }}
styles={{ body: { padding: "12px" } }} styles={{ body: { padding: isPortraitMode ? "10px 12px" : "12px" } }}
> >
{rankBadge && ( {rankBadge && (
<div <div
@@ -550,14 +555,14 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
{rankBadge} {rankBadge}
</div> </div>
)} )}
<div style={{ display: "flex", alignItems: "center", gap: "12px" }}> <div style={{ display: "flex", alignItems: "center", gap: isPortraitMode ? "10px" : "12px" }}>
{student.avatarUrl ? ( {student.avatarUrl ? (
<img <img
src={student.avatarUrl} src={student.avatarUrl}
alt={student.name} alt={student.name}
style={{ style={{
width: "44px", width: isPortraitMode ? "40px" : "44px",
height: "44px", height: isPortraitMode ? "40px" : "44px",
borderRadius: "12px", borderRadius: "12px",
objectFit: "cover", objectFit: "cover",
flexShrink: 0, flexShrink: 0,
@@ -569,8 +574,8 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
) : ( ) : (
<div <div
style={{ style={{
width: "44px", width: isPortraitMode ? "40px" : "44px",
height: "44px", height: isPortraitMode ? "40px" : "44px",
borderRadius: "12px", borderRadius: "12px",
backgroundColor: avatarColor, backgroundColor: avatarColor,
display: "flex", display: "flex",
@@ -578,7 +583,13 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
justifyContent: "center", justifyContent: "center",
color: "white", color: "white",
fontWeight: "bold", fontWeight: "bold",
fontSize: avatarText.length > 1 ? "14px" : "18px", fontSize: isPortraitMode
? avatarText.length > 1
? "13px"
: "16px"
: avatarText.length > 1
? "14px"
: "18px",
flexShrink: 0, flexShrink: 0,
boxShadow: `0 4px 10px ${avatarColor}40`, boxShadow: `0 4px 10px ${avatarColor}40`,
}} }}
@@ -586,7 +597,14 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
{avatarText} {avatarText}
</div> </div>
)} )}
<div style={{ flex: 1, overflow: "hidden", position: "relative", minHeight: "44px" }}> <div
style={{
flex: 1,
overflow: "hidden",
position: "relative",
minHeight: isPortraitMode ? "40px" : "44px",
}}
>
<div <div
style={{ style={{
position: "absolute", position: "absolute",
@@ -677,7 +695,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
return groupedStudents.map((group) => ( return groupedStudents.map((group) => (
<div <div
key={group.key} key={group.key}
style={{ marginBottom: "32px" }} style={{ marginBottom: isPortraitMode ? "20px" : "32px" }}
ref={(el) => { ref={(el) => {
groupRefs.current[group.key] = el groupRefs.current[group.key] = el
}} }}
@@ -706,9 +724,10 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
)} )}
<div <div
style={{ style={{
display: "grid", display: isPortraitMode ? "flex" : "grid",
gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))", flexDirection: isPortraitMode ? "column" : undefined,
gap: "16px", gridTemplateColumns: isPortraitMode ? undefined : "repeat(auto-fill, minmax(180px, 1fr))",
gap: isPortraitMode ? "10px" : "16px",
}} }}
> >
{group.students.map((student, idx) => renderStudentCard(student, idx))} {group.students.map((student, idx) => renderStudentCard(student, idx))}
@@ -902,6 +921,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
const renderQuickNav = () => { const renderQuickNav = () => {
if ( if (
isPortraitMode ||
groupedStudents.length <= 1 || groupedStudents.length <= 1 ||
sortType === "score" || sortType === "score" ||
(sortType === "alphabet" && searchKeyword) (sortType === "alphabet" && searchKeyword)
@@ -1023,7 +1043,17 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
} }
return ( return (
<div style={{ padding: "24px", maxWidth: "1200px", margin: "0 auto", position: "relative" }}> <div
style={{
padding: isPortraitMode ? "16px" : "24px",
width: "100%",
boxSizing: "border-box",
maxWidth: isPortraitMode ? "100%" : "1200px",
margin: "0 auto",
position: "relative",
overflowX: "hidden",
}}
>
{contextHolder} {contextHolder}
<div <div
style={{ style={{