mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
支持 OOBE 导入名单粘贴多行姓名添加
This commit is contained in:
@@ -166,13 +166,31 @@ export const OOBE: React.FC<oobeProps> = ({ visible, onComplete }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addStudent = () => {
|
const addStudent = () => {
|
||||||
const name = newStudentName.trim()
|
const input = newStudentName.trim()
|
||||||
if (!name) return
|
if (!input) return
|
||||||
if (students.some((s) => s.name === name)) {
|
|
||||||
|
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"))
|
messageApi.warning(t("oobe.steps.students.studentExists"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setStudents([...students, { name }])
|
|
||||||
|
setStudents([...students, ...newStudents])
|
||||||
setNewStudentName("")
|
setNewStudentName("")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,17 +548,20 @@ export const OOBE: React.FC<oobeProps> = ({ visible, onComplete }) => {
|
|||||||
{t("oobe.steps.students.supportedFormats")}
|
{t("oobe.steps.students.supportedFormats")}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: "flex", gap: 8 }}>
|
<div style={{ display: "flex", gap: 8, alignItems: "flex-start" }}>
|
||||||
<Input
|
<Input.TextArea
|
||||||
value={newStudentName}
|
value={newStudentName}
|
||||||
onChange={(e) => setNewStudentName(e.target.value)}
|
onChange={(e) => setNewStudentName(e.target.value)}
|
||||||
placeholder={t("oobe.steps.students.studentName")}
|
placeholder={t("oobe.steps.students.studentName")}
|
||||||
onPressEnter={addStudent}
|
autoSize={{ minRows: 2, maxRows: 5 }}
|
||||||
/>
|
/>
|
||||||
<Button type="primary" icon={<PlusOutlined />} onClick={addStudent}>
|
<Button type="primary" icon={<PlusOutlined />} onClick={addStudent}>
|
||||||
{t("oobe.steps.students.addStudent")}
|
{t("oobe.steps.students.addStudent")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
{t("oobe.steps.students.manualHint")}
|
||||||
|
</Typography.Text>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
maxHeight: 150,
|
maxHeight: 150,
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
"import": "Import List",
|
"import": "Import List",
|
||||||
"manual": "Add Manually",
|
"manual": "Add Manually",
|
||||||
"importHint": "Supports Excel (.xlsx) or JSON files",
|
"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",
|
"dragDrop": "Drag and drop files here, or click to select",
|
||||||
"supportedFormats": "Supports .xlsx, .json formats",
|
"supportedFormats": "Supports .xlsx, .json formats",
|
||||||
"studentName": "Student Name",
|
"studentName": "Student Name",
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
"import": "导入名单",
|
"import": "导入名单",
|
||||||
"manual": "手动添加",
|
"manual": "手动添加",
|
||||||
"importHint": "支持 Excel (.xlsx) 或 JSON 文件",
|
"importHint": "支持 Excel (.xlsx) 或 JSON 文件",
|
||||||
"manualHint": "逐个添加学生姓名",
|
"manualHint": "支持粘贴多行文本,一行一个姓名",
|
||||||
"dragDrop": "拖拽文件到此处,或点击选择",
|
"dragDrop": "拖拽文件到此处,或点击选择",
|
||||||
"supportedFormats": "支持 .xlsx, .json 格式",
|
"supportedFormats": "支持 .xlsx, .json 格式",
|
||||||
"studentName": "学生姓名",
|
"studentName": "学生姓名",
|
||||||
|
|||||||
Reference in New Issue
Block a user