🔥 移除 json-bigint,buffer请求解耦

This commit is contained in:
BTMuli
2026-04-08 17:40:01 +08:00
parent e67763fa60
commit 000cd51dc0
7 changed files with 55 additions and 75 deletions

View File

@@ -1,11 +1,12 @@
/**
* 祈愿相关请求
* @since Beta v0.9.1
* @since Beta v0.10.0
*/
import { getReqHeader } from "@Hutao/utils/authUtils.js";
import TGHttp from "@utils/TGHttp.js";
const GachaUrl = "https://homa.gentle.house/GachaLog/";
import { getReqHeader } from "../utils/authUtils.js";
const HUTAO_GACHA_API = "https://homa.gentle.house/GachaLog/";
/**
* 获取抽卡入口
@@ -15,7 +16,7 @@ const GachaUrl = "https://homa.gentle.house/GachaLog/";
export async function getEntries(
tk: string,
): Promise<TGApp.Plugins.Hutao.Gacha.EntryRes | TGApp.Plugins.Hutao.Base.Resp> {
const url = `${GachaUrl}Entries`;
const url = `${HUTAO_GACHA_API}Entries`;
const header = await getReqHeader(tk);
const resp = await TGHttp<TGApp.Plugins.Hutao.Gacha.EntryResp>(url, {
method: "GET",
@@ -27,6 +28,7 @@ export async function getEntries(
/**
* 获取抽卡EndId
* @since Beta v0.10.0
* @param tk - token
* @param uid - 记录UID
* @returns EndId
@@ -35,13 +37,12 @@ export async function getEndIds(
tk: string,
uid: string,
): Promise<TGApp.Plugins.Hutao.Gacha.EndIdRes | TGApp.Plugins.Hutao.Base.Resp> {
const url = `${GachaUrl}EndIds`;
const url = `${HUTAO_GACHA_API}EndIds`;
const header = await getReqHeader(tk);
const resp = await TGHttp<TGApp.Plugins.Hutao.Gacha.EndIdResp>(url, {
method: "GET",
headers: header,
query: { Uid: uid },
hasBigInt: true,
});
if (resp.retcode !== 0) return <TGApp.Plugins.Hutao.Base.Resp>resp;
return <TGApp.Plugins.Hutao.Gacha.EndIdRes>resp.data;
@@ -49,7 +50,7 @@ export async function getEndIds(
/**
* 获取抽卡记录
* @since Beta v0.9.1
* @since Beta v0.10.0
* @param tk - token
* @param uid - 记录UID
* @param gType - 祈愿类型按照EndId来
@@ -63,7 +64,7 @@ export async function getGachaLogs(
count: number,
endId: string | undefined = undefined,
): Promise<TGApp.Plugins.Hutao.Gacha.GachaLogResp> {
const url = `${GachaUrl}LimitedRetrieve`;
const url = `${HUTAO_GACHA_API}LimitedRetrieve`;
const header = await getReqHeader(tk);
const params: Record<string, string | number> = {
uid: uid,
@@ -75,7 +76,6 @@ export async function getGachaLogs(
method: "GET",
headers: header,
query: params,
hasBigInt: true,
});
}
@@ -90,7 +90,7 @@ export async function uploadGachaLogs(
tk: string,
data: TGApp.Plugins.Hutao.Gacha.UploadData,
): Promise<TGApp.Plugins.Hutao.Gacha.UploadResp> {
const url = `${GachaUrl}Upload`;
const url = `${HUTAO_GACHA_API}Upload`;
const header = await getReqHeader(tk);
return await TGHttp<TGApp.Plugins.Hutao.Gacha.UploadResp>(url, {
method: "POST",
@@ -110,7 +110,7 @@ export async function deleteGachaLogs(
tk: string,
uid: string,
): Promise<TGApp.Plugins.Hutao.Gacha.DeleteResp> {
const url = `${GachaUrl}Delete`;
const url = `${HUTAO_GACHA_API}Delete`;
const header = await getReqHeader(tk);
return await TGHttp<TGApp.Plugins.Hutao.Gacha.DeleteResp>(url, {
method: "GET",