增加转格式

This commit is contained in:
yinsx
2025-12-20 11:51:35 +08:00
parent 5315a97613
commit d9abc57b0b
32 changed files with 4339 additions and 229 deletions

View File

@ -3,7 +3,6 @@ import boxen from "boxen";
import figlet from "figlet";
import { gridSelect } from "./grid.js";
// 古诗配置
let poemConfig = {
lines: ["你我皆牛马", "生在人世间", "终日奔波苦", "一刻不得闲"],
perLine: 2,
@ -12,16 +11,16 @@ let poemConfig = {
borderColor: "cyan",
};
// 标题配置
let titleConfig = {
text: "Zguiy Tool Box",
font: "Standard",
color: "magenta",
};
// 工具列表
const tools = [
{ name: "格式转换", desc: "OBJ/FBX转glTF", module: "./lib/convert/index.js" },
{ name: "KTX2 纹理压缩", desc: "图片转KTX2格式", module: "./lib/ktx2/index.js" },
{ name: "glTF扩展", desc: "添加KHR_texture_basisu", module: "./lib/gltf/index.js" },
{ name: "模型压缩", desc: "压缩glTF/GLB模型", module: "./lib/model/index.js" },
{ name: "图片批量处理", desc: "裁剪/缩放/转换", module: "./lib/image/index.js" },
{ name: "Sprite图集", desc: "合并精灵图集", module: "./lib/sprite/index.js" },
@ -29,25 +28,21 @@ const tools = [
{ name: "音频压缩", desc: "压缩音频文件", module: "./lib/audio/index.js" },
];
// 设置古诗
export function setPoem(lines, perLine = 2) {
poemConfig.lines = lines;
poemConfig.perLine = perLine;
}
// 设置古诗框样式
export function setPoemStyle(style) {
Object.assign(poemConfig, style);
}
// 设置标题
export function setTitle(text, font = "Standard", titleColor = "magenta") {
titleConfig.text = text;
titleConfig.font = font;
titleConfig.color = titleColor;
}
// 渲染古诗
function renderPoem() {
const merged = [];
for (let i = 0; i < poemConfig.lines.length; i += poemConfig.perLine) {
@ -62,7 +57,6 @@ function renderPoem() {
});
}
// 渲染标题
function renderTitle() {
const art = figlet.textSync(titleConfig.text, { font: titleConfig.font });
const termWidth = process.stdout.columns || 80;
@ -72,12 +66,10 @@ function renderTitle() {
}).join("\n");
}
// 渲染头部
function renderHeader() {
return renderPoem() + "\n\n" + renderTitle();
}
// 主菜单
export async function showMainMenu() {
return gridSelect({
items: tools,