Skip to content

Commit 3d05282

Browse files
Merge pull request #7 from NanGua-QWQ/dev
Fix: 1,StudentMg和AutoCoreMg分页器错误. New: 1,增加了自动加分的排序拖拽按钮
2 parents ed8e9b6 + 08d58bb commit 3d05282

File tree

4 files changed

+39
-59
lines changed

4 files changed

+39
-59
lines changed

src/main/services/WindowManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export class WindowManager extends Service {
9393
}
9494

9595
const baseOptions: BrowserWindowConstructorOptions = {
96-
width: 900,
97-
height: 670,
96+
width: 1180,
97+
height: 680,
9898
show: false,
9999
autoHideMenuBar: true,
100100
frame: false,

src/renderer/src/components/AutoScoreManager.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useEffect } from 'react'
2+
import { MoveIcon } from 'tdesign-icons-react'
23
import {
34
Card,
45
Form,
@@ -40,6 +41,8 @@ export const AutoScoreManager: React.FC = () => {
4041
const [rules, setRules] = useState<AutoScoreRule[]>([])
4142
const [students, setStudents] = useState<{ id: number; name: string }[]>([])
4243
const [loading, setLoading] = useState(false)
44+
const [currentPage, setCurrentPage] = useState(1)
45+
const [pageSize, setPageSize] = useState<number>(50)
4346
const [form] = Form.useForm()
4447
const [editingRuleId, setEditingRuleId] = useState<number | null>(null)
4548

@@ -233,6 +236,12 @@ export const AutoScoreManager: React.FC = () => {
233236
}
234237

235238
const columns: PrimaryTableCol<AutoScoreRule>[] = [
239+
{
240+
colKey: 'drag',
241+
title: '排序',
242+
cell: () => <MoveIcon />,
243+
width: 60
244+
},
236245
{
237246
colKey: 'enabled',
238247
title: '状态',
@@ -270,7 +279,7 @@ export const AutoScoreManager: React.FC = () => {
270279
{
271280
colKey: 'studentNames',
272281
title: '适用学生',
273-
width: 150,
282+
width: 130,
274283
cell: ({ row }) => {
275284
if (row.studentNames.length === 0) {
276285
return <span>所有学生</span>
@@ -288,11 +297,11 @@ export const AutoScoreManager: React.FC = () => {
288297
)
289298
}
290299
},
291-
{ colKey: 'reason', title: '理由', ellipsis: true },
300+
{ colKey: 'reason', title: '理由', width: 130, ellipsis: true },
292301
{
293302
colKey: 'lastExecuted',
294303
title: '最后执行',
295-
width: 150,
304+
width: 180,
296305
cell: ({ row }) => {
297306
if (!row.lastExecuted) return <span>未执行</span>
298307
try {
@@ -329,6 +338,8 @@ export const AutoScoreManager: React.FC = () => {
329338
}
330339
]
331340

341+
const onDragSort = (params: any) => setRules(params.newData);
342+
332343
return (
333344
<div style={{ padding: '24px' }}>
334345
<h2 style={{ marginBottom: '24px', color: 'var(--ss-text-main)' }}>自动化加分管理</h2>
@@ -417,24 +428,33 @@ export const AutoScoreManager: React.FC = () => {
417428

418429
<Card style={{ backgroundColor: 'var(--ss-card-bg)' }}>
419430
<Table
420-
data={rules}
431+
data={rules.slice((currentPage - 1) * pageSize, currentPage * pageSize)}
421432
columns={columns}
422433
rowKey="id"
434+
resizable
423435
loading={loading}
424-
pagination={{ defaultPageSize: 10 }}
436+
dragSort="row-handler"
437+
onDragSort={onDragSort}
438+
pagination={{
439+
current: currentPage,
440+
pageSize,
441+
total: rules.length,
442+
onChange: (pageInfo) => setCurrentPage(pageInfo.current),
443+
onPageSizeChange: (size) => setPageSize(size),
444+
}}
425445
style={{ color: 'var(--ss-text-main)' }}
426446
/>
427447
</Card>
428448

429-
<div style={{ marginTop: '24px', padding: '16px', backgroundColor: 'var(--ss-card-bg)', borderRadius: '8px' }}>
449+
{/* <div style={{ marginTop: '24px', padding: '16px', backgroundColor: 'var(--ss-card-bg)', borderRadius: '8px' }}>
430450
<h3 style={{ marginBottom: '12px', color: 'var(--ss-text-main)' }}>使用说明</h3>
431451
<ul style={{ color: 'var(--ss-text-secondary)', lineHeight: '1.6' }}>
432452
<li>自动化加分功能会按照设定的时间间隔自动为学生加分</li>
433453
<li>间隔时间以分钟为单位,例如1440表示每24小时(一天)执行一次</li>
434454
<li>如果"适用学生"字段为空,则规则适用于所有学生</li>
435455
<li>可以随时启用/禁用规则,不会影响已保存的规则配置</li>
436456
</ul>
437-
</div>
457+
</div> */}
438458
</div>
439459
)
440460
}

src/renderer/src/components/Settings.tsx

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -263,52 +263,6 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
263263
</div>
264264

265265
<Tabs value={activeTab} onChange={(v) => setActiveTab(v as string)}>
266-
<Tabs.TabPanel value="auto-score" label="自动加分">
267-
<Card style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}>
268-
<div style={{ fontWeight: 600, marginBottom: '12px' }}>自动加分功能</div>
269-
<div style={{ marginBottom: '16px', color: 'var(--ss-text-secondary)' }}>
270-
自动加分功能会按照设定的时间间隔自动为学生加分。
271-
</div>
272-
<Form labelWidth={120}>
273-
<Form.FormItem label="启用自动加分">
274-
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
275-
<Button
276-
theme={settings.auto_score_enabled ? 'success' : 'danger'}
277-
variant="outline"
278-
onClick={async () => {
279-
if (!(window as any).api) return
280-
const newValue = !settings.auto_score_enabled
281-
const res = await (window as any).api.setSetting('auto_score_enabled', newValue)
282-
if (res.success) {
283-
setSettings((prev) => ({ ...prev, auto_score_enabled: newValue }))
284-
MessagePlugin.success(`自动加分功能已${newValue ? '启用' : '禁用'}`)
285-
} else {
286-
MessagePlugin.error(res.message || `设置失败`)
287-
}
288-
}}
289-
disabled={!canAdmin}
290-
>
291-
{settings.auto_score_enabled ? '已启用' : '已禁用'}
292-
</Button>
293-
<span style={{ fontSize: '12px', color: 'var(--ss-text-secondary)' }}>
294-
{settings.auto_score_enabled
295-
? '当前处于启用状态'
296-
: '当前处于禁用状态'}
297-
</span>
298-
</div>
299-
</Form.FormItem>
300-
</Form>
301-
<div style={{ marginTop: '16px', padding: '12px', backgroundColor: 'var(--ss-bg-color)', borderRadius: '4px', border: '1px solid var(--ss-border-color)' }}>
302-
<div style={{ fontWeight: 500, marginBottom: '8px' }}>使用说明:</div>
303-
<ul style={{ margin: 0, paddingLeft: '20px', color: 'var(--ss-text-secondary)' }}>
304-
<li>启用功能后,系统将按照设定的规则自动为学生加分</li>
305-
<li>在"自动加分"菜单中可以创建和管理加分规则</li>
306-
<li>每个规则可以设置不同的时间间隔、加分值和适用学生</li>
307-
<li>请谨慎设置,避免积分增长过快</li>
308-
</ul>
309-
</div>
310-
</Card>
311-
</Tabs.TabPanel>
312266
<Tabs.TabPanel value="appearance" label="外观">
313267
<Card style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}>
314268
<Form labelWidth={120}>

src/renderer/src/components/StudentManager.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface student {
1818
export const StudentManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
1919
const [data, setData] = useState<student[]>([])
2020
const [loading, setLoading] = useState(false)
21+
const [currentPage, setCurrentPage] = useState(1)
22+
const [pageSize, setPageSize] = useState<number>(50)
2123
const [visible, setVisible] = useState(false)
2224
const [importVisible, setImportVisible] = useState(false)
2325
const [xlsxVisible, setXlsxVisible] = useState(false)
@@ -338,14 +340,18 @@ export const StudentManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
338340
</div>
339341

340342
<Table
341-
data={data}
343+
data={data.slice((currentPage - 1) * pageSize, currentPage * pageSize)}
342344
columns={columns}
343345
rowKey="id"
344346
loading={loading}
345-
bordered
346347
hover
347-
pagination={{ pageSize: 50, total: data.length, defaultCurrent: 1 }}
348-
scroll={{ type: 'virtual', rowHeight: 48, threshold: 100 }}
348+
pagination={{
349+
current: currentPage,
350+
pageSize,
351+
total: data.length,
352+
onChange: (pageInfo) => setCurrentPage(pageInfo.current),
353+
onPageSizeChange: (size) => setPageSize(size),
354+
}}
349355
style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}
350356
/>
351357

0 commit comments

Comments
 (0)