将战绩数据存到数据库中

This commit is contained in:
BTMuli
2023-06-03 00:20:24 +08:00
parent 1c9989a030
commit 9f07918b27
7 changed files with 534 additions and 47 deletions

View File

@@ -14,23 +14,24 @@ import TGUtils from "../utils/TGUtils";
/**
* @description 获取用户游戏数据
* @since Alpha v0.2.0
* @todo invalid uid
* @description 这边的 ck 可以是 cookie_token 和 account_id
* @description 也可以是 ltoken 和 ltuid
* @param {Record<string, string>} cookie cookie
* @param {TGApp.Sqlite.Account.Game} user 用户的基本信息
* @returns {Promise<unknown>} 用户基本信息
* @returns {Promise<TGApp.Game.Record.FullData|TGApp.BBS.Response.Base>} 用户基本信息
*/
export async function getGameRecord (cookie: Record<string, string>, user: TGApp.Sqlite.Account.Game): Promise<unknown> {
const url = TGApi.GameData.getUserCard;
export async function getGameRecord (cookie: Record<string, string>, user: TGApp.Sqlite.Account.Game): Promise<TGApp.Game.Record.FullData | TGApp.BBS.Response.Base> {
const url = TGApi.GameData.getUserBase;
const params = { role_id: user.gameUid, server: user.region };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http.fetch(url, {
return await http.fetch<TGApp.Game.Record.Response>(url, {
method: "GET",
headers: header,
query: params,
}).then((res) => {
console.log(res.data);
return res.data;
if (res.data.retcode !== 0) {
return res.data;
}
return res.data.data;
});
}