Skip to content

Commit 2652a48

Browse files
authored
Merge pull request #13 from NanGua-QWQ/main
推送一个稳定版本
2 parents 27e85b6 + efa78f2 commit 2652a48

File tree

12 files changed

+49
-46
lines changed

12 files changed

+49
-46
lines changed

eslint.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default defineConfig(
3131
'react-refresh/only-export-components': 'off',
3232
'react-hooks/exhaustive-deps': 'warn',
3333
'react-hooks/set-state-in-effect': 'off',
34-
'@typescript-eslint/no-require-imports': 'off'
34+
'@typescript-eslint/no-require-imports': 'off',
35+
// we use TypeScript types instead of PropTypes in React components
36+
'react/prop-types': 'off'
3537
}
3638
},
3739
eslintConfigPrettier

src/main/db/migrations/InitSchema2026011800000.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class InitSchema2026011800000 implements MigrationInterface {
8181
('迟到','纪律',-1,1,CURRENT_TIMESTAMP),
8282
('未交作业','作业情况',-2,1,CURRENT_TIMESTAMP)
8383
`)
84-
84+
8585
if (!(await queryRunner.hasTable('tags'))) {
8686
await queryRunner.query(`
8787
CREATE TABLE "tags" (

src/main/services/AutoScoreService.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class AutoScoreService extends Service {
357357

358358
// 使用AND/OR逻辑评估触发器
359359
const matchedStudents = this.evaluateTriggersWithLogic(rule, studentsToScore)
360-
360+
361361
if (matchedStudents.length > 0) {
362362
for (const action of rule.actions || []) {
363363
await this.executeAction(action, matchedStudents, rule.name)
@@ -387,7 +387,7 @@ export class AutoScoreService extends Service {
387387
for (let i = 0; i < rule.triggers.length; i++) {
388388
const trigger = rule.triggers[i]
389389
const logic = getTriggerLogic(trigger.event)
390-
390+
391391
if (!logic?.check) {
392392
continue
393393
}
@@ -404,9 +404,9 @@ export class AutoScoreService extends Service {
404404
},
405405
now: new Date()
406406
}
407-
407+
408408
const result = logic.check(context, trigger.value || '')
409-
409+
410410
if (!result.matchedStudents || result.matchedStudents.length === 0) {
411411
// 当前触发器没有匹配的学生
412412
if (currentRelation === 'AND') {
@@ -418,13 +418,13 @@ export class AutoScoreService extends Service {
418418
// 当前触发器有匹配的学生
419419
if (currentRelation === 'AND') {
420420
// AND关系下,取交集
421-
currentGroup = currentGroup.filter(student =>
422-
result.matchedStudents!.some(matched => matched.id === student.id)
421+
currentGroup = currentGroup.filter((student) =>
422+
result.matchedStudents!.some((matched) => matched.id === student.id)
423423
)
424424
} else {
425425
// OR关系下,取并集
426-
const newStudents = result.matchedStudents.filter(matched =>
427-
!currentGroup.some(student => student.id === matched.id)
426+
const newStudents = result.matchedStudents.filter(
427+
(matched) => !currentGroup.some((student) => student.id === matched.id)
428428
)
429429
currentGroup = [...currentGroup, ...newStudents]
430430
}
@@ -433,27 +433,28 @@ export class AutoScoreService extends Service {
433433
// 处理下一个关系(如果存在)
434434
if (i < rule.triggers.length - 1) {
435435
const nextRelation = rule.triggers[i + 1].relation || 'AND'
436-
436+
437437
if (nextRelation !== currentRelation) {
438438
// 关系发生变化,处理当前组的结果
439439
if (currentRelation === 'AND') {
440440
// AND组结束,如果当前组不为空,则合并到结果
441441
if (currentGroup.length > 0) {
442-
resultStudents = resultStudents.filter(student =>
443-
currentGroup.some(groupStudent => groupStudent.id === student.id)
442+
resultStudents = resultStudents.filter((student) =>
443+
currentGroup.some((groupStudent) => groupStudent.id === student.id)
444444
)
445445
} else {
446446
// AND组为空,整个规则不匹配
447447
return []
448448
}
449449
} else {
450450
// OR组结束,合并当前组到结果
451-
const newStudents = currentGroup.filter(groupStudent =>
452-
!resultStudents.some(resultStudent => resultStudent.id === groupStudent.id)
451+
const newStudents = currentGroup.filter(
452+
(groupStudent) =>
453+
!resultStudents.some((resultStudent) => resultStudent.id === groupStudent.id)
453454
)
454455
resultStudents = [...resultStudents, ...newStudents]
455456
}
456-
457+
457458
// 重置当前组为所有学生,开始新的关系组
458459
currentGroup = [...initialStudents]
459460
currentRelation = nextRelation
@@ -465,17 +466,18 @@ export class AutoScoreService extends Service {
465466
if (currentRelation === 'AND') {
466467
// AND组结束,如果当前组不为空,则合并到结果
467468
if (currentGroup.length > 0) {
468-
resultStudents = resultStudents.filter(student =>
469-
currentGroup.some(groupStudent => groupStudent.id === student.id)
469+
resultStudents = resultStudents.filter((student) =>
470+
currentGroup.some((groupStudent) => groupStudent.id === student.id)
470471
)
471472
} else {
472473
// AND组为空,整个规则不匹配
473474
return []
474475
}
475476
} else {
476477
// OR组结束,合并当前组到结果
477-
const newStudents = currentGroup.filter(groupStudent =>
478-
!resultStudents.some(resultStudent => resultStudent.id === groupStudent.id)
478+
const newStudents = currentGroup.filter(
479+
(groupStudent) =>
480+
!resultStudents.some((resultStudent) => resultStudent.id === groupStudent.id)
479481
)
480482
resultStudents = [...resultStudents, ...newStudents]
481483
}

src/main/services/HttpServerService.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,7 @@ export class HttpServerService extends Service {
337337
}
338338
})
339339

340-
// ww
341-
this.app.use
342-
340+
// stray expression removed
343341
// 404处理
344342
this.app.use((_req: Request, res: Response) => {
345343
res.status(404).json({
@@ -349,7 +347,8 @@ export class HttpServerService extends Service {
349347
})
350348

351349
// 错误处理中间件
352-
this.app.use((error: Error, _: Request, res: Response, __: NextFunction) => {
350+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
351+
this.app.use((error: Error, _: Request, res: Response, _next: NextFunction) => {
353352
this.mainCtx.logger.error(`HTTP server error: ${error.message}`)
354353
res.status(500).json({
355354
success: false,

src/renderer/src/components/AutoScoreManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ export const AutoScoreManager: React.FC = () => {
569569
/>
570570
</Card>
571571

572-
<Card style={{ marginBottom: '24px', backgroundColor: 'var(--ss-card-bg)' }}>
572+
<Card style={{ marginBottom: '24px' }}>
573573
<Code
574574
code={(() => {
575575
if (editingRuleId !== null) {

src/renderer/src/components/Code.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { useEffect } from 'react'
33
import Prism from 'prismjs'
44
import { useTheme } from '../contexts/ThemeContext'
55

6-
// 预先导入所有主题
7-
import 'prismjs/themes/prism-coy.min.css'
86
import 'prismjs/themes/prism-okaidia.min.css'
97

108
const Code = ({ code, language }) => {

src/renderer/src/components/TagEditorDialog.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
2929

3030
const themeMode = currentTheme?.mode || 'light' // 默认为 light
3131

32-
useEffect(() => {
33-
if (visible) {
34-
setSelectedTagIds(new Set(initialTagIds))
35-
setInputValue('')
36-
fetchAllTags()
37-
}
38-
}, [visible, initialTagIds])
39-
40-
const fetchAllTags = async () => {
32+
// fetchAllTags is declared as a function so it can be called from useEffect
33+
async function fetchAllTags() {
4134
if (!(window as any).api) return
4235
try {
4336
const res = await (window as any).api.tagsGetAll()
@@ -50,6 +43,14 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
5043
}
5144
}
5245

46+
useEffect(() => {
47+
if (visible) {
48+
setSelectedTagIds(new Set(initialTagIds))
49+
setInputValue('')
50+
fetchAllTags()
51+
}
52+
}, [visible, initialTagIds])
53+
5354
const handleAddTag = async () => {
5455
const trimmed = inputValue.trim()
5556
if (!trimmed) return

src/renderer/src/components/com.automatically/actions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const actionDefinitions: ActionDefinition[] = [
4343
description: sendNotificationDescription,
4444
component: SendNotificationAction,
4545
hasReason: sendNotificationHasReason
46-
},
46+
}
4747
]
4848

4949
actionDefinitions.forEach((def) => actionRegistry.register(def))

src/renderer/src/components/com.automatically/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@ export { default as TriggerItemComponent } from './TriggerItem'
1414
export { default as ActionItemComponent } from './ActionItem'
1515

1616
export { IntervalTimeTrigger, StudentTagTrigger, RandomTimeTrigger } from './triggers'
17-
export {
18-
AddScoreAction,
19-
AddTagAction,
20-
SendNotificationAction,
21-
} from './actions'
17+
export { AddScoreAction, AddTagAction, SendNotificationAction } from './actions'

src/renderer/src/components/com.automatically/triggers/IntervalTimeTrigger.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const IntervalTimeTrigger: React.FC<TriggerComponentProps> = ({ value, onChange
3636
numValue === undefined || isNaN(numValue)
3737
? undefined
3838
: unit === 'minutes'
39-
? numValue
40-
: Math.max(1, Math.round(numValue / 1440))
39+
? numValue
40+
: Math.max(1, Math.round(numValue / 1440))
4141

4242
return (
4343
<Space>

0 commit comments

Comments
 (0)