支持 OOBE 导入名单粘贴多行姓名添加

This commit is contained in:
JSR
2026-03-18 17:45:35 +08:00
parent de369e126a
commit 5f9c6609bb
3 changed files with 30 additions and 9 deletions
+28 -7
View File
@@ -166,13 +166,31 @@ export const OOBE: React.FC<oobeProps> = ({ visible, onComplete }) => {
}
const addStudent = () => {
const name = newStudentName.trim()
if (!name) return
if (students.some((s) => s.name === name)) {
const input = newStudentName.trim()
if (!input) return
const lines = input
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)
if (lines.length === 0) return
const existing = new Set(students.map((s) => s.name))
const added = new Set<string>()
const newStudents: studentItem[] = []
lines.forEach((name) => {
if (existing.has(name) || added.has(name)) return
newStudents.push({ name })
added.add(name)
})
if (newStudents.length === 0) {
messageApi.warning(t("oobe.steps.students.studentExists"))
return
}
setStudents([...students, { name }])
setStudents([...students, ...newStudents])
setNewStudentName("")
}
@@ -530,17 +548,20 @@ export const OOBE: React.FC<oobeProps> = ({ visible, onComplete }) => {
{t("oobe.steps.students.supportedFormats")}
</div>
</div>
<div style={{ display: "flex", gap: 8 }}>
<Input
<div style={{ display: "flex", gap: 8, alignItems: "flex-start" }}>
<Input.TextArea
value={newStudentName}
onChange={(e) => setNewStudentName(e.target.value)}
placeholder={t("oobe.steps.students.studentName")}
onPressEnter={addStudent}
autoSize={{ minRows: 2, maxRows: 5 }}
/>
<Button type="primary" icon={<PlusOutlined />} onClick={addStudent}>
{t("oobe.steps.students.addStudent")}
</Button>
</div>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
{t("oobe.steps.students.manualHint")}
</Typography.Text>
<div
style={{
maxHeight: 150,
+1 -1
View File
@@ -71,7 +71,7 @@
"import": "Import List",
"manual": "Add Manually",
"importHint": "Supports Excel (.xlsx) or JSON files",
"manualHint": "Add student names one by one",
"manualHint": "You can paste multiple lines, one student name per line",
"dragDrop": "Drag and drop files here, or click to select",
"supportedFormats": "Supports .xlsx, .json formats",
"studentName": "Student Name",
+1 -1
View File
@@ -71,7 +71,7 @@
"import": "导入名单",
"manual": "手动添加",
"importHint": "支持 Excel (.xlsx) 或 JSON 文件",
"manualHint": "逐个添加学生姓名",
"manualHint": "支持粘贴多行文本,一行一个姓名",
"dragDrop": "拖拽文件到此处,或点击选择",
"supportedFormats": "支持 .xlsx, .json 格式",
"studentName": "学生姓名",