第一版

This commit is contained in:
yinsx
2025-12-16 16:21:26 +08:00
parent 0c73ef2547
commit 8ba7e635f5
15 changed files with 1006 additions and 30 deletions

View File

@ -1,5 +1,6 @@
import color from "picocolors";
import readline from "readline";
import boxen from "boxen";
import { steps } from "./config.js";
// 存储结果和状态
@ -8,6 +9,31 @@ let completed = new Set();
let currentStep = 0;
let currentOption = 0;
// 古诗配置
let poemLines = ["你我皆牛马", "生在人世间", "终日奔波苦", "一刻不得闲"];
let poemPerLine = 2;
// 设置古诗
export function setPoem(lines, perLine = 2) {
poemLines = lines;
poemPerLine = perLine;
}
// 渲染古诗
function renderPoem() {
const merged = [];
for (let i = 0; i < poemLines.length; i += poemPerLine) {
merged.push(poemLines.slice(i, i + poemPerLine).join(""));
}
return boxen(color.yellow(merged.join("\n")), {
padding: { top: 1, bottom: 1, left: 4, right: 4 },
borderStyle: "double",
borderColor: "cyan",
textAlignment: "center",
float: "center",
});
}
// 初始化结果
export function initResults() {
results = steps.map(s => s.type === "multiselect" ? [...s.default] : s.default);
@ -67,6 +93,7 @@ function renderOptions() {
// 渲染整个界面
function render() {
console.clear();
console.log(renderPoem());
console.log(color.bgCyan(color.black(" KTX2 纹理压缩工具 ")));
console.log("\n" + renderNav());
console.log(color.dim("\n← → 切换步骤 | ↑ ↓ 选择选项 | Space 选中 | Enter 确认 | Tab 提交\n"));
@ -152,6 +179,7 @@ export async function runInteractive() {
// 显示配置摘要
export function showSummary(config) {
console.clear();
console.log(renderPoem());
console.log(color.bgCyan(color.black(" KTX2 纹理压缩工具 ")));
console.log("\n" + color.green("配置完成!当前设置:"));
console.log(` 文件格式: ${config.exts.join(", ")}`);