🐛 修正扫码登录,增加网页登录

fix #89
This commit is contained in:
目棃
2024-02-01 11:20:53 +08:00
parent 619bc9d3a3
commit ac25685fbd
13 changed files with 336 additions and 49 deletions

View File

@@ -1,28 +1,32 @@
/**
* @file plugins/Mys/utils/doGameLogin
* @description 获取 gameToken曲线获取 stoken
* @since Beta v0.3.0
* @since Beta v0.4.3
*/
import { http } from "@tauri-apps/api";
const device = crypto.randomUUID();
import { getDeviceInfo } from "../../../utils/toolFunc";
import { getRequestHeader } from "../../../web/utils/getRequestHeader";
/**
* @description 获取登录二维码
* @since Beta v0.3.0
* @since Beta v0.4.3
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginQrData|TGApp.BBS.Response.Base>}
*/
export async function getLoginQr(): Promise<
TGApp.Plugins.Mys.GameLogin.GetLoginQrData | TGApp.BBS.Response.Base
> {
const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/fetch";
const device = getDeviceInfo("device_id");
const data = {
app_id: "4",
device,
};
const header = getRequestHeader({}, "POST", data, "common");
return await http
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginQrResponse | TGApp.BBS.Response.Base>(url, {
headers: header,
method: "POST",
body: http.Body.json(data),
})
@@ -34,7 +38,7 @@ export async function getLoginQr(): Promise<
/**
* @description 获取登录状态
* @since Beta v0.3.0
* @since Beta v0.4.3
* @param {string} ticket 二维码 ticket
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.BBS.Response.Base>}
*/
@@ -42,9 +46,12 @@ export async function getLoginStatus(
ticket: string,
): Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.BBS.Response.Base> {
const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/query";
const device = getDeviceInfo("device_id");
const data = { app_id: "4", device, ticket };
const header = getRequestHeader({}, "POST", data, "common");
return await http
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginStatusResponse | TGApp.BBS.Response.Base>(url, {
headers: header,
method: "POST",
body: http.Body.json(data),
})

View File

@@ -1,12 +1,12 @@
/**
* @file plugins/Mys/types/GameLogin.d.ts
* @description Mys 插件 Game 登录类型定义文件
* @since Beta v0.3.0
* @since Beta v0.4.3
*/
/**
* @description Mys 插件 Game 登录类型
* @since Beta v0.3.0
* @since Beta v0.4.3
* @namespace TGApp.Plugins.Mys.GameLogin
* @memberof TGApp.Plugins.Mys
*/
@@ -76,7 +76,7 @@ declare namespace TGApp.Plugins.Mys.GameLogin {
/**
* @description 反序列化后的登录状态数据
* @since Beta v0.3.0
* @since Beta v0.4.3
* @interface StatusPayloadRaw
* @property {string} uid 用户 UID
* @property {string} token 用户 token
@@ -84,6 +84,6 @@ declare namespace TGApp.Plugins.Mys.GameLogin {
*/
interface StatusPayloadRaw {
uid: string;
token: string;
open_token: string;
}
}