增加转格式

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

35
lib/convert/config.js Normal file
View File

@ -0,0 +1,35 @@
import fs from "fs";
import { getImportExtensions, getExportFormats } from "./converters.js";
import { sortByUsage } from "../stats.js";
export function listConvertibleFiles() {
const cwd = process.cwd();
const exts = getImportExtensions();
return fs.readdirSync(cwd).filter(file => {
const ext = file.slice(file.lastIndexOf(".")).toLowerCase();
return exts.includes(ext);
});
}
export function getSteps() {
const files = listConvertibleFiles();
const formats = sortByUsage("convert_format", getExportFormats());
return [
{
name: "源文件",
type: "multiselect",
message: files.length ? "选择要转换的模型文件" : "当前目录未找到可转换的模型文件",
options: files.map(file => ({ value: file, label: file })),
default: [],
emptyMessage: "请按 Esc 返回并放入模型文件后重试"
},
{
name: "输出格式",
type: "select",
message: "选择目标格式",
options: formats.map(f => ({ value: f, label: f })),
default: formats[0]
}
];
}