mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 19:04:23 +08:00
fix: pnpm lint --fix
This commit is contained in:
@@ -133,11 +133,17 @@ export class AutoScoreService extends Service {
|
||||
const migratedRule = this.migrateRule(rule)
|
||||
return {
|
||||
...migratedRule,
|
||||
lastExecuted: migratedRule.lastExecuted ? new Date(migratedRule.lastExecuted) : undefined
|
||||
lastExecuted: migratedRule.lastExecuted
|
||||
? new Date(migratedRule.lastExecuted)
|
||||
: undefined
|
||||
}
|
||||
})
|
||||
// 如果有数据迁移,保存新格式
|
||||
if (data.rules.some((rule: any) => rule.intervalMinutes !== undefined || rule.scoreValue !== undefined)) {
|
||||
if (
|
||||
data.rules.some(
|
||||
(rule: any) => rule.intervalMinutes !== undefined || rule.scoreValue !== undefined
|
||||
)
|
||||
) {
|
||||
await this.saveRulesToFile()
|
||||
}
|
||||
} else {
|
||||
@@ -170,7 +176,10 @@ export class AutoScoreService extends Service {
|
||||
}
|
||||
|
||||
// 将intervalMinutes迁移到triggers
|
||||
if (rule.intervalMinutes && !migratedRule.triggers?.find(t => t.event === 'interval_time_passed')) {
|
||||
if (
|
||||
rule.intervalMinutes &&
|
||||
!migratedRule.triggers?.find((t) => t.event === 'interval_time_passed')
|
||||
) {
|
||||
migratedRule.triggers = migratedRule.triggers || []
|
||||
migratedRule.triggers.push({
|
||||
event: 'interval_time_passed',
|
||||
@@ -179,7 +188,10 @@ export class AutoScoreService extends Service {
|
||||
}
|
||||
|
||||
// 将scoreValue和reason迁移到actions
|
||||
if (rule.scoreValue !== undefined && !migratedRule.actions?.find(a => a.event === 'add_score')) {
|
||||
if (
|
||||
rule.scoreValue !== undefined &&
|
||||
!migratedRule.actions?.find((a) => a.event === 'add_score')
|
||||
) {
|
||||
migratedRule.actions = migratedRule.actions || []
|
||||
migratedRule.actions.push({
|
||||
event: 'add_score',
|
||||
@@ -269,9 +281,9 @@ export class AutoScoreService extends Service {
|
||||
}
|
||||
|
||||
// 从triggers中读取间隔时间
|
||||
const intervalTrigger = rule.triggers?.find(t => t.event === 'interval_time_passed')
|
||||
const intervalTrigger = rule.triggers?.find((t) => t.event === 'interval_time_passed')
|
||||
const intervalMinutes = intervalTrigger?.value ? parseInt(intervalTrigger.value, 10) : 0
|
||||
|
||||
|
||||
if (!intervalMinutes || intervalMinutes <= 0) {
|
||||
this.logger.warn(`Rule ${rule.name} has no valid interval time, skipping timer`)
|
||||
return
|
||||
@@ -299,9 +311,9 @@ export class AutoScoreService extends Service {
|
||||
|
||||
private setRuleInterval(rule: AutoScoreRule) {
|
||||
// 从triggers中读取间隔时间
|
||||
const intervalTrigger = rule.triggers?.find(t => t.event === 'interval_time_passed')
|
||||
const intervalTrigger = rule.triggers?.find((t) => t.event === 'interval_time_passed')
|
||||
const intervalMinutes = intervalTrigger?.value ? parseInt(intervalTrigger.value, 10) : 0
|
||||
|
||||
|
||||
if (!intervalMinutes || intervalMinutes <= 0) {
|
||||
return
|
||||
}
|
||||
@@ -336,7 +348,7 @@ export class AutoScoreService extends Service {
|
||||
}
|
||||
|
||||
// 从actions中读取分数和理由
|
||||
const scoreAction = rule.actions?.find(a => a.event === 'add_score')
|
||||
const scoreAction = rule.actions?.find((a) => a.event === 'add_score')
|
||||
const scoreValue = scoreAction?.value ? parseInt(scoreAction.value, 10) : 0
|
||||
const reason = scoreAction?.reason || `自动化加分 - ${rule.name}`
|
||||
|
||||
|
||||
@@ -125,8 +125,8 @@ export const AutoScoreManager: React.FC = () => {
|
||||
const studentNames = Array.isArray(values.studentNames) ? values.studentNames : []
|
||||
|
||||
const triggersPayload = triggerList.map((t) => ({ event: t.eventName, value: t.value }))
|
||||
const actionsPayload = actionList.map((a) => ({
|
||||
event: a.eventName,
|
||||
const actionsPayload = actionList.map((a) => ({
|
||||
event: a.eventName,
|
||||
value: a.value,
|
||||
reason: a.reason
|
||||
}))
|
||||
@@ -321,7 +321,12 @@ export const AutoScoreManager: React.FC = () => {
|
||||
return def?.label || t.event
|
||||
})
|
||||
return (
|
||||
<TooltipLite content={triggerLabels.join(', ')} showArrow placement="mouse" theme="default">
|
||||
<TooltipLite
|
||||
content={triggerLabels.join(', ')}
|
||||
showArrow
|
||||
placement="mouse"
|
||||
theme="default"
|
||||
>
|
||||
{row.triggers.length} 个触发器
|
||||
</TooltipLite>
|
||||
)
|
||||
@@ -340,7 +345,12 @@ export const AutoScoreManager: React.FC = () => {
|
||||
return def?.label || a.event
|
||||
})
|
||||
return (
|
||||
<TooltipLite content={actionLabels.join(', ')} showArrow placement="mouse" theme="default">
|
||||
<TooltipLite
|
||||
content={actionLabels.join(', ')}
|
||||
showArrow
|
||||
placement="mouse"
|
||||
theme="default"
|
||||
>
|
||||
{row.actions.length} 个行动
|
||||
</TooltipLite>
|
||||
)
|
||||
@@ -484,7 +494,9 @@ export const AutoScoreManager: React.FC = () => {
|
||||
{triggerTest.valueType
|
||||
? React.createElement(triggerTest.valueType, {
|
||||
placeholder:
|
||||
triggerTest.eventName === 'interval_time_passed' ? '请选择日期' : '请输入时间间隔(天)',
|
||||
triggerTest.eventName === 'interval_time_passed'
|
||||
? '请选择日期'
|
||||
: '请输入时间间隔(天)',
|
||||
style: { width: '150px' },
|
||||
value:
|
||||
triggerTest.eventName === 'interval_time_passed'
|
||||
@@ -518,9 +530,9 @@ export const AutoScoreManager: React.FC = () => {
|
||||
onChange={(value) => handleActionChange(action.id, value as string)}
|
||||
/>
|
||||
{(() => {
|
||||
const actionDef = allActions.find(a => a.eventName === action.eventName);
|
||||
const renderConfig = actionDef?.renderConfig;
|
||||
|
||||
const actionDef = allActions.find((a) => a.eventName === action.eventName)
|
||||
const renderConfig = actionDef?.renderConfig
|
||||
|
||||
// 特殊处理Radio组件
|
||||
if (action.valueType === Radio || renderConfig?.component === Radio) {
|
||||
return (
|
||||
@@ -530,25 +542,27 @@ export const AutoScoreManager: React.FC = () => {
|
||||
{...renderConfig?.props}
|
||||
>
|
||||
{renderConfig?.props?.options?.map((option: any) => (
|
||||
<Radio.Button key={option.value} value={option.value}>{option.label}</Radio.Button>
|
||||
<Radio.Button key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</Radio.Button>
|
||||
))}
|
||||
</Radio.Group>
|
||||
);
|
||||
)
|
||||
} else if (renderConfig?.component) {
|
||||
return React.createElement(renderConfig.component, {
|
||||
value: String(action.value ?? ''),
|
||||
onChange: (v: any) => handleActionValueChange(action.id, v ? String(v) : ''),
|
||||
...renderConfig.props
|
||||
});
|
||||
})
|
||||
} else if (action.valueType) {
|
||||
return React.createElement(action.valueType, {
|
||||
placeholder: '请输入Value',
|
||||
style: { width: '150px' },
|
||||
value: String(action.value ?? ''),
|
||||
onChange: (v: any) => handleActionValueChange(action.id, v ? String(v) : '')
|
||||
});
|
||||
})
|
||||
}
|
||||
return null;
|
||||
return null
|
||||
})()}
|
||||
{action.eventName === 'add_score' && (
|
||||
<Input
|
||||
|
||||
@@ -142,7 +142,7 @@ export const allActions: TriggerDef[] = [
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
export class AutoScoreService extends Service {
|
||||
|
||||
Reference in New Issue
Block a user