mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
过下pnpm lint
This commit is contained in:
+43
-39
@@ -139,67 +139,71 @@ function MainContent(): React.JSX.Element {
|
||||
/>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<div style={{
|
||||
position: 'fixed',
|
||||
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
display: 'flex',
|
||||
bottom: '2px',
|
||||
left: '20px',
|
||||
opacity: 0.6,
|
||||
zIndex: 9999
|
||||
}}>
|
||||
<p style={{
|
||||
color: '#de2611',
|
||||
fontWeight: 'bold',
|
||||
fontSize: '13px',
|
||||
pointerEvents: 'none',
|
||||
}}>
|
||||
开发中画面,不代表最终品质
|
||||
</p>
|
||||
<p style={{
|
||||
color: '#44474b',
|
||||
fontWeight: 'bold',
|
||||
fontSize: '13px',
|
||||
paddingLeft: '5px',
|
||||
}}>
|
||||
SecScore Dev ({getPlatform()}-{getArchitecture()})
|
||||
</p>
|
||||
bottom: '2px',
|
||||
left: '20px',
|
||||
opacity: 0.6,
|
||||
zIndex: 9999
|
||||
}}
|
||||
>
|
||||
<p
|
||||
style={{
|
||||
color: '#de2611',
|
||||
fontWeight: 'bold',
|
||||
fontSize: '13px',
|
||||
pointerEvents: 'none'
|
||||
}}
|
||||
>
|
||||
开发中画面,不代表最终品质
|
||||
</p>
|
||||
<p
|
||||
style={{
|
||||
color: '#44474b',
|
||||
fontWeight: 'bold',
|
||||
fontSize: '13px',
|
||||
paddingLeft: '5px'
|
||||
}}
|
||||
>
|
||||
SecScore Dev ({getPlatform()}-{getArchitecture()})
|
||||
</p>
|
||||
</div>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
function getArchitecture(): string {
|
||||
|
||||
// 尝试从 userAgent 中获取架构信息
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
const userAgent = navigator.userAgent.toLowerCase()
|
||||
|
||||
if (userAgent.includes('arm64') || userAgent.includes('aarch64')) {
|
||||
return 'ARM64';
|
||||
return 'ARM64'
|
||||
} else if (userAgent.includes('x64') || userAgent.includes('amd64')) {
|
||||
return 'x64';
|
||||
return 'x64'
|
||||
} else if (userAgent.includes('i386') || userAgent.includes('i686')) {
|
||||
return 'x86';
|
||||
return 'x86'
|
||||
}
|
||||
|
||||
|
||||
// 默认返回未知架构
|
||||
return userAgent;
|
||||
return userAgent
|
||||
}
|
||||
|
||||
function getPlatform(): string {
|
||||
|
||||
// 尝试从 userAgent 中获取平台信息
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
const userAgent = navigator.userAgent.toLowerCase()
|
||||
|
||||
if (userAgent.includes('windows')) {
|
||||
return 'Windows';
|
||||
return 'Windows'
|
||||
} else if (userAgent.includes('mac')) {
|
||||
return 'Mac';
|
||||
return 'Mac'
|
||||
} else if (userAgent.includes('linux')) {
|
||||
return 'Linux';
|
||||
return 'Linux'
|
||||
}
|
||||
|
||||
return 'Unknown';
|
||||
return 'Unknown'
|
||||
}
|
||||
function App(): React.JSX.Element {
|
||||
return (
|
||||
|
||||
@@ -52,7 +52,7 @@ export const AutoScoreManager: React.FC = () => {
|
||||
|
||||
const fetchRules = async () => {
|
||||
if (!(window as any).api) return
|
||||
|
||||
|
||||
setLoading(true)
|
||||
try {
|
||||
// 权限检查:确保当前为 admin
|
||||
@@ -93,20 +93,23 @@ export const AutoScoreManager: React.FC = () => {
|
||||
}, [])
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!(window as any).api) return;
|
||||
if (!(window as any).api) return
|
||||
|
||||
const values = form.getFieldsValue(true) as unknown as AutoScoreRuleFormValues & { timeUnit: string };
|
||||
const values = form.getFieldsValue(true) as unknown as AutoScoreRuleFormValues & {
|
||||
timeUnit: string
|
||||
}
|
||||
|
||||
if (!values.name || values.intervalMinutes == null || values.scoreValue == null) {
|
||||
MessagePlugin.warning('请填写完整信息');
|
||||
return;
|
||||
MessagePlugin.warning('请填写完整信息')
|
||||
return
|
||||
}
|
||||
|
||||
// 根据单位转换间隔时间
|
||||
const intervalMinutes = values.timeUnit === 'days' ? values.intervalMinutes * 1440 : values.intervalMinutes;
|
||||
const intervalMinutes =
|
||||
values.timeUnit === 'days' ? values.intervalMinutes * 1440 : values.intervalMinutes
|
||||
|
||||
// 确保 studentNames 是数组类型
|
||||
const studentNames = Array.isArray(values.studentNames) ? values.studentNames : [];
|
||||
const studentNames = Array.isArray(values.studentNames) ? values.studentNames : []
|
||||
|
||||
const triggersPayload = triggerList.map((t) => ({ event: t.eventName, value: t.value }))
|
||||
|
||||
@@ -118,7 +121,7 @@ export const AutoScoreManager: React.FC = () => {
|
||||
scoreValue: values.scoreValue,
|
||||
reason: values.reason || `自动化加分 - ${values.name}`,
|
||||
triggers: triggersPayload
|
||||
};
|
||||
}
|
||||
|
||||
// 权限检查:仅管理员可创建/更新自动化
|
||||
try {
|
||||
@@ -168,7 +171,9 @@ export const AutoScoreManager: React.FC = () => {
|
||||
setTriggerList([])
|
||||
fetchRules() // 刷新自动化列表
|
||||
} else {
|
||||
MessagePlugin.error(res.message || (editingRuleId !== null ? '更新自动化失败' : '创建自动化失败'))
|
||||
MessagePlugin.error(
|
||||
res.message || (editingRuleId !== null ? '更新自动化失败' : '创建自动化失败')
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to submit auto score rule:', error)
|
||||
@@ -268,11 +273,11 @@ export const AutoScoreManager: React.FC = () => {
|
||||
}
|
||||
|
||||
const columns: PrimaryTableCol<AutoScoreRule>[] = [
|
||||
{
|
||||
colKey: 'drag',
|
||||
title: '排序',
|
||||
cell: () => <MoveIcon />,
|
||||
width: 60
|
||||
{
|
||||
colKey: 'drag',
|
||||
title: '排序',
|
||||
cell: () => <MoveIcon />,
|
||||
width: 60
|
||||
},
|
||||
{
|
||||
colKey: 'enabled',
|
||||
@@ -318,12 +323,7 @@ export const AutoScoreManager: React.FC = () => {
|
||||
}
|
||||
const studentList = row.studentNames.join(',\n')
|
||||
return (
|
||||
<TooltipLite
|
||||
content={studentList}
|
||||
showArrow
|
||||
placement="mouse"
|
||||
theme="default"
|
||||
>
|
||||
<TooltipLite content={studentList} showArrow placement="mouse" theme="default">
|
||||
{row.studentNames.length} 名学生
|
||||
</TooltipLite>
|
||||
)
|
||||
@@ -350,17 +350,10 @@ export const AutoScoreManager: React.FC = () => {
|
||||
width: 150,
|
||||
cell: ({ row }) => (
|
||||
<Space>
|
||||
<Button
|
||||
size="small"
|
||||
variant="outline"
|
||||
onClick={() => handleEdit(row)}
|
||||
>
|
||||
<Button size="small" variant="outline" onClick={() => handleEdit(row)}>
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm
|
||||
content="确定要删除这条自动化吗?"
|
||||
onConfirm={() => handleDelete(row.id)}
|
||||
>
|
||||
<Popconfirm content="确定要删除这条自动化吗?" onConfirm={() => handleDelete(row.id)}>
|
||||
<Button size="small" variant="outline" theme="danger">
|
||||
删除
|
||||
</Button>
|
||||
@@ -369,31 +362,57 @@ export const AutoScoreManager: React.FC = () => {
|
||||
)
|
||||
}
|
||||
]
|
||||
const onDragSort = (params: any) => setRules(params.newData);
|
||||
|
||||
const onDragSort = (params: any) => setRules(params.newData)
|
||||
|
||||
type TriggerDef = {
|
||||
id: number
|
||||
label: string
|
||||
description: string
|
||||
eventName: string
|
||||
valueType?: "DatePicker" | "Input"
|
||||
valueType?: 'DatePicker' | 'Input'
|
||||
}
|
||||
|
||||
const allTriggers: TriggerDef[] = [
|
||||
{ id: 1, label: '根据间隔时间触发', description: '当学生注册时触发自动化', eventName: 'interval_time_passed', valueType: 'DatePicker' },
|
||||
{ id: 2, label: '按照学生标签触发', description: '当学生完成作业时触发自动化', eventName: 'student_tag_matched', valueType: 'Input' },
|
||||
{ id: 3, label: '随机时间触发', description: '当随机时间到达时触发自动化', eventName: 'random_time_reached' }
|
||||
{
|
||||
id: 1,
|
||||
label: '根据间隔时间触发',
|
||||
description: '当学生注册时触发自动化',
|
||||
eventName: 'interval_time_passed',
|
||||
valueType: 'DatePicker'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: '按照学生标签触发',
|
||||
description: '当学生完成作业时触发自动化',
|
||||
eventName: 'student_tag_matched',
|
||||
valueType: 'Input'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
label: '随机时间触发',
|
||||
description: '当随机时间到达时触发自动化',
|
||||
eventName: 'random_time_reached'
|
||||
}
|
||||
]
|
||||
|
||||
const triggerOptions = allTriggers.map((t) => ({ label: t.label, value: t.eventName }))
|
||||
|
||||
// triggerList items only need id, eventName, haveValue and value
|
||||
type TriggerItem = { id: number; eventName: string; value?: string; valueType?: "DatePicker" | "Input" }
|
||||
type TriggerItem = {
|
||||
id: number
|
||||
eventName: string
|
||||
value?: string
|
||||
valueType?: 'DatePicker' | 'Input'
|
||||
}
|
||||
const [triggerList, setTriggerList] = useState<TriggerItem[]>([])
|
||||
|
||||
const handleTriggerChange = (id: number, value: string) => {
|
||||
const found = allTriggers.find((a) => a.eventName === value)
|
||||
setTriggerList((prev) => prev.map((t) => (t.id === id ? { ...t, eventName: value, valueType: found?.valueType, value: '' } : t)))
|
||||
setTriggerList((prev) =>
|
||||
prev.map((t) =>
|
||||
t.id === id ? { ...t, eventName: value, valueType: found?.valueType, value: '' } : t
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const handleValueChange = (id: number, val: string) => {
|
||||
@@ -407,7 +426,15 @@ export const AutoScoreManager: React.FC = () => {
|
||||
const handleAddTrigger = () => {
|
||||
const nextId = triggerList.length ? Math.max(...triggerList.map((t) => t.id)) + 1 : 1
|
||||
const defaultTrigger = allTriggers[0]
|
||||
setTriggerList((prev) => [...prev, { id: nextId, eventName: defaultTrigger.eventName, valueType: defaultTrigger.valueType, value: '' }])
|
||||
setTriggerList((prev) => [
|
||||
...prev,
|
||||
{
|
||||
id: nextId,
|
||||
eventName: defaultTrigger.eventName,
|
||||
valueType: defaultTrigger.valueType,
|
||||
value: ''
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
const triggerItems = triggerList
|
||||
@@ -440,24 +467,21 @@ export const AutoScoreManager: React.FC = () => {
|
||||
placeholder="请输入Value"
|
||||
style={{ width: '150px' }}
|
||||
value={String(triggerTest.value ?? '')}
|
||||
onChange={(v) => handleValueChange(triggerTest.id, String((v as any).target?.value ?? v))}
|
||||
onChange={(v) =>
|
||||
handleValueChange(triggerTest.id, String((v as any).target?.value ?? v))
|
||||
}
|
||||
/>
|
||||
)
|
||||
) : null}
|
||||
</div>
|
||||
))
|
||||
|
||||
|
||||
return (
|
||||
<div style={{ padding: '24px' }}>
|
||||
<h2 style={{ marginBottom: '24px', color: 'var(--ss-text-main)' }}>自动化加分管理</h2>
|
||||
|
||||
<Card style={{ marginBottom: '24px', backgroundColor: 'var(--ss-card-bg)' }}>
|
||||
<Form
|
||||
form={form}
|
||||
labelWidth={100}
|
||||
onReset={handleResetForm}
|
||||
>
|
||||
<Form form={form} labelWidth={100} onReset={handleResetForm}>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '24px' }}>
|
||||
<Form.FormItem
|
||||
label="自动化名称"
|
||||
@@ -470,13 +494,13 @@ export const AutoScoreManager: React.FC = () => {
|
||||
<Form.FormItem>
|
||||
<Space>
|
||||
<Form.FormItem
|
||||
label="间隔时间"
|
||||
name="intervalMinutes"
|
||||
rules={[
|
||||
{ required: true, message: '请输入间隔时间' },
|
||||
{ min: 1, message: '间隔时间至少为1分钟/天' }
|
||||
]}
|
||||
style={{ marginBottom: 0 }}
|
||||
label="间隔时间"
|
||||
name="intervalMinutes"
|
||||
rules={[
|
||||
{ required: true, message: '请输入间隔时间' },
|
||||
{ min: 1, message: '间隔时间至少为1分钟/天' }
|
||||
]}
|
||||
style={{ marginBottom: 0 }}
|
||||
>
|
||||
<InputNumber min={1} placeholder="例如:1(每隔1分钟/天执行一次)" />
|
||||
</Form.FormItem>
|
||||
@@ -497,43 +521,31 @@ export const AutoScoreManager: React.FC = () => {
|
||||
<InputNumber placeholder="例如:1(每次加1分)" />
|
||||
</Form.FormItem>
|
||||
|
||||
<Form.FormItem
|
||||
label="适用学生"
|
||||
name="studentNames"
|
||||
>
|
||||
<Select
|
||||
filterable
|
||||
multiple
|
||||
placeholder="请选择或搜索学生(留空表示所有学生)"
|
||||
options={students.map((student) => ({ label: student.name, value: student.name }))}
|
||||
/>
|
||||
<Form.FormItem label="适用学生" name="studentNames">
|
||||
<Select
|
||||
filterable
|
||||
multiple
|
||||
placeholder="请选择或搜索学生(留空表示所有学生)"
|
||||
options={students.map((student) => ({ label: student.name, value: student.name }))}
|
||||
/>
|
||||
</Form.FormItem>
|
||||
|
||||
<Form.FormItem
|
||||
label="加分理由"
|
||||
name="reason"
|
||||
>
|
||||
<Form.FormItem label="加分理由" name="reason">
|
||||
<Input placeholder="例如:每日签到奖励" />
|
||||
</Form.FormItem>
|
||||
</div>
|
||||
|
||||
<div style={{ marginTop: '24px', display: 'flex', gap: '12px' }}>
|
||||
<Button
|
||||
theme="primary"
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
<Button theme="primary" onClick={handleSubmit}>
|
||||
{editingRuleId !== null ? '更新自动化' : '添加自动化'}
|
||||
</Button>
|
||||
<Button
|
||||
type="reset"
|
||||
variant="outline"
|
||||
>
|
||||
<Button type="reset" variant="outline">
|
||||
{editingRuleId !== null ? '取消编辑' : '重置表单'}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
</Card>
|
||||
<Card style={{ marginBottom: '24px',backgroundColor: 'var(--ss-card-bg)' }}>
|
||||
<Card style={{ marginBottom: '24px', backgroundColor: 'var(--ss-card-bg)' }}>
|
||||
<Table
|
||||
data={rules.slice((currentPage - 1) * pageSize, currentPage * pageSize)}
|
||||
columns={columns}
|
||||
@@ -547,32 +559,37 @@ export const AutoScoreManager: React.FC = () => {
|
||||
pageSize,
|
||||
total: rules.length,
|
||||
onChange: (pageInfo) => setCurrentPage(pageInfo.current),
|
||||
onPageSizeChange: (size) => setPageSize(size),
|
||||
onPageSizeChange: (size) => setPageSize(size)
|
||||
}}
|
||||
style={{ color: 'var(--ss-text-main)' }}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Card style={{ marginBottom: '24px', backgroundColor: 'var(--ss-card-bg)' }} title="当以下事件触发时" headerBordered>
|
||||
<Space style={{ display: "grid" }}>
|
||||
<Card
|
||||
style={{ marginBottom: '24px', backgroundColor: 'var(--ss-card-bg)' }}
|
||||
title="当以下事件触发时"
|
||||
headerBordered
|
||||
>
|
||||
<Space style={{ display: 'grid' }}>
|
||||
{triggerItems}
|
||||
<Button
|
||||
theme="default"
|
||||
variant="text"
|
||||
style={{ fontWeight: 'bolder', fontSize: 15 }}
|
||||
icon={<AddIcon strokeWidth={3}/>}
|
||||
onClick={handleAddTrigger}>
|
||||
<Button
|
||||
theme="default"
|
||||
variant="text"
|
||||
style={{ fontWeight: 'bolder', fontSize: 15 }}
|
||||
icon={<AddIcon strokeWidth={3} />}
|
||||
onClick={handleAddTrigger}
|
||||
>
|
||||
添加触发器
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
<Card style={{ marginBottom: '24px' , backgroundColor: 'var(--ss-card-bg)' }}>
|
||||
<Card style={{ marginBottom: '24px', backgroundColor: 'var(--ss-card-bg)' }}>
|
||||
<SyntaxHighlighter language="javascript" style={prism} showLineNumbers>
|
||||
println("这是一个示例代码块,展示如何使用自动化加分功能的API接口")
|
||||
</SyntaxHighlighter>
|
||||
</Card>
|
||||
{/* <div style={{ marginTop: '24px', padding: '16px', backgroundColor: 'var(--ss-card-bg)', borderRadius: '8px' }}>
|
||||
{/* <div style={{ marginTop: '24px', padding: '16px', backgroundColor: 'var(--ss-card-bg)', borderRadius: '8px' }}>
|
||||
<h3 style={{ marginBottom: '12px', color: 'var(--ss-text-main)' }}>使用说明</h3>
|
||||
<ul style={{ color: 'var(--ss-text-secondary)', lineHeight: '1.6' }}>
|
||||
<li>自动化加分功能会按照设定的时间间隔自动为学生加分</li>
|
||||
@@ -583,4 +600,4 @@ export const AutoScoreManager: React.FC = () => {
|
||||
</div> */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +138,11 @@ export const ScoreManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
return
|
||||
}
|
||||
const values = form.getFieldsValue(true) as any
|
||||
|
||||
|
||||
// 支持多选学生
|
||||
const studentNames = Array.isArray(values.student_name) ? values.student_name : [values.student_name]
|
||||
const studentNames = Array.isArray(values.student_name)
|
||||
? values.student_name
|
||||
: [values.student_name]
|
||||
if (!studentNames || studentNames.length === 0 || !values.reason_content) {
|
||||
MessagePlugin.warning('请填写完整信息')
|
||||
return
|
||||
|
||||
@@ -62,7 +62,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
const [settleDialogVisible, setSettleDialogVisible] = useState(false)
|
||||
|
||||
const [urlRegisterLoading, setUrlRegisterLoading] = useState(false)
|
||||
|
||||
|
||||
// HTTP Server状态
|
||||
const [httpServerStatus, setHttpServerStatus] = useState<{
|
||||
isRunning: boolean
|
||||
@@ -111,7 +111,8 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
if (change?.key === 'is_wizard_completed')
|
||||
return { ...prev, is_wizard_completed: change.value }
|
||||
if (change?.key === 'window_zoom') return { ...prev, window_zoom: change.value }
|
||||
if (change?.key === 'auto_score_enabled') return { ...prev, auto_score_enabled: change.value }
|
||||
if (change?.key === 'auto_score_enabled')
|
||||
return { ...prev, auto_score_enabled: change.value }
|
||||
return prev
|
||||
})
|
||||
})
|
||||
@@ -259,7 +260,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
if (!(window as any).api) return
|
||||
setSettleDialogVisible(true)
|
||||
}
|
||||
|
||||
|
||||
// HTTP Server函数
|
||||
const refreshHttpServerStatus = async () => {
|
||||
if (!(window as any).api) return
|
||||
@@ -275,7 +276,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
console.error('Failed to refresh HTTP server status:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const handleHttpServerStart = async () => {
|
||||
if (!(window as any).api) return
|
||||
setHttpLoading(true)
|
||||
@@ -291,7 +292,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
if (httpCorsOrigin.trim()) {
|
||||
config.corsOrigin = httpCorsOrigin.trim()
|
||||
}
|
||||
|
||||
|
||||
const res = await (window as any).api.httpServerStart(config)
|
||||
if (res.success) {
|
||||
MessagePlugin.success(`HTTP服务器已启动: ${res.data.url}`)
|
||||
@@ -306,7 +307,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
setHttpLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const handleHttpServerStop = async () => {
|
||||
if (!(window as any).api) return
|
||||
setHttpLoading(true)
|
||||
@@ -632,14 +633,11 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
>
|
||||
通过HTTP API提供学生分数查询服务,可在局域网内访问。
|
||||
</div>
|
||||
|
||||
|
||||
<Form labelWidth={120}>
|
||||
<Form.FormItem label="服务器状态">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<Tag
|
||||
theme={httpServerStatus?.isRunning ? 'success' : 'default'}
|
||||
variant="light"
|
||||
>
|
||||
<Tag theme={httpServerStatus?.isRunning ? 'success' : 'default'} variant="light">
|
||||
{httpServerStatus?.isRunning ? '运行中' : '已停止'}
|
||||
</Tag>
|
||||
{httpServerStatus?.isRunning && (
|
||||
@@ -649,7 +647,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
)}
|
||||
</div>
|
||||
</Form.FormItem>
|
||||
|
||||
|
||||
<Form.FormItem label="端口设置">
|
||||
<Input
|
||||
value={httpPort}
|
||||
@@ -659,7 +657,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
disabled={!canAdmin || httpLoading}
|
||||
/>
|
||||
</Form.FormItem>
|
||||
|
||||
|
||||
<Form.FormItem label="主机地址">
|
||||
<Input
|
||||
value={httpHost}
|
||||
@@ -669,7 +667,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
disabled={!canAdmin || httpLoading}
|
||||
/>
|
||||
</Form.FormItem>
|
||||
|
||||
|
||||
<Form.FormItem label="CORS来源">
|
||||
<Input
|
||||
value={httpCorsOrigin}
|
||||
@@ -678,11 +676,13 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
style={{ width: '200px' }}
|
||||
disabled={!canAdmin || httpLoading}
|
||||
/>
|
||||
<div style={{ marginTop: '4px', fontSize: '12px', color: 'var(--ss-text-secondary)' }}>
|
||||
<div
|
||||
style={{ marginTop: '4px', fontSize: '12px', color: 'var(--ss-text-secondary)' }}
|
||||
>
|
||||
* 表示允许所有来源,建议在生产环境中设置具体域名
|
||||
</div>
|
||||
</Form.FormItem>
|
||||
|
||||
|
||||
<Form.FormItem label="操作">
|
||||
<Space>
|
||||
<Button
|
||||
@@ -711,9 +711,11 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.FormItem>
|
||||
|
||||
|
||||
<Form.FormItem label="API端点">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '4px', fontSize: '12px' }}>
|
||||
<div
|
||||
style={{ display: 'flex', flexDirection: 'column', gap: '4px', fontSize: '12px' }}
|
||||
>
|
||||
<div>• GET /health - 健康检查</div>
|
||||
<div>• GET /api/students/scores - 获取所有学生分数</div>
|
||||
<div>• GET /api/students/:id/score - 获取单个学生分数</div>
|
||||
@@ -724,7 +726,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
||||
</Form>
|
||||
</Card>
|
||||
</Tabs.TabPanel>
|
||||
|
||||
|
||||
<Tabs.TabPanel value="url" label="URL 链接">
|
||||
<Card style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}>
|
||||
<div style={{ fontSize: '16px', fontWeight: 600, marginBottom: '8px' }}>
|
||||
|
||||
@@ -68,7 +68,9 @@ export function Sidebar({ activeMenu, permission, onMenuChange }: SidebarProps):
|
||||
|
||||
<div style={{ flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column' }}>
|
||||
<Menu value={activeMenu} onChange={onMenuChange} style={{ width: '100%', border: 'none' }}>
|
||||
<Menu.MenuItem value="home" icon={<HomeIcon />}> 主页
|
||||
<Menu.MenuItem value="home" icon={<HomeIcon />}>
|
||||
{' '}
|
||||
主页
|
||||
</Menu.MenuItem>
|
||||
<Menu.MenuItem value="students" icon={<UserIcon />} disabled={permission !== 'admin'}>
|
||||
学生管理
|
||||
@@ -76,13 +78,13 @@ export function Sidebar({ activeMenu, permission, onMenuChange }: SidebarProps):
|
||||
<Menu.MenuItem value="score" icon={<HistoryIcon />}>
|
||||
积分管理
|
||||
</Menu.MenuItem>
|
||||
<Menu.MenuItem value="auto-score" icon={<ReplayIcon />}>
|
||||
<Menu.MenuItem value="auto-score" icon={<ReplayIcon />}>
|
||||
自动加分
|
||||
</Menu.MenuItem>
|
||||
<Menu.MenuItem value="leaderboard" icon={<ViewListIcon />}>
|
||||
<Menu.MenuItem value="leaderboard" icon={<ViewListIcon />}>
|
||||
排行榜
|
||||
</Menu.MenuItem>
|
||||
<Menu.MenuItem value="settlements" icon={<HistoryIcon />}>
|
||||
<Menu.MenuItem value="settlements" icon={<HistoryIcon />}>
|
||||
结算历史
|
||||
</Menu.MenuItem>
|
||||
<Menu.MenuItem value="reasons" icon={<RootListIcon />} disabled={permission !== 'admin'}>
|
||||
|
||||
@@ -382,7 +382,7 @@ export const StudentManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
{tags.length === 0 ? (
|
||||
<span style={{ color: 'var(--ss-text-secondary)' }}>无标签</span>
|
||||
) : (
|
||||
tags.slice(0, 3).map(tag => (
|
||||
tags.slice(0, 3).map((tag) => (
|
||||
<Tag key={tag} theme="primary" size="small">
|
||||
{tag}
|
||||
</Tag>
|
||||
@@ -449,7 +449,7 @@ export const StudentManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
pageSize,
|
||||
total: data.length,
|
||||
onChange: (pageInfo) => setCurrentPage(pageInfo.current),
|
||||
onPageSizeChange: (size) => setPageSize(size),
|
||||
onPageSizeChange: (size) => setPageSize(size)
|
||||
}}
|
||||
style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}
|
||||
/>
|
||||
|
||||
@@ -26,8 +26,8 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
const [allTags, setAllTags] = useState<Tag[]>([])
|
||||
const [selectedTagIds, setSelectedTagIds] = useState<Set<number>>(new Set(initialTagIds))
|
||||
const { currentTheme } = useTheme() // 获取当前主题
|
||||
|
||||
const themeMode = currentTheme?.mode || 'light'; // 默认为 light
|
||||
|
||||
const themeMode = currentTheme?.mode || 'light' // 默认为 light
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
@@ -59,10 +59,10 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
return
|
||||
}
|
||||
|
||||
if (allTags.some(t => t.name === trimmed)) {
|
||||
const existingTag = allTags.find(t => t.name === trimmed)
|
||||
if (allTags.some((t) => t.name === trimmed)) {
|
||||
const existingTag = allTags.find((t) => t.name === trimmed)
|
||||
if (existingTag) {
|
||||
setSelectedTagIds(prev => new Set([...prev, existingTag.id]))
|
||||
setSelectedTagIds((prev) => new Set([...prev, existingTag.id]))
|
||||
}
|
||||
setInputValue('')
|
||||
return
|
||||
@@ -71,8 +71,8 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
try {
|
||||
const res = await (window as any).api.tagsCreate(trimmed)
|
||||
if (res.success && res.data) {
|
||||
setAllTags(prev => [...prev, res.data])
|
||||
setSelectedTagIds(prev => new Set([...prev, res.data.id]))
|
||||
setAllTags((prev) => [...prev, res.data])
|
||||
setSelectedTagIds((prev) => new Set([...prev, res.data.id]))
|
||||
setInputValue('')
|
||||
} else {
|
||||
MessagePlugin.error(res.message || '添加标签失败')
|
||||
@@ -84,7 +84,7 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
}
|
||||
|
||||
const handleToggleTag = (tagId: number) => {
|
||||
setSelectedTagIds(prev => {
|
||||
setSelectedTagIds((prev) => {
|
||||
const newSet = new Set(prev)
|
||||
if (newSet.has(tagId)) {
|
||||
newSet.delete(tagId)
|
||||
@@ -99,8 +99,8 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
try {
|
||||
const res = await (window as any).api.tagsDelete(tagId)
|
||||
if (res.success) {
|
||||
setAllTags(prev => prev.filter(t => t.id !== tagId))
|
||||
setSelectedTagIds(prev => {
|
||||
setAllTags((prev) => prev.filter((t) => t.id !== tagId))
|
||||
setSelectedTagIds((prev) => {
|
||||
const newSet = new Set(prev)
|
||||
newSet.delete(tagId)
|
||||
return newSet
|
||||
@@ -115,7 +115,7 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
/* const handleKeyDown = (value: string, context: { e: React.KeyboardEvent<HTMLInputElement> }) => {
|
||||
/* const handleKeyDown = (value: string, context: { e: React.KeyboardEvent<HTMLInputElement> }) => {
|
||||
if (context.e.key === 'Enter') {
|
||||
context.e.preventDefault()
|
||||
handleAddTag()
|
||||
@@ -127,8 +127,8 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
onClose()
|
||||
}
|
||||
|
||||
const selectedTags = allTags.filter(t => selectedTagIds.has(t.id))
|
||||
const availableTags = allTags.filter(t => !selectedTagIds.has(t.id))
|
||||
const selectedTags = allTags.filter((t) => selectedTagIds.has(t.id))
|
||||
const availableTags = allTags.filter((t) => !selectedTagIds.has(t.id))
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@@ -149,14 +149,10 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
value={inputValue}
|
||||
onChange={setInputValue}
|
||||
onEnter={handleAddTag}
|
||||
/* maxLength={50} */
|
||||
/* maxLength={50} */
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
<Button
|
||||
theme="primary"
|
||||
onClick={handleAddTag}
|
||||
disabled={!inputValue.trim()}
|
||||
>
|
||||
<Button theme="primary" onClick={handleAddTag} disabled={!inputValue.trim()}>
|
||||
添加
|
||||
</Button>
|
||||
</div>
|
||||
@@ -166,7 +162,14 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
<div style={{ fontSize: '14px', color: 'var(--ss-text-secondary)', marginBottom: '8px' }}>
|
||||
已选标签(点击取消)
|
||||
</div>
|
||||
<div style={{ minHeight: '50px', padding: '12px', backgroundColor: 'var(--ss-card-bg)', borderRadius: '4px' }}>
|
||||
<div
|
||||
style={{
|
||||
minHeight: '50px',
|
||||
padding: '12px',
|
||||
backgroundColor: 'var(--ss-card-bg)',
|
||||
borderRadius: '4px'
|
||||
}}
|
||||
>
|
||||
{selectedTags.length === 0 ? (
|
||||
<span style={{ color: 'var(--ss-text-secondary)' }}>未选择标签</span>
|
||||
) : (
|
||||
@@ -193,7 +196,14 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
<div style={{ fontSize: '14px', color: 'var(--ss-text-secondary)', marginBottom: '8px' }}>
|
||||
可选标签(点击选择)
|
||||
</div>
|
||||
<div style={{ minHeight: '50px', padding: '12px', backgroundColor: 'var(--ss-card-bg)', borderRadius: '4px' }}>
|
||||
<div
|
||||
style={{
|
||||
minHeight: '50px',
|
||||
padding: '12px',
|
||||
backgroundColor: 'var(--ss-card-bg)',
|
||||
borderRadius: '4px'
|
||||
}}
|
||||
>
|
||||
{availableTags.length === 0 ? (
|
||||
<span style={{ color: 'var(--ss-text-secondary)' }}>无可用标签</span>
|
||||
) : (
|
||||
@@ -218,4 +228,4 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user