mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-17 21:19:04 +08:00
👽️ 替换祈愿数据源为yatta
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Hakushi 插件入口
|
||||
* @since Beta v0.9.0
|
||||
*/
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
|
||||
const HAKUSHI_API = "https://api.hakush.in/gi/data/";
|
||||
|
||||
/**
|
||||
* 请求角色数据
|
||||
* @since Beta v0.9.0
|
||||
* @returns 角色数据
|
||||
*/
|
||||
async function fetchAvatar(): Promise<TGApp.Plugins.Hakushi.AvatarResp> {
|
||||
return await TGHttp<TGApp.Plugins.Hakushi.AvatarResp>(`${HAKUSHI_API}character.json`, {
|
||||
method: "GET",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求武器数据
|
||||
* @since Beta v0.9.0
|
||||
* @returns 武器数据
|
||||
*/
|
||||
async function fetchWeapon(): Promise<TGApp.Plugins.Hakushi.WeaponResp> {
|
||||
return await TGHttp<TGApp.Plugins.Hakushi.WeaponResp>(`${HAKUSHI_API}weapon.json`, {
|
||||
method: "GET",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换数据
|
||||
* @since Beta v0.9.1
|
||||
*/
|
||||
async function fetchJson(): Promise<Array<TGApp.Plugins.Hakushi.ConvertData>> {
|
||||
const jsonW = await fetchWeapon();
|
||||
const jsonA = await fetchAvatar();
|
||||
const res: Array<TGApp.Plugins.Hakushi.ConvertData> = [];
|
||||
for (const [id, data] of Object.entries(jsonW)) {
|
||||
res.push({ id: id.toString(), name: data.CHS, type: "武器", star: data.rank });
|
||||
}
|
||||
for (const [id, data] of Object.entries(jsonA)) {
|
||||
res.push({ id: id.toString(), name: data.CHS, type: "角色", star: data.rank });
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const Hakushi = {
|
||||
fetch: fetchJson,
|
||||
};
|
||||
|
||||
export default Hakushi;
|
||||
48
src/utils/Yatta.ts
Normal file
48
src/utils/Yatta.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Yatta 插件入口
|
||||
* @since Beta v0.9.6
|
||||
*/
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
|
||||
const YATTA_API = "https://gi.yatta.moe/api/v2/";
|
||||
|
||||
/**
|
||||
* 请求角色数据
|
||||
* @since Beta v0.9.6
|
||||
* @returns 角色数据
|
||||
*/
|
||||
async function fetchAvatar(): Promise<TGApp.Plugins.Yatta.AvatarResp> {
|
||||
return await TGHttp<TGApp.Plugins.Yatta.AvatarResp>(`${YATTA_API}avatar`, {
|
||||
method: "GET",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求武器数据
|
||||
* @since Beta v0.9.6
|
||||
* @returns 武器数据
|
||||
*/
|
||||
async function fetchWeapon(): Promise<TGApp.Plugins.Yatta.WeaponResp> {
|
||||
return await TGHttp<TGApp.Plugins.Yatta.WeaponResp>(`${YATTA_API}weapon`, {
|
||||
method: "GET",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换数据
|
||||
* @since Beta v0.9.6
|
||||
*/
|
||||
async function fetchYattaJson(): Promise<Array<TGApp.Plugins.Yatta.ConvertData>> {
|
||||
const jsonW = await fetchWeapon();
|
||||
const jsonA = await fetchAvatar();
|
||||
const res: Array<TGApp.Plugins.Yatta.ConvertData> = [];
|
||||
for (const weapon of Object.values(jsonW.data.items)) {
|
||||
res.push({ id: weapon.id.toString(), name: weapon.name, type: "武器", star: weapon.rank });
|
||||
}
|
||||
for (const avatar of Object.values(jsonA.data.items)) {
|
||||
res.push({ id: avatar.id.toString(), name: avatar.name, type: "角色", star: avatar.rank });
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export default fetchYattaJson;
|
||||
Reference in New Issue
Block a user