feat: 间隔时间加分可以按照多少天、月、分钟后加分

fix: 修复若干问题
下雨了好害怕我靠
This commit is contained in:
NanGua-QWQ
2026-03-29 18:17:54 +08:00
parent a930e4843c
commit e4d9ee0c85
14 changed files with 507 additions and 83 deletions
@@ -1,17 +1,23 @@
import React, { useMemo } from "react"
import { Button, Card, Input, InputNumber, Select, Space } from "antd"
import { Button, Card, InputNumber, Select, Space } from "antd"
import { DeleteOutlined, PlusOutlined } from "@ant-design/icons"
import { useTranslation } from "react-i18next"
import type { ActionDraft, ActionEvent } from "./AutoScoreUtils"
import type { ActionDraft, ActionEvent, AutoScoreTagOption } from "./AutoScoreUtils"
import { createDefaultActionDraft } from "./AutoScoreUtils"
interface ActionEditorProps {
value: ActionDraft[]
tagOptions: AutoScoreTagOption[]
canEdit: boolean
onChange: (nextDrafts: ActionDraft[]) => void
}
export const ActionEditor: React.FC<ActionEditorProps> = ({ value, canEdit, onChange }) => {
export const ActionEditor: React.FC<ActionEditorProps> = ({
value,
tagOptions,
canEdit,
onChange,
}) => {
const { t } = useTranslation()
const actionOptions = useMemo(
@@ -22,6 +28,27 @@ export const ActionEditor: React.FC<ActionEditorProps> = ({ value, canEdit, onCh
[t]
)
const mergedTagOptions = useMemo(() => {
const optionMap = new Map(tagOptions.map((option) => [option.value, option]))
for (const action of value) {
if (action.event !== "add_tag") continue
const tagValues = Array.isArray(action.value)
? action.value
: action.value
? [action.value]
: []
for (const tagValue of tagValues) {
if (!optionMap.has(tagValue)) {
optionMap.set(tagValue, { label: tagValue, value: tagValue })
}
}
}
return Array.from(optionMap.values())
}, [tagOptions, value])
const updateAction = (id: string, patch: Partial<Omit<ActionDraft, "id">>) => {
onChange(value.map((item) => (item.id === id ? { ...item, ...patch } : item)))
}
@@ -51,7 +78,7 @@ export const ActionEditor: React.FC<ActionEditorProps> = ({ value, canEdit, onCh
onChange={(event: ActionEvent) =>
updateAction(action.id, {
event,
value: event === "add_score" ? "1" : "",
value: event === "add_score" ? "1" : [],
})
}
/>
@@ -66,12 +93,16 @@ export const ActionEditor: React.FC<ActionEditorProps> = ({ value, canEdit, onCh
}
/>
) : (
<Input
style={{ minWidth: 220 }}
<Select
mode="multiple"
showSearch
allowClear
style={{ minWidth: 260 }}
placeholder={t("autoScore.tagNamePlaceholder")}
value={action.value}
value={Array.isArray(action.value) ? action.value : action.value ? [action.value] : []}
disabled={!canEdit}
onChange={(event) => updateAction(action.id, { value: event.target.value })}
options={mergedTagOptions}
onChange={(nextValue) => updateAction(action.id, { value: nextValue })}
/>
)}
<Button