优化
This commit is contained in:
@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user