mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🗑️ 增加几个 callback 处理
This commit is contained in:
@@ -211,6 +211,9 @@ class TGClient {
|
|||||||
case "getStatusBarHeight":
|
case "getStatusBarHeight":
|
||||||
await this.getStatusBarHeight(callback);
|
await this.getStatusBarHeight(callback);
|
||||||
break;
|
break;
|
||||||
|
case "genAuthKey":
|
||||||
|
await this.genAuthKey(payload, callback);
|
||||||
|
break;
|
||||||
case "getCookieInfo":
|
case "getCookieInfo":
|
||||||
await this.getCookieInfo(payload, callback);
|
await this.getCookieInfo(payload, callback);
|
||||||
break;
|
break;
|
||||||
@@ -249,6 +252,13 @@ class TGClient {
|
|||||||
case "share":
|
case "share":
|
||||||
await this.share(payload, callback);
|
await this.share(payload, callback);
|
||||||
break;
|
break;
|
||||||
|
case "share2":
|
||||||
|
await this.nullCallback(arg);
|
||||||
|
break;
|
||||||
|
// 监听滚动事件? payload:{direction: 0|1} 0:向上滚动 1:向下滚动
|
||||||
|
case "onBeginDragging":
|
||||||
|
await this.nullCallback(arg);
|
||||||
|
break;
|
||||||
// getNotificationSettings
|
// getNotificationSettings
|
||||||
default:
|
default:
|
||||||
console.warn(`[${arg.windowLabel}] ${arg.payload}`);
|
console.warn(`[${arg.windowLabel}] ${arg.payload}`);
|
||||||
@@ -289,6 +299,24 @@ class TGClient {
|
|||||||
await this.callback(callback, data);
|
await this.callback(callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @func genAuthKey
|
||||||
|
* @since Beta v0.3.7
|
||||||
|
* @desc 获取米游社客户端的 authkey
|
||||||
|
* @param {Record<string, string>} payload - 请求参数
|
||||||
|
* @param {string} callback - 回调函数名
|
||||||
|
* @returns {void} - 无返回值
|
||||||
|
*/
|
||||||
|
async genAuthKey(payload: Record<string, string>, callback: string): Promise<void> {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const cookie = {
|
||||||
|
mid: userStore.cookie.mid,
|
||||||
|
stoken: userStore.cookie.stoken,
|
||||||
|
};
|
||||||
|
const res = await TGRequest.User.getAuthkey2(cookie, payload);
|
||||||
|
await this.callback(callback, res.data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @func getCookieInfo
|
* @func getCookieInfo
|
||||||
* @since Beta v0.3.4
|
* @since Beta v0.3.4
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @since Beta v0.3.6
|
* @since Beta v0.3.6
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { genAuthkey } from "./genAuthkey";
|
import { genAuthkey, genAuthkey2 } from "./genAuthkey";
|
||||||
import { getAbyss } from "./getAbyss";
|
import { getAbyss } from "./getAbyss";
|
||||||
import { getActionTicketBySToken } from "./getActionTicket";
|
import { getActionTicketBySToken } from "./getActionTicket";
|
||||||
import { getAnnoContent, getAnnoList } from "./getAnno";
|
import { getAnnoContent, getAnnoList } from "./getAnno";
|
||||||
@@ -33,6 +33,7 @@ const TGRequest = {
|
|||||||
},
|
},
|
||||||
User: {
|
User: {
|
||||||
getAuthkey: genAuthkey,
|
getAuthkey: genAuthkey,
|
||||||
|
getAuthkey2: genAuthkey2,
|
||||||
getGachaLog,
|
getGachaLog,
|
||||||
getRecord: getGameRecord,
|
getRecord: getGameRecord,
|
||||||
byLoginTicket: {
|
byLoginTicket: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file web/request/genAuthkey.ts
|
* @file web/request/genAuthkey.ts
|
||||||
* @description 生成 authkey
|
* @description 生成 authkey
|
||||||
* @since Beta v0.3.0
|
* @since Beta v0.3.7
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { http } from "@tauri-apps/api";
|
import { http } from "@tauri-apps/api";
|
||||||
@@ -39,3 +39,25 @@ export async function genAuthkey(
|
|||||||
return res.data;
|
return res.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 生成 authkey
|
||||||
|
* @since Beta v0.3.0
|
||||||
|
* @param {Record<string, string>} cookie cookie // stoken_v2 & mid
|
||||||
|
* @param {object} payload payload
|
||||||
|
* @returns {Promise<string|TGApp.BBS.Response.Base>} authkey
|
||||||
|
*/
|
||||||
|
export async function genAuthkey2(
|
||||||
|
cookie: Record<string, string>,
|
||||||
|
payload: Record<string, string>,
|
||||||
|
): Promise<TGApp.BBS.Response.Base> {
|
||||||
|
const url = "https://api-takumi.mihoyo.com/binding/api/genAuthKey";
|
||||||
|
const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(payload), "lk2", true);
|
||||||
|
return await http
|
||||||
|
.fetch<TGApp.BBS.Response.Base>(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: header,
|
||||||
|
body: http.Body.json(payload),
|
||||||
|
})
|
||||||
|
.then((res) => res.data);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user