From 05efd546aac77cf26548d84d38cfcf4f746e4f51 Mon Sep 17 00:00:00 2001 From: JSR Date: Wed, 18 Mar 2026 21:29:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AB=96=E5=B1=8F=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E6=93=8D=E4=BD=9C=E7=95=8C=E9=9D=A2=E4=B8=BA=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E5=85=A8=E5=B1=8F=E6=8A=BD=E5=B1=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home.tsx | 603 ++++++++++++++++++++-------------------- 1 file changed, 307 insertions(+), 296 deletions(-) diff --git a/src/components/Home.tsx b/src/components/Home.tsx index df91e9a..9b0e41b 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useCallback, useMemo, useRef } from "react" -import { Card, Space, Button, Tag, Input, Select, Modal, message, InputNumber, Divider } from "antd" +import { Card, Space, Button, Tag, Input, Select, Modal, Drawer, message, InputNumber, Divider } from "antd" import { SearchOutlined, DeleteOutlined } from "@ant-design/icons" import { useTranslation } from "react-i18next" import { match, pinyin } from "pinyin-pro" @@ -1180,6 +1180,277 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = ) } + const operationPanelContent = selectedStudent && ( +
+
+
+ {selectedStudent.avatarUrl ? ( + {selectedStudent.name} + ) : ( +
+ {getDisplayText(selectedStudent.name)} +
+ )} + {selectedStudent.name} +
+
+ + {t("home.currentScore")}: + + 0 ? "success" : selectedStudent.score < 0 ? "error" : "default" + } + style={{ fontWeight: "bold" }} + > + {selectedStudent.score > 0 ? `+${selectedStudent.score}` : selectedStudent.score} + +
+
+ + {groupedReasons.length > 0 && ( +
+
+ + {t("home.quickOptions")} + + +
+
+ {groupedReasons.map(([category, items]) => ( +
+
+ {category} +
+ + {items.map((r) => ( + + ))} + +
+ ))} +
+
+ )} + +
+
+ + {t("home.adjustPoints")} + + +
+
+ {[-5, -3, -2, -1, 1, 2, 3, 5, 10].map((num) => ( + + ))} + +
+
+ setCustomScore(v as number)} + min={-99} + max={99} + step={1} + style={{ width: "140px" }} + placeholder={t("home.customPoints")} + /> + + {t("home.customPointsHint")} + +
+
+ +
+
+ + {t("home.reason")} + + +
+ setReasonContent(e.target.value)} + placeholder={t("home.reasonPlaceholder")} + suffix={ + reasonContent ? ( + setReasonContent("")} style={{ cursor: "pointer" }} /> + ) : undefined + } + /> +
+ + {customScore !== undefined && ( +
0 + ? "var(--ant-color-success-bg, #f6ffed)" + : customScore < 0 + ? "var(--ant-color-error-bg, #fff2f0)" + : "var(--ss-bg-color)", + borderRadius: "8px", + border: `1px solid ${customScore > 0 ? "var(--ant-color-success-border, #b7eb8f)" : customScore < 0 ? "var(--ant-color-error-border, #ffccc7)" : "var(--ss-border-color)"}`, + marginTop: "4px", + }} + > +
+ {t("home.preview")}: +
+
+ {selectedStudent.name}{" "} + 0 + ? "var(--ant-color-success, #52c41a)" + : customScore < 0 + ? "var(--ant-color-error, #ff4d4f)" + : "inherit", + }} + > + {customScore > 0 ? `+${customScore}` : customScore} + {" "} + {t("home.points")} + + {reasonContent ? `${t("home.reasonLabel")}${reasonContent}` : t("home.noReason")} + +
+
+ )} +
+ ) + return (
= ({ canEdit, isPortraitMode = false }) = )}
- setOperationVisible(false)} - onOk={handleSubmit} - confirmLoading={submitLoading} - okText={t("home.submitOperation")} - cancelText={t("common.cancel")} - width={560} - destroyOnHidden - > - {selectedStudent && ( -
-
-
- {selectedStudent.avatarUrl ? ( - {selectedStudent.name} - ) : ( -
- {getDisplayText(selectedStudent.name)} -
- )} - {selectedStudent.name} -
-
- - {t("home.currentScore")}: - - 0 - ? "success" - : selectedStudent.score < 0 - ? "error" - : "default" - } - style={{ fontWeight: "bold" }} - > - {selectedStudent.score > 0 ? `+${selectedStudent.score}` : selectedStudent.score} - -
-
- - {groupedReasons.length > 0 && ( -
-
- - {t("home.quickOptions")} - - -
-
- {groupedReasons.map(([category, items]) => ( -
-
- {category} -
- - {items.map((r) => ( - - ))} - -
- ))} -
-
- )} - -
-
- - {t("home.adjustPoints")} - - -
-
- {[-5, -3, -2, -1, 1, 2, 3, 5, 10].map((num) => ( - - ))} - -
-
- setCustomScore(v as number)} - min={-99} - max={99} - step={1} - style={{ width: "140px" }} - placeholder={t("home.customPoints")} - /> - - {t("home.customPointsHint")} - -
-
- -
-
- - {t("home.reason")} - - -
- setReasonContent(e.target.value)} - placeholder={t("home.reasonPlaceholder")} - suffix={ - reasonContent ? ( - setReasonContent("")} - style={{ cursor: "pointer" }} - /> - ) : undefined - } - /> -
- - {customScore !== undefined && ( -
0 - ? "var(--ant-color-success-bg, #f6ffed)" - : customScore < 0 - ? "var(--ant-color-error-bg, #fff2f0)" - : "var(--ss-bg-color)", - borderRadius: "8px", - border: `1px solid ${customScore > 0 ? "var(--ant-color-success-border, #b7eb8f)" : customScore < 0 ? "var(--ant-color-error-border, #ffccc7)" : "var(--ss-border-color)"}`, - marginTop: "4px", - }} - > -
- {t("home.preview")}: -
-
- {selectedStudent.name}{" "} - 0 - ? "var(--ant-color-success, #52c41a)" - : customScore < 0 - ? "var(--ant-color-error, #ff4d4f)" - : "inherit", - }} - > - {customScore > 0 ? `+${customScore}` : customScore} - {" "} - {t("home.points")} - - {reasonContent - ? `${t("home.reasonLabel")}${reasonContent}` - : t("home.noReason")} - -
-
- )} -
- )} -
+ {isPortraitMode ? ( + setOperationVisible(false)} + destroyOnClose + styles={{ body: { padding: "12px 16px 24px" } }} + footer={ + + + + + } + > + {operationPanelContent} + + ) : ( + setOperationVisible(false)} + onOk={handleSubmit} + confirmLoading={submitLoading} + okText={t("home.submitOperation")} + cancelText={t("common.cancel")} + width={560} + destroyOnHidden + > + {operationPanelContent} + + )} ) }