From 3599ef0b749e00de6f92af458898534b2c599839 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Fri, 26 May 2023 22:23:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9=20=E4=B8=8D=E7=9F=A5=E9=81=93?= =?UTF-8?q?=E5=93=AA=E9=87=8C=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/request/getGameRecord.ts | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/web/request/getGameRecord.ts diff --git a/src/web/request/getGameRecord.ts b/src/web/request/getGameRecord.ts new file mode 100644 index 00000000..bc14ca67 --- /dev/null +++ b/src/web/request/getGameRecord.ts @@ -0,0 +1,36 @@ +/** + * @file core utils getGameRecord.ts + * @description 获取游戏数据的函数 + * @author BTMuli + * @since Alpha v0.2.0 + */ + +// tauri +import { http } from "@tauri-apps/api"; +// utils +import TGApi from "../api/TGApi"; +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} cookie cookie + * @param {TGApp.Sqlite.Account.Game} user 用户的基本信息 + * @returns {Promise} 用户基本信息 + */ +export async function getGameRecord (cookie: Record, user: TGApp.Sqlite.Account.Game): Promise { + const url = TGApi.GameData.getUserCard; + const params = { role_id: user.gameUid, server: user.region }; + const header = TGUtils.User.getHeader(cookie, "GET", params, "common"); + return await http.fetch(url, { + method: "GET", + headers: header, + query: params, + }).then((res) => { + console.log(res.data); + return res.data; + }); +}