增加转格式
This commit is contained in:
35
lib/convert/config.js
Normal file
35
lib/convert/config.js
Normal 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]
|
||||
}
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user