Merge pull request #7 from NanGua-QWQ/dev

Fix: 1,StudentMg和AutoCoreMg分页器错误. New: 1,增加了自动加分的排序拖拽按钮
This commit is contained in:
藏狐
2026-02-05 18:45:25 +08:00
committed by GitHub
4 changed files with 39 additions and 59 deletions
+2 -2
View File
@@ -93,8 +93,8 @@ export class WindowManager extends Service {
}
const baseOptions: BrowserWindowConstructorOptions = {
width: 900,
height: 670,
width: 1180,
height: 680,
show: false,
autoHideMenuBar: true,
frame: false,
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react'
import { MoveIcon } from 'tdesign-icons-react'
import {
Card,
Form,
@@ -40,6 +41,8 @@ export const AutoScoreManager: React.FC = () => {
const [rules, setRules] = useState<AutoScoreRule[]>([])
const [students, setStudents] = useState<{ id: number; name: string }[]>([])
const [loading, setLoading] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [pageSize, setPageSize] = useState<number>(50)
const [form] = Form.useForm()
const [editingRuleId, setEditingRuleId] = useState<number | null>(null)
@@ -233,6 +236,12 @@ export const AutoScoreManager: React.FC = () => {
}
const columns: PrimaryTableCol<AutoScoreRule>[] = [
{
colKey: 'drag',
title: '排序',
cell: () => <MoveIcon />,
width: 60
},
{
colKey: 'enabled',
title: '状态',
@@ -270,7 +279,7 @@ export const AutoScoreManager: React.FC = () => {
{
colKey: 'studentNames',
title: '适用学生',
width: 150,
width: 130,
cell: ({ row }) => {
if (row.studentNames.length === 0) {
return <span></span>
@@ -288,11 +297,11 @@ export const AutoScoreManager: React.FC = () => {
)
}
},
{ colKey: 'reason', title: '理由', ellipsis: true },
{ colKey: 'reason', title: '理由', width: 130, ellipsis: true },
{
colKey: 'lastExecuted',
title: '最后执行',
width: 150,
width: 180,
cell: ({ row }) => {
if (!row.lastExecuted) return <span></span>
try {
@@ -329,6 +338,8 @@ export const AutoScoreManager: React.FC = () => {
}
]
const onDragSort = (params: any) => setRules(params.newData);
return (
<div style={{ padding: '24px' }}>
<h2 style={{ marginBottom: '24px', color: 'var(--ss-text-main)' }}></h2>
@@ -417,16 +428,25 @@ export const AutoScoreManager: React.FC = () => {
<Card style={{ backgroundColor: 'var(--ss-card-bg)' }}>
<Table
data={rules}
data={rules.slice((currentPage - 1) * pageSize, currentPage * pageSize)}
columns={columns}
rowKey="id"
resizable
loading={loading}
pagination={{ defaultPageSize: 10 }}
dragSort="row-handler"
onDragSort={onDragSort}
pagination={{
current: currentPage,
pageSize,
total: rules.length,
onChange: (pageInfo) => setCurrentPage(pageInfo.current),
onPageSizeChange: (size) => setPageSize(size),
}}
style={{ color: 'var(--ss-text-main)' }}
/>
</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>
@@ -434,7 +454,7 @@ export const AutoScoreManager: React.FC = () => {
<li>如果"适用学生"字段为空,则规则适用于所有学生</li>
<li>可以随时启用/禁用规则,不会影响已保存的规则配置</li>
</ul>
</div>
</div> */}
</div>
)
}
-46
View File
@@ -263,52 +263,6 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
</div>
<Tabs value={activeTab} onChange={(v) => setActiveTab(v as string)}>
<Tabs.TabPanel value="auto-score" label="自动加分">
<Card style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}>
<div style={{ fontWeight: 600, marginBottom: '12px' }}></div>
<div style={{ marginBottom: '16px', color: 'var(--ss-text-secondary)' }}>
</div>
<Form labelWidth={120}>
<Form.FormItem label="启用自动加分">
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
<Button
theme={settings.auto_score_enabled ? 'success' : 'danger'}
variant="outline"
onClick={async () => {
if (!(window as any).api) return
const newValue = !settings.auto_score_enabled
const res = await (window as any).api.setSetting('auto_score_enabled', newValue)
if (res.success) {
setSettings((prev) => ({ ...prev, auto_score_enabled: newValue }))
MessagePlugin.success(`自动加分功能已${newValue ? '启用' : '禁用'}`)
} else {
MessagePlugin.error(res.message || `设置失败`)
}
}}
disabled={!canAdmin}
>
{settings.auto_score_enabled ? '已启用' : '已禁用'}
</Button>
<span style={{ fontSize: '12px', color: 'var(--ss-text-secondary)' }}>
{settings.auto_score_enabled
? '当前处于启用状态'
: '当前处于禁用状态'}
</span>
</div>
</Form.FormItem>
</Form>
<div style={{ marginTop: '16px', padding: '12px', backgroundColor: 'var(--ss-bg-color)', borderRadius: '4px', border: '1px solid var(--ss-border-color)' }}>
<div style={{ fontWeight: 500, marginBottom: '8px' }}>使</div>
<ul style={{ margin: 0, paddingLeft: '20px', color: 'var(--ss-text-secondary)' }}>
<li></li>
<li>"自动加分"</li>
<li></li>
<li></li>
</ul>
</div>
</Card>
</Tabs.TabPanel>
<Tabs.TabPanel value="appearance" label="外观">
<Card style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}>
<Form labelWidth={120}>
+10 -4
View File
@@ -18,6 +18,8 @@ interface student {
export const StudentManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
const [data, setData] = useState<student[]>([])
const [loading, setLoading] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [pageSize, setPageSize] = useState<number>(50)
const [visible, setVisible] = useState(false)
const [importVisible, setImportVisible] = useState(false)
const [xlsxVisible, setXlsxVisible] = useState(false)
@@ -338,14 +340,18 @@ export const StudentManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
</div>
<Table
data={data}
data={data.slice((currentPage - 1) * pageSize, currentPage * pageSize)}
columns={columns}
rowKey="id"
loading={loading}
bordered
hover
pagination={{ pageSize: 50, total: data.length, defaultCurrent: 1 }}
scroll={{ type: 'virtual', rowHeight: 48, threshold: 100 }}
pagination={{
current: currentPage,
pageSize,
total: data.length,
onChange: (pageInfo) => setCurrentPage(pageInfo.current),
onPageSizeChange: (size) => setPageSize(size),
}}
style={{ backgroundColor: 'var(--ss-card-bg)', color: 'var(--ss-text-main)' }}
/>