mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-25 09:27:34 +00:00
c32579ab63
* 根据当前账号的角色练度及本期深渊出场数据,推荐较匹配的配队方案 * 深渊出场数据来自胡桃API,为SnapGenshin用户自主上传的深渊挑战记录,感谢SG团队 * 配队方案仅供参考
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
/*
|
|
* 胡桃API Miao-Plugin 封装
|
|
* https://github.com/DGP-Studio/DGP.Genshin.HutaoAPI
|
|
*
|
|
* */
|
|
|
|
import fetch from "node-fetch";
|
|
|
|
const host = "http://49.232.91.210:88/miaoPlugin/hutaoApi";
|
|
|
|
let hutaoApi = null;
|
|
|
|
function getApi(api) {
|
|
return `${host}?api=${api}`;
|
|
}
|
|
|
|
let HutaoApi = {
|
|
async req(url, data) {
|
|
let cacheData = await redis.get(`hutao:${url}`);
|
|
if (cacheData) {
|
|
return JSON.parse(cacheData)
|
|
}
|
|
|
|
let response = await fetch(getApi(`${url}`), {
|
|
method: "GET",
|
|
});
|
|
let retData = await response.json();
|
|
if (retData && retData.data) {
|
|
let d = new Date();
|
|
retData.lastUpdate = `${d.toLocaleDateString()} ${d.toTimeString().substr(0, 5)}`;
|
|
await redis.set(`hutao:${url}`, JSON.stringify(retData), { EX: 3600 });
|
|
}
|
|
return retData;
|
|
},
|
|
|
|
// 角色持有及命座分布
|
|
async getCons() {
|
|
return await HutaoApi.req("/Statistics/Constellation");
|
|
},
|
|
|
|
async getAbyssPct() {
|
|
return await HutaoApi.req("/Statistics/AvatarParticipation");
|
|
},
|
|
|
|
async getAbyssTeam() {
|
|
return await HutaoApi.req("/Statistics/TeamCombination");
|
|
}
|
|
};
|
|
|
|
|
|
export default HutaoApi; |