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