mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-16 09:58:13 +08:00
✏️ 完善基本 Response 类型 #51
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
/**
|
||||
* @file plugins Mys utils doGameLogin
|
||||
* @file plugins/Mys/utils/doGameLogin
|
||||
* @todo 完善
|
||||
* @description 获取 gameToken,曲线获取 stoken
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
// tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
|
||||
const device = crypto.randomUUID();
|
||||
@@ -13,10 +12,10 @@ const device = crypto.randomUUID();
|
||||
/**
|
||||
* @description 获取登录二维码
|
||||
* @since Beta v0.3.0
|
||||
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginQrData|TGApp.Plugins.Mys.Base.Response>}
|
||||
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginQrData|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getLoginQr(): Promise<
|
||||
TGApp.Plugins.Mys.GameLogin.GetLoginQrData | TGApp.Plugins.Mys.Base.Response
|
||||
TGApp.Plugins.Mys.GameLogin.GetLoginQrData | TGApp.BBS.Response.Base
|
||||
> {
|
||||
const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/fetch";
|
||||
const data = {
|
||||
@@ -24,7 +23,7 @@ export async function getLoginQr(): Promise<
|
||||
device,
|
||||
};
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginQrResponse>(url, {
|
||||
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginQrResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
@@ -38,16 +37,16 @@ export async function getLoginQr(): Promise<
|
||||
* @description 获取登录状态
|
||||
* @since Beta v0.3.0
|
||||
* @param {string} ticket 二维码 ticket
|
||||
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.Plugins.Mys.Base.Response>}
|
||||
* @returns {Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getLoginStatus(
|
||||
ticket: string,
|
||||
): Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.Plugins.Mys.Base.Response> {
|
||||
): Promise<TGApp.Plugins.Mys.GameLogin.GetLoginStatusData | TGApp.BBS.Response.Base> {
|
||||
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<TGApp.Plugins.Mys.GameLogin.GetLoginStatusResponse>(url, {
|
||||
.fetch<TGApp.Plugins.Mys.GameLogin.GetLoginStatusResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**
|
||||
* @file plugins Mys request getEmojis.ts
|
||||
* @file plugins/Mys/request/getEmojis.ts
|
||||
* @description Mys 表情包请求函数集合
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
// tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
|
||||
/**
|
||||
@@ -15,16 +13,18 @@ import { http } from "@tauri-apps/api";
|
||||
*/
|
||||
export async function getEmojis(): Promise<Record<string, string> | TGApp.BBS.Response.Base> {
|
||||
const url = "https://bbs-api-static.miyoushe.com/misc/api/emoticon_set";
|
||||
return await http.fetch<TGApp.Plugins.Mys.Emoji.Response>(url).then((res) => {
|
||||
if (res.data.retcode === 0) {
|
||||
const emojis: Record<string, string> = {};
|
||||
res.data.data.list.forEach((series) => {
|
||||
series.list.forEach((emoji) => {
|
||||
emojis[emoji.name] = emoji.icon;
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Mys.Emoji.Response | TGApp.BBS.Response.Base>(url)
|
||||
.then((res) => {
|
||||
if (res.data.retcode === 0) {
|
||||
const emojis: Record<string, string> = {};
|
||||
res.data.data.list.forEach((series) => {
|
||||
series.list.forEach((emoji) => {
|
||||
emojis[emoji.name] = emoji.icon;
|
||||
});
|
||||
});
|
||||
});
|
||||
return emojis;
|
||||
}
|
||||
return res.data;
|
||||
});
|
||||
return emojis;
|
||||
}
|
||||
return res.data;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user