This commit is contained in:
yinsx
2025-12-20 17:14:43 +08:00
parent 7a6a55b535
commit 29a7a1e626
16 changed files with 172 additions and 724 deletions

3
lib/audio/index.js Normal file
View File

@ -0,0 +1,3 @@
export async function run() {
throw new Error("尚未实现");
}

3
lib/image/index.js Normal file
View File

@ -0,0 +1,3 @@
export async function run() {
throw new Error("尚未实现");
}

3
lib/lod/index.js Normal file
View File

@ -0,0 +1,3 @@
export async function run() {
throw new Error("尚未实现");
}

View File

@ -2,6 +2,15 @@ import color from "picocolors";
import boxen from "boxen";
import figlet from "figlet";
import { gridSelect } from "./grid.js";
import * as convertTool from "./convert/index.js";
import * as ktx2Tool from "./ktx2/index.js";
import * as gltfTool from "./gltf/index.js";
import * as modelTool from "./model/index.js";
import * as imageTool from "./image/index.js";
import * as spriteTool from "./sprite/index.js";
import * as lodTool from "./lod/index.js";
import * as audioTool from "./audio/index.js";
import * as scaffoldTool from "./scaffold/index.js";
let poemConfig = {
lines: ["你我皆牛马", "生在人世间", "终日奔波苦", "一刻不得闲"],
@ -18,15 +27,15 @@ let titleConfig = {
};
const tools = [
{ name: "格式转换", desc: "支持多种模型格式转换", 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" },
{ name: "LOD生成器", desc: "生成多级细节", module: "./lib/lod/index.js" },
{ name: "音频压缩", desc: "压缩音频文件", module: "./lib/audio/index.js" },
{ name: "项目脚手架", desc: "快速创建项目模板", module: "./lib/scaffold/index.js" },
{ name: "格式转换", desc: "支持多种模型格式转换", tool: convertTool },
{ name: "KTX2 纹理压缩", desc: "图片转KTX2格式", tool: ktx2Tool },
{ name: "glTF扩展", desc: "添加KHR_texture_basisu", tool: gltfTool },
{ name: "模型压缩", desc: "压缩glTF/GLB模型", tool: modelTool },
{ name: "图片批量处理", desc: "裁剪/缩放/转换", tool: imageTool },
{ name: "Sprite图集", desc: "合并精灵图集", tool: spriteTool },
{ name: "LOD生成器", desc: "生成多级细节", tool: lodTool },
{ name: "音频压缩", desc: "压缩音频文件", tool: audioTool },
{ name: "项目脚手架", desc: "快速创建项目模板", tool: scaffoldTool },
];
export function setPoem(lines, perLine = 2) {

3
lib/sprite/index.js Normal file
View File

@ -0,0 +1,3 @@
export async function run() {
throw new Error("尚未实现");
}

30
lib/update.js Normal file
View File

@ -0,0 +1,30 @@
import color from "picocolors";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const pkg = require("../package.json");
export async function checkUpdate() {
try {
const res = await fetch(`https://registry.npmmirror.com/${pkg.name}/latest`, {
signal: AbortSignal.timeout(3000)
});
if (!res.ok) return;
const data = await res.json();
const latest = data.version;
if (latest && latest !== pkg.version && isNewer(latest, pkg.version)) {
console.log(color.yellow(`\n📦 发现新版本: ${color.red(pkg.version)}${color.green(latest)}`));
console.log(color.cyan(` 运行 ${color.bold("yinx upgrade")} 进行更新\n`));
}
} catch {}
}
function isNewer(latest, current) {
const l = latest.split(".").map(Number);
const c = current.split(".").map(Number);
for (let i = 0; i < 3; i++) {
if ((l[i] || 0) > (c[i] || 0)) return true;
if ((l[i] || 0) < (c[i] || 0)) return false;
}
return false;
}