diff --git a/src/components/ConfigModal.tsx b/src/components/ConfigModal.tsx index 8b58587..a3be5a0 100644 --- a/src/components/ConfigModal.tsx +++ b/src/components/ConfigModal.tsx @@ -30,6 +30,7 @@ import { import { useFieldValidations, ValidatedFormItem, + ValidationSlot, type FormNamePath, type StaticOnly, type StaticValidationDef, @@ -166,7 +167,38 @@ const STATIC_DEFS: StaticValidationDef[] = [ }, ]; -const LIST_DEFS: ListValidationDef[] = []; +const LIST_DEFS: ListValidationDef[] = [ + // Modrinth 依赖 — 查询依赖项目名称 + { + list: ["modrinth", "dependencies"], + target: "project_id", + deps: ["project_id"], + async validate(getVal, row) { + const id = getVal("project_id") as string | undefined; + if (!id) return null; + const r = await lookupModrinthProject(id); + return r.ok + ? { status: "success", help: `项目:${r.name}` } + : { status: "error", help: r.error }; + }, + }, + // CurseForge 关联项目 — 查询关联项目名称并自动填充 slug + { + list: ["curseforge", "relations", "projects"], + target: "projectID", + deps: ["projectID"], + async validate(getVal, row, setVal) { + const id = getVal("projectID") as string | undefined; + if (!id) return null; + const r = await lookupCurseforgeProject(Number(id)); + if (r.ok) { + setVal("slug", r.slug); + return { status: "success", help: `项目:${r.name}` }; + } + return { status: "error", help: r.error }; + }, + }, +]; // --------------------------------------------------------------------------- // Data-fetching hooks — each Select loads independently, no blocking @@ -613,6 +645,7 @@ function ConfigModalForm({ /> remove(name)} /> + ))}