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 break
} }
case 'set_student_status': { 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 break
} }
default: default:
+2 -2
View File
@@ -7,12 +7,12 @@ import { Wizard } from './components/Wizard'
import { ThemeProvider } from './contexts/ThemeContext' import { ThemeProvider } from './contexts/ThemeContext'
import { ThemeEditorProvider } from './contexts/ThemeEditorContext' import { ThemeEditorProvider } from './contexts/ThemeEditorContext'
import { ThemeEditor } from './components/ThemeEditor' import { ThemeEditor } from './components/ThemeEditor'
import { useTheme } from './contexts/ThemeContext'; import { useTheme } from './contexts/ThemeContext'
function MainContent(): React.JSX.Element { function MainContent(): React.JSX.Element {
const navigate = useNavigate() const navigate = useNavigate()
const location = useLocation() const location = useLocation()
const { currentTheme } = useTheme(); const { currentTheme } = useTheme()
useEffect(() => { useEffect(() => {
if (!(window as any).api) return 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 { AddIcon, MoveIcon } from 'tdesign-icons-react'
import { allTriggers, allActions, triggerRegistry, actionRegistry } from './com.automatically' import { allTriggers, allActions, triggerRegistry, actionRegistry } from './com.automatically'
import type { TriggerItem, ActionItem } from './com.automatically/types' import type { TriggerItem, ActionItem } from './com.automatically/types'
@@ -278,9 +278,7 @@ export const AutoScoreManager: React.FC = () => {
} }
const handleTriggerChange = (id: number, eventName: string) => { const handleTriggerChange = (id: number, eventName: string) => {
setTriggerList((prev) => setTriggerList((prev) => prev.map((t) => (t.id === id ? { ...t, eventName, value: '' } : t)))
prev.map((t) => (t.id === id ? { ...t, eventName, value: '' } : t))
)
} }
const handleTriggerValueChange = (id: number, value: string) => { const handleTriggerValueChange = (id: number, value: string) => {
@@ -310,9 +308,7 @@ export const AutoScoreManager: React.FC = () => {
} }
const handleActionChange = (id: number, eventName: string) => { const handleActionChange = (id: number, eventName: string) => {
setActionList((prev) => setActionList((prev) => prev.map((a) => (a.id === id ? { ...a, eventName, value: '' } : a)))
prev.map((a) => (a.id === id ? { ...a, eventName, value: '' } : a))
)
} }
const handleActionValueChange = (id: number, value: string) => { const handleActionValueChange = (id: number, value: string) => {
@@ -565,7 +561,10 @@ export const AutoScoreManager: React.FC = () => {
if (editingRuleId !== null) { if (editingRuleId !== null) {
const values = form.getFieldsValue(true) as unknown as AutoScoreRuleFormValues const values = form.getFieldsValue(true) as unknown as AutoScoreRuleFormValues
const studentNames = Array.isArray(values.studentNames) ? values.studentNames : [] 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) => ({ const actionsPayload = actionList.map((a) => ({
event: a.eventName, event: a.eventName,
value: a.value, value: a.value,
+31 -31
View File
@@ -1,40 +1,40 @@
import { useEffect } from "react"; import { useEffect } from 'react'
import Prism from "prismjs"; import Prism from 'prismjs'
import { useTheme } from '../contexts/ThemeContext'; import { useTheme } from '../contexts/ThemeContext'
// 预先导入所有主题 // 预先导入所有主题
import "prismjs/themes/prism-coy.min.css"; import 'prismjs/themes/prism-coy.min.css'
import "prismjs/themes/prism-okaidia.min.css"; import 'prismjs/themes/prism-okaidia.min.css'
const Code = ({ code, language }) => { const Code = ({ code, language }) => {
const { currentTheme } = useTheme(); const { currentTheme } = useTheme()
useEffect(() => { useEffect(() => {
// 重新高亮代码 // 重新高亮代码
Prism.highlightAll(); Prism.highlightAll()
}, [currentTheme, code, language]); }, [currentTheme, code, language])
// 根据主题设置不同的类名 // 根据主题设置不同的类名
const isDark = currentTheme?.mode === 'dark'; const isDark = currentTheme?.mode === 'dark'
return ( return (
<div <div
style={{ style={{
opacity: "0.6", opacity: '0.6',
// 根据主题动态设置样式 // 根据主题动态设置样式
backgroundColor: isDark ? '#282c34' : '#f5f2f0', backgroundColor: isDark ? '#282c34' : '#f5f2f0',
color: isDark ? '#abb2bf' : '#383a42', color: isDark ? '#abb2bf' : '#383a42',
padding: '16px', padding: '16px',
borderRadius: '8px', borderRadius: '8px',
overflow: 'auto' overflow: 'auto'
}} }}
> >
<pre className={isDark ? 'prism-okaidia' : 'prism-coy'}> <pre className={isDark ? 'prism-okaidia' : 'prism-coy'}>
<code className={`language-${language}`}>{code}</code> <code className={`language-${language}`}>{code}</code>
</pre> </pre>
</div> </div>
); )
}; }
export default Code; export default Code
@@ -1,4 +1,3 @@
import React from 'react'
import { Button, Select } from 'tdesign-react' import { Button, Select } from 'tdesign-react'
import { Delete1Icon } from 'tdesign-icons-react' import { Delete1Icon } from 'tdesign-icons-react'
import { actionRegistry, allActions } from './registry' import { actionRegistry, allActions } from './registry'
@@ -12,12 +11,12 @@ interface ActionItemProps {
onReasonChange: (id: number, reason: string) => void onReasonChange: (id: number, reason: string) => void
} }
const ActionItem: React.FC<ActionItemProps> = ({ const ActionItem: React.FC<ActionItemProps> = ({
item, item,
onDelete, onDelete,
onChange, onChange,
onValueChange, onValueChange,
onReasonChange onReasonChange
}) => { }) => {
const definition = actionRegistry.get(item.eventName) const definition = actionRegistry.get(item.eventName)
const Component = definition?.component 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)} onChange={(value) => onChange(item.id, value as string)}
/> />
{Component && ( {Component && (
<Component <Component value={item.value} onChange={(value) => onValueChange(item.id, value)} />
value={item.value}
onChange={(value) => onValueChange(item.id, value)}
/>
)} )}
</div> </div>
) )
@@ -1,4 +1,3 @@
import React from 'react'
import { Input } from 'tdesign-react' import { Input } from 'tdesign-react'
import type { ActionComponentProps } from '../types' import type { ActionComponentProps } from '../types'
@@ -7,7 +6,12 @@ export const label = '添加分数'
export const description = '为学生添加分数' export const description = '为学生添加分数'
export const hasReason = true export const hasReason = true
const AddScoreAction: React.FC<ActionComponentProps> = ({ value, reason, onChange, onReasonChange }) => { const AddScoreAction: React.FC<ActionComponentProps> = ({
value,
reason,
onChange,
onReasonChange
}) => {
return ( return (
<> <>
<Input <Input
@@ -1,4 +1,3 @@
import React from 'react'
import { Input } from 'tdesign-react' import { Input } from 'tdesign-react'
import type { ActionComponentProps } from '../types' import type { ActionComponentProps } from '../types'
@@ -1,4 +1,3 @@
import React from 'react'
import { Input } from 'tdesign-react' import { Input } from 'tdesign-react'
import type { ActionComponentProps } from '../types' import type { ActionComponentProps } from '../types'
@@ -1,4 +1,3 @@
import React from 'react'
import { Select } from 'tdesign-react' import { Select } from 'tdesign-react'
import type { ActionComponentProps } from '../types' import type { ActionComponentProps } from '../types'
@@ -1,30 +1,30 @@
import { actionRegistry } from '../registry' import { actionRegistry } from '../registry'
import type { ActionDefinition } from '../types' import type { ActionDefinition } from '../types'
import AddScoreAction, { import AddScoreAction, {
eventName as addScoreEventName, eventName as addScoreEventName,
label as addScoreLabel, label as addScoreLabel,
description as addScoreDescription, description as addScoreDescription,
hasReason as addScoreHasReason hasReason as addScoreHasReason
} from './AddScoreAction' } from './AddScoreAction'
import AddTagAction, { import AddTagAction, {
eventName as addTagEventName, eventName as addTagEventName,
label as addTagLabel, label as addTagLabel,
description as addTagDescription, description as addTagDescription,
hasReason as addTagHasReason hasReason as addTagHasReason
} from './AddTagAction' } from './AddTagAction'
import SendNotificationAction, { import SendNotificationAction, {
eventName as sendNotificationEventName, eventName as sendNotificationEventName,
label as sendNotificationLabel, label as sendNotificationLabel,
description as sendNotificationDescription, description as sendNotificationDescription,
hasReason as sendNotificationHasReason hasReason as sendNotificationHasReason
} from './SendNotificationAction' } from './SendNotificationAction'
import SetStudentStatusAction, { import SetStudentStatusAction, {
eventName as setStudentStatusEventName, eventName as setStudentStatusEventName,
label as setStudentStatusLabel, label as setStudentStatusLabel,
description as setStudentStatusDescription, description as setStudentStatusDescription,
hasReason as setStudentStatusHasReason hasReason as setStudentStatusHasReason
} from './SetStudentStatusAction' } from './SetStudentStatusAction'
@@ -62,9 +62,4 @@ const actionDefinitions: ActionDefinition[] = [
actionDefinitions.forEach((def) => actionRegistry.register(def)) actionDefinitions.forEach((def) => actionRegistry.register(def))
export { export { AddScoreAction, AddTagAction, SendNotificationAction, SetStudentStatusAction }
AddScoreAction,
AddTagAction,
SendNotificationAction,
SetStudentStatusAction
}
@@ -2,16 +2,21 @@ import './triggers'
import './actions' import './actions'
export { triggerRegistry, actionRegistry, allTriggers, allActions } from './registry' export { triggerRegistry, actionRegistry, allTriggers, allActions } from './registry'
export type { export type {
TriggerComponentProps, TriggerComponentProps,
ActionComponentProps, ActionComponentProps,
TriggerDefinition, TriggerDefinition,
ActionDefinition, ActionDefinition,
TriggerItem, TriggerItem,
ActionItem ActionItem
} from './types' } from './types'
export { default as TriggerItemComponent } from './TriggerItem' export { default as TriggerItemComponent } from './TriggerItem'
export { default as ActionItemComponent } from './ActionItem' export { default as ActionItemComponent } from './ActionItem'
export { IntervalTimeTrigger, StudentTagTrigger, RandomTimeTrigger } from './triggers' 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 { InputNumber } from 'tdesign-react'
import type { TriggerComponentProps } from '../types' import type { TriggerComponentProps } from '../types'
@@ -22,7 +21,7 @@ const IntervalTimeTrigger: React.FC<TriggerComponentProps> = ({ value, onChange
const numValue = value ? parseInt(value, 10) : undefined const numValue = value ? parseInt(value, 10) : undefined
const handleChange = (v: any) => { 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) : '') 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 { InputNumber, Row, Col } from 'tdesign-react'
import type { TriggerComponentProps } from '../types' import type { TriggerComponentProps } from '../types'
@@ -33,7 +32,7 @@ const RandomTimeTrigger: React.FC<TriggerComponentProps> = ({ value, onChange })
} catch {} } catch {}
const handleChange = (key: keyof RandomTimeConfig, v: any) => { 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) } const newConfig = { ...config, [key]: numV ?? (key === 'minHour' ? 0 : 23) }
onChange(JSON.stringify(newConfig)) 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 { Select } from 'tdesign-react'
import type { TriggerComponentProps } from '../types' import type { TriggerComponentProps } from '../types'
@@ -1,23 +1,23 @@
import { triggerRegistry } from '../registry' import { triggerRegistry } from '../registry'
import type { TriggerDefinition } from '../types' import type { TriggerDefinition } from '../types'
import IntervalTimeTrigger, { import IntervalTimeTrigger, {
eventName as intervalEventName, eventName as intervalEventName,
label as intervalLabel, label as intervalLabel,
description as intervalDescription, description as intervalDescription,
triggerLogic as intervalTriggerLogic triggerLogic as intervalTriggerLogic
} from './IntervalTimeTrigger' } from './IntervalTimeTrigger'
import StudentTagTrigger, { import StudentTagTrigger, {
eventName as studentTagEventName, eventName as studentTagEventName,
label as studentTagLabel, label as studentTagLabel,
description as studentTagDescription, description as studentTagDescription,
triggerLogic as studentTagTriggerLogic triggerLogic as studentTagTriggerLogic
} from './StudentTagTrigger' } from './StudentTagTrigger'
import RandomTimeTrigger, { import RandomTimeTrigger, {
eventName as randomTimeEventName, eventName as randomTimeEventName,
label as randomTimeLabel, label as randomTimeLabel,
description as randomTimeDescription, description as randomTimeDescription,
triggerLogic as randomTimeTriggerLogic triggerLogic as randomTimeTriggerLogic
} from './RandomTimeTrigger' } from './RandomTimeTrigger'
@@ -48,8 +48,4 @@ const triggerDefinitions: TriggerDefinition[] = [
triggerDefinitions.forEach((def) => triggerRegistry.register(def)) triggerDefinitions.forEach((def) => triggerRegistry.register(def))
export { export { IntervalTimeTrigger, StudentTagTrigger, RandomTimeTrigger }
IntervalTimeTrigger,
StudentTagTrigger,
RandomTimeTrigger
}
@@ -17,7 +17,11 @@ export interface TriggerLogic {
label: string label: string
description: string description: string
validate: (value: string) => { valid: boolean; message?: 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 } 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[] { updateTriggerEvent(triggerList: TriggerItem[], id: number, eventName: string): TriggerItem[] {
return triggerList.map((t) => return triggerList.map((t) => (t.id === id ? { ...t, eventName, value: '' } : t))
t.id === id ? { ...t, eventName, value: '' } : t
)
} }
updateTriggerValue(triggerList: TriggerItem[], id: number, value: string): TriggerItem[] { 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[] { updateActionEvent(actionList: ActionItem[], id: number, eventName: string): ActionItem[] {
return actionList.map((a) => return actionList.map((a) => (a.id === id ? { ...a, eventName, value: '' } : a))
a.id === id ? { ...a, eventName, value: '' } : a
)
} }
updateActionValue(actionList: ActionItem[], id: number, value: string): ActionItem[] { 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 randomHour = Math.floor(Math.random() * (maxHour - minHour + 1)) + minHour
const randomMinute = Math.floor(Math.random() * 60) const randomMinute = Math.floor(Math.random() * 60)
let targetDate = new Date(now) const targetDate = new Date(now)
targetDate.setHours(randomHour, randomMinute, 0, 0) targetDate.setHours(randomHour, randomMinute, 0, 0)
if (targetDate.getTime() <= now.getTime()) { if (targetDate.getTime() <= now.getTime()) {