mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
lint --fix
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,4 +14,9 @@ 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'
|
||||||
|
|
||||||
|
|||||||
@@ -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[] {
|
||||||
|
|||||||
@@ -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()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user