mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-22 15:36:27 +00:00
9b90010daa
* 目前可正确获取圣遗物名称了,`#圣遗物列表`如有错误重新获角色信息后即正常 * 雷神、莫娜的元素伤害字段数据错误fix * 由于服务逻辑与之前数据不一致,部分角色的属性及伤害计算可能会不准确,如有发现请反馈给喵喵
90 lines
2.0 KiB
JavaScript
90 lines
2.0 KiB
JavaScript
import {Data} from "../components/index.js";
|
|
import lodash from "lodash";
|
|
import fs from "fs";
|
|
import request from "request";
|
|
|
|
const _path = process.cwd() + "/plugins/miao-plugin/resources/meta/reliquaries/";
|
|
|
|
let relis = Data.readJSON(_path, 'data.json');
|
|
|
|
|
|
for(let idx in relis){
|
|
|
|
}
|
|
|
|
|
|
lodash.forEach(readDir, (c) => {
|
|
|
|
console.log(c);
|
|
|
|
if (!fs.existsSync(`${_cRoot}/${c}/data.json`)) {
|
|
return;
|
|
}
|
|
|
|
let char = Data.readJSON(`${_cRoot}/${c}/`, 'data.json');
|
|
|
|
if (char.name) {
|
|
// 正面
|
|
|
|
// 角色条
|
|
img(char, char.imgs.profile, "profile.png");
|
|
// 名片
|
|
img(char, char.imgs.party, "party.png");
|
|
// img(char, char.imgs.char, "char.png");
|
|
// 立绘-竖版
|
|
img(char, char.imgs.gacha_card, "gacha_card.png");
|
|
// 立绘
|
|
img(char, char.imgs.gacha_splash, "gacha_splash.png");
|
|
// 正面像
|
|
img(char, char.imgs.face, "face.png");
|
|
img(char, char.imgs.side, "face.png");
|
|
|
|
// 天赋
|
|
if (char.talent) {
|
|
img(char, char.talent.a.icon, "talent_a.png");
|
|
img(char, char.talent.e.icon, "talent_e.png");
|
|
img(char, char.talent.q.icon, "talent_q.png");
|
|
}
|
|
// 被动天赋
|
|
lodash.forEach(char.passive, (p, idx) => {
|
|
img(char, p.icon, `passive_${idx}.png`);
|
|
});
|
|
|
|
// 命座
|
|
lodash.forEach(char.cons, (con, idx) => {
|
|
img(char, con.icon, `cons_${idx}.png`)
|
|
});
|
|
|
|
}
|
|
})
|
|
|
|
let cacheFile = async function () {
|
|
|
|
let cacheFn = async function (file) {
|
|
if (fs.existsSync(`${_cRoot}/${file.file}`)) {
|
|
console.log(`已存在,跳过 ${file.file}`);
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
let stream = fs.createWriteStream(`${_cRoot}/${file.file}`);
|
|
await request("https://genshin.honeyhunterworld.com/" + file.url).pipe(stream);
|
|
|
|
return new Promise((resolve) => {
|
|
stream.on('finish', resolve)
|
|
});
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
console.log(`下载成功: ${file.file}`);
|
|
return true;
|
|
};
|
|
|
|
console.log('开始下载');
|
|
await Data.asyncPool(5, imgs, cacheFn);
|
|
|
|
}
|
|
|
|
await cacheFile();
|
|
console.log('下载成功');
|