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,
+31 -31
View File
@@ -1,40 +1,40 @@
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]);
useEffect(() => {
// 重新高亮代码
Prism.highlightAll()
}, [currentTheme, code, language])
// 根据主题设置不同的类名
const isDark = currentTheme?.mode === 'dark';
// 根据主题设置不同的类名
const isDark = currentTheme?.mode === 'dark'
return (
<div
style={{
opacity: "0.6",
// 根据主题动态设置样式
backgroundColor: isDark ? '#282c34' : '#f5f2f0',
color: isDark ? '#abb2bf' : '#383a42',
padding: '16px',
borderRadius: '8px',
overflow: 'auto'
}}
>
<pre className={isDark ? 'prism-okaidia' : 'prism-coy'}>
<code className={`language-${language}`}>{code}</code>
</pre>
</div>
);
};
return (
<div
style={{
opacity: '0.6',
// 根据主题动态设置样式
backgroundColor: isDark ? '#282c34' : '#f5f2f0',
color: isDark ? '#abb2bf' : '#383a42',
padding: '16px',
borderRadius: '8px',
overflow: 'auto'
}}
>
<pre className={isDark ? 'prism-okaidia' : 'prism-coy'}>
<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'
@@ -12,12 +11,12 @@ interface ActionItemProps {
onReasonChange: (id: number, reason: string) => void
}
const ActionItem: React.FC<ActionItemProps> = ({
item,
onDelete,
onChange,
onValueChange,
onReasonChange
const ActionItem: React.FC<ActionItemProps> = ({
item,
onDelete,
onChange,
onValueChange,
onReasonChange
}) => {
const definition = actionRegistry.get(item.eventName)
const Component = definition?.component
@@ -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'
@@ -1,30 +1,30 @@
import { actionRegistry } from '../registry'
import type { ActionDefinition } from '../types'
import AddScoreAction, {
eventName as addScoreEventName,
label as addScoreLabel,
import AddScoreAction, {
eventName as addScoreEventName,
label as addScoreLabel,
description as addScoreDescription,
hasReason as addScoreHasReason
} from './AddScoreAction'
import AddTagAction, {
eventName as addTagEventName,
label as addTagLabel,
import AddTagAction, {
eventName as addTagEventName,
label as addTagLabel,
description as addTagDescription,
hasReason as addTagHasReason
} from './AddTagAction'
import SendNotificationAction, {
eventName as sendNotificationEventName,
label as sendNotificationLabel,
import SendNotificationAction, {
eventName as sendNotificationEventName,
label as sendNotificationLabel,
description as sendNotificationDescription,
hasReason as sendNotificationHasReason
} from './SendNotificationAction'
import SetStudentStatusAction, {
eventName as setStudentStatusEventName,
label as setStudentStatusLabel,
import SetStudentStatusAction, {
eventName as setStudentStatusEventName,
label as setStudentStatusLabel,
description as setStudentStatusDescription,
hasReason as setStudentStatusHasReason
} from './SetStudentStatusAction'
@@ -62,9 +62,4 @@ const actionDefinitions: ActionDefinition[] = [
actionDefinitions.forEach((def) => actionRegistry.register(def))
export {
AddScoreAction,
AddTagAction,
SendNotificationAction,
SetStudentStatusAction
}
export { AddScoreAction, AddTagAction, SendNotificationAction, SetStudentStatusAction }
@@ -2,16 +2,21 @@ import './triggers'
import './actions'
export { triggerRegistry, actionRegistry, allTriggers, allActions } from './registry'
export type {
TriggerComponentProps,
ActionComponentProps,
TriggerDefinition,
export type {
TriggerComponentProps,
ActionComponentProps,
TriggerDefinition,
ActionDefinition,
TriggerItem,
ActionItem
ActionItem
} from './types'
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'
@@ -1,23 +1,23 @@
import { triggerRegistry } from '../registry'
import type { TriggerDefinition } from '../types'
import IntervalTimeTrigger, {
eventName as intervalEventName,
label as intervalLabel,
import IntervalTimeTrigger, {
eventName as intervalEventName,
label as intervalLabel,
description as intervalDescription,
triggerLogic as intervalTriggerLogic
} from './IntervalTimeTrigger'
import StudentTagTrigger, {
eventName as studentTagEventName,
label as studentTagLabel,
import StudentTagTrigger, {
eventName as studentTagEventName,
label as studentTagLabel,
description as studentTagDescription,
triggerLogic as studentTagTriggerLogic
} from './StudentTagTrigger'
import RandomTimeTrigger, {
eventName as randomTimeEventName,
label as randomTimeLabel,
import RandomTimeTrigger, {
eventName as randomTimeEventName,
label as randomTimeLabel,
description as randomTimeDescription,
triggerLogic as randomTimeTriggerLogic
} from './RandomTimeTrigger'
@@ -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()) {