lint --fix

This commit is contained in:
NanGua_QWQ
2026-02-21 16:18:31 +08:00
parent 67852bd889
commit 094bd639b1
19 changed files with 101 additions and 109 deletions
+3 -1
View File
@@ -432,7 +432,9 @@ export class AutoScoreService extends Service {
break
}
case 'set_student_status': {
this.logger.info(`Set student status action: ${action.value} (not implemented - student type has no status field)`)
this.logger.info(
`Set student status action: ${action.value} (not implemented - student type has no status field)`
)
break
}
default:
+2 -2
View File
@@ -7,12 +7,12 @@ import { Wizard } from './components/Wizard'
import { ThemeProvider } from './contexts/ThemeContext'
import { ThemeEditorProvider } from './contexts/ThemeEditorContext'
import { ThemeEditor } from './components/ThemeEditor'
import { useTheme } from './contexts/ThemeContext';
import { useTheme } from './contexts/ThemeContext'
function MainContent(): React.JSX.Element {
const navigate = useNavigate()
const location = useLocation()
const { currentTheme } = useTheme();
const { currentTheme } = useTheme()
useEffect(() => {
if (!(window as any).api) return
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'
import { useState, useEffect } from 'react'
import { AddIcon, MoveIcon } from 'tdesign-icons-react'
import { allTriggers, allActions, triggerRegistry, actionRegistry } from './com.automatically'
import type { TriggerItem, ActionItem } from './com.automatically/types'
@@ -278,9 +278,7 @@ export const AutoScoreManager: React.FC = () => {
}
const handleTriggerChange = (id: number, eventName: string) => {
setTriggerList((prev) =>
prev.map((t) => (t.id === id ? { ...t, eventName, value: '' } : t))
)
setTriggerList((prev) => prev.map((t) => (t.id === id ? { ...t, eventName, value: '' } : t)))
}
const handleTriggerValueChange = (id: number, value: string) => {
@@ -310,9 +308,7 @@ export const AutoScoreManager: React.FC = () => {
}
const handleActionChange = (id: number, eventName: string) => {
setActionList((prev) =>
prev.map((a) => (a.id === id ? { ...a, eventName, value: '' } : a))
)
setActionList((prev) => prev.map((a) => (a.id === id ? { ...a, eventName, value: '' } : a)))
}
const handleActionValueChange = (id: number, value: string) => {
@@ -565,7 +561,10 @@ export const AutoScoreManager: React.FC = () => {
if (editingRuleId !== null) {
const values = form.getFieldsValue(true) as unknown as AutoScoreRuleFormValues
const studentNames = Array.isArray(values.studentNames) ? values.studentNames : []
const triggersPayload = triggerList.map((t) => ({ event: t.eventName, value: t.value }))
const triggersPayload = triggerList.map((t) => ({
event: t.eventName,
value: t.value
}))
const actionsPayload = actionList.map((a) => ({
event: a.eventName,
value: a.value,
+13 -13
View File
@@ -1,27 +1,27 @@
import { useEffect } from "react";
import { useEffect } from 'react'
import Prism from "prismjs";
import { useTheme } from '../contexts/ThemeContext';
import Prism from 'prismjs'
import { useTheme } from '../contexts/ThemeContext'
// 预先导入所有主题
import "prismjs/themes/prism-coy.min.css";
import "prismjs/themes/prism-okaidia.min.css";
import 'prismjs/themes/prism-coy.min.css'
import 'prismjs/themes/prism-okaidia.min.css'
const Code = ({ code, language }) => {
const { currentTheme } = useTheme();
const { currentTheme } = useTheme()
useEffect(() => {
// 重新高亮代码
Prism.highlightAll();
}, [currentTheme, code, language]);
Prism.highlightAll()
}, [currentTheme, code, language])
// 根据主题设置不同的类名
const isDark = currentTheme?.mode === 'dark';
const isDark = currentTheme?.mode === 'dark'
return (
<div
style={{
opacity: "0.6",
opacity: '0.6',
// 根据主题动态设置样式
backgroundColor: isDark ? '#282c34' : '#f5f2f0',
color: isDark ? '#abb2bf' : '#383a42',
@@ -34,7 +34,7 @@ const Code = ({ code, language }) => {
<code className={`language-${language}`}>{code}</code>
</pre>
</div>
);
};
)
}
export default Code;
export default Code
@@ -1,4 +1,3 @@
import React from 'react'
import { Button, Select } from 'tdesign-react'
import { Delete1Icon } from 'tdesign-icons-react'
import { actionRegistry, allActions } from './registry'
@@ -31,10 +31,7 @@ const TriggerItem: React.FC<TriggerItemProps> = ({ item, onDelete, onChange, onV
onChange={(value) => onChange(item.id, value as string)}
/>
{Component && (
<Component
value={item.value}
onChange={(value) => onValueChange(item.id, value)}
/>
<Component value={item.value} onChange={(value) => onValueChange(item.id, value)} />
)}
</div>
)
@@ -1,4 +1,3 @@
import React from 'react'
import { Input } from 'tdesign-react'
import type { ActionComponentProps } from '../types'
@@ -7,7 +6,12 @@ export const label = '添加分数'
export const description = '为学生添加分数'
export const hasReason = true
const AddScoreAction: React.FC<ActionComponentProps> = ({ value, reason, onChange, onReasonChange }) => {
const AddScoreAction: React.FC<ActionComponentProps> = ({
value,
reason,
onChange,
onReasonChange
}) => {
return (
<>
<Input
@@ -1,4 +1,3 @@
import React from 'react'
import { Input } from 'tdesign-react'
import type { ActionComponentProps } from '../types'
@@ -1,4 +1,3 @@
import React from 'react'
import { Input } from 'tdesign-react'
import type { ActionComponentProps } from '../types'
@@ -1,4 +1,3 @@
import React from 'react'
import { Select } from 'tdesign-react'
import type { ActionComponentProps } from '../types'
@@ -62,9 +62,4 @@ const actionDefinitions: ActionDefinition[] = [
actionDefinitions.forEach((def) => actionRegistry.register(def))
export {
AddScoreAction,
AddTagAction,
SendNotificationAction,
SetStudentStatusAction
}
export { AddScoreAction, AddTagAction, SendNotificationAction, SetStudentStatusAction }
@@ -14,4 +14,9 @@ export { default as TriggerItemComponent } from './TriggerItem'
export { default as ActionItemComponent } from './ActionItem'
export { IntervalTimeTrigger, StudentTagTrigger, RandomTimeTrigger } from './triggers'
export { AddScoreAction, AddTagAction, SendNotificationAction, SetStudentStatusAction } from './actions'
export {
AddScoreAction,
AddTagAction,
SendNotificationAction,
SetStudentStatusAction
} from './actions'
@@ -1,4 +1,3 @@
import React from 'react'
import { InputNumber } from 'tdesign-react'
import type { TriggerComponentProps } from '../types'
@@ -22,7 +21,7 @@ const IntervalTimeTrigger: React.FC<TriggerComponentProps> = ({ value, onChange
const numValue = value ? parseInt(value, 10) : undefined
const handleChange = (v: any) => {
const numV = typeof v === 'number' ? v : (v ? Number(v) : undefined)
const numV = typeof v === 'number' ? v : v ? Number(v) : undefined
onChange(numV !== undefined && numV !== null && !isNaN(numV) ? String(numV) : '')
}
@@ -1,4 +1,3 @@
import React from 'react'
import { InputNumber, Row, Col } from 'tdesign-react'
import type { TriggerComponentProps } from '../types'
@@ -33,7 +32,7 @@ const RandomTimeTrigger: React.FC<TriggerComponentProps> = ({ value, onChange })
} catch {}
const handleChange = (key: keyof RandomTimeConfig, v: any) => {
const numV = typeof v === 'number' ? v : (v ? Number(v) : undefined)
const numV = typeof v === 'number' ? v : v ? Number(v) : undefined
const newConfig = { ...config, [key]: numV ?? (key === 'minHour' ? 0 : 23) }
onChange(JSON.stringify(newConfig))
}
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'
import { useState, useEffect } from 'react'
import { Select } from 'tdesign-react'
import type { TriggerComponentProps } from '../types'
@@ -48,8 +48,4 @@ const triggerDefinitions: TriggerDefinition[] = [
triggerDefinitions.forEach((def) => triggerRegistry.register(def))
export {
IntervalTimeTrigger,
StudentTagTrigger,
RandomTimeTrigger
}
export { IntervalTimeTrigger, StudentTagTrigger, RandomTimeTrigger }
@@ -17,7 +17,11 @@ export interface TriggerLogic {
label: string
description: string
validate: (value: string) => { valid: boolean; message?: string }
calculateNextTime?: (value: string, lastExecuted: Date | undefined, now: Date) => { delayMs: number; nextExecuteTime: Date }
calculateNextTime?: (
value: string,
lastExecuted: Date | undefined,
now: Date
) => { delayMs: number; nextExecuteTime: Date }
check?: (context: any, value: string) => { shouldExecute: boolean; message?: string }
}
@@ -79,9 +79,7 @@ export class AutoScoreService extends Service {
}
updateTriggerEvent(triggerList: TriggerItem[], id: number, eventName: string): TriggerItem[] {
return triggerList.map((t) =>
t.id === id ? { ...t, eventName, value: '' } : t
)
return triggerList.map((t) => (t.id === id ? { ...t, eventName, value: '' } : t))
}
updateTriggerValue(triggerList: TriggerItem[], id: number, value: string): TriggerItem[] {
@@ -104,9 +102,7 @@ export class AutoScoreService extends Service {
}
updateActionEvent(actionList: ActionItem[], id: number, eventName: string): ActionItem[] {
return actionList.map((a) =>
a.id === id ? { ...a, eventName, value: '' } : a
)
return actionList.map((a) => (a.id === id ? { ...a, eventName, value: '' } : a))
}
updateActionValue(actionList: ActionItem[], id: number, value: string): ActionItem[] {
+1 -1
View File
@@ -42,7 +42,7 @@ export const randomTimeTrigger: TriggerLogic = {
const randomHour = Math.floor(Math.random() * (maxHour - minHour + 1)) + minHour
const randomMinute = Math.floor(Math.random() * 60)
let targetDate = new Date(now)
const targetDate = new Date(now)
targetDate.setHours(randomHour, randomMinute, 0, 0)
if (targetDate.getTime() <= now.getTime()) {