This commit is contained in:
yinsx
2026-01-15 11:03:06 +08:00
parent 943bf4bbd4
commit 53a044f19e
3 changed files with 71 additions and 64 deletions

View File

@ -3,7 +3,7 @@ import { initKeypress, onKey, stopKeypress } from "../keyboard.js";
import { clearScreen } from "./terminal.js";
export function createStepUI(options) {
const { title, getSteps, onStepChange } = options;
const { title, getSteps, onStepChange, validate } = options;
let steps = [];
let results = [];
@ -171,6 +171,11 @@ export function createStepUI(options) {
}
break;
case "tab":
// 如果提供了验证函数,先验证
if (validate && !validate(results)) {
// 验证失败,忽略此次提交
break;
}
resolved = true;
stopKeypress();
setImmediate(() => resolve({ steps, results }));