/** * @file plugins Mys utils doGameLogin * @description 获取 gameToken,曲线获取 stoken * @author BTMuli * @since Beta v0.3.0 */ // tauri import { http } from "@tauri-apps/api"; const device = crypto.randomUUID(); /** * @description 获取登录二维码 * @since Beta v0.3.0 * @returns {Promise} */ export async function getLoginQr(): Promise< TGApp.Plugins.Mys.GameLogin.GetLoginQrData | TGApp.Plugins.Mys.Base.Response > { const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/fetch"; const data = { app_id: "4", device, }; return await http .fetch(url, { method: "POST", body: http.Body.json(data), }) .then((res) => { if (res.data.retcode === 0) return res.data.data; return res.data; }); } /** * @description 获取登录状态 * @since Beta v0.3.0 * @param {string} ticket 二维码 ticket * @returns {Promise} */ export async function getLoginStatus( ticket: string, ): Promise { const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/query"; const data = { app_id: "4", device, ticket }; console.log(data); return await http .fetch(url, { method: "POST", body: http.Body.json(data), }) .then((res) => { if (res.data.retcode === 0) return res.data.data; return res.data; }); }