This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-05 03:26:09 +08:00
parent ec4d6a15d7
commit 0014eff5e0
4034 changed files with 623229 additions and 41 deletions

View File

@@ -16,7 +16,7 @@ const excel = require('exceljs');
* @param {*} name excel文件名
* @param {*} isClient 是否为客户端数据
*/
async function convert(src, dst, name, isClient) {
async function convert(src, dst, name, isClient,outLocalJsonPath) {
let r = {};
let names = []; // 文名字段名
let keys = []; // 字段名
@@ -282,11 +282,14 @@ async function convert(src, dst, name, isClient) {
});
// 写入流
if (r["undefined"] == null) {
await fs.writeFileSync(dst, JSON.stringify(r));
await fs.writeFileSync(outLocalJsonPath, JSON.stringify(r));
// 生成客户端脚本
if (isClient)
(0, JsonToTs_1.createTs)(name, types_client, r, primary);
console.log(isClient ? "客户端数据" : "服务器数据", "生成成功", dst);
}
else {
console.warn(isClient ? "客户端数据" : "服务器数据", "无数据", dst);
@@ -296,12 +299,13 @@ async function convert(src, dst, name, isClient) {
function run() {
var inputExcelPath = path_1.default.join(__dirname, main_1.config.PathExcel);
var outJsonPath = path_1.default.join(__dirname, main_1.config.PathJson);
var outLocalJsonPath = path_1.default.join(__dirname, "../json/");
const files = fs.readdirSync(inputExcelPath);
files.forEach((f) => {
let name = f.substring(0, f.indexOf("."));
let ext = f.toString().substring(f.lastIndexOf(".") + 1);
if (ext == "xlsx") {
convert(inputExcelPath + f, outJsonPath + name + ".json", name, true); // 客户端数据
convert(inputExcelPath + f, outJsonPath + name + ".json", name, true, outLocalJsonPath + name + ".json"); // 客户端数据
}
});
}