mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
✨ 实装 authKey 获取
This commit is contained in:
@@ -51,13 +51,6 @@ export const useUserStore = defineStore(
|
|||||||
return cookie.value[key] || "";
|
return cookie.value[key] || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCookieGroup1(): TGApp.BBS.Constant.CookieGroup1 {
|
|
||||||
return {
|
|
||||||
login_ticket: getCookieItem("login_ticket"),
|
|
||||||
login_uid: getCookieItem("login_uid"),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCookieGroup2(): TGApp.BBS.Constant.CookieGroup2 {
|
function getCookieGroup2(): TGApp.BBS.Constant.CookieGroup2 {
|
||||||
return {
|
return {
|
||||||
account_id: getCookieItem("account_id"),
|
account_id: getCookieItem("account_id"),
|
||||||
@@ -89,7 +82,6 @@ export const useUserStore = defineStore(
|
|||||||
setBriefInfo,
|
setBriefInfo,
|
||||||
setCurAccount,
|
setCurAccount,
|
||||||
getCurAccount,
|
getCurAccount,
|
||||||
getCookieGroup1,
|
|
||||||
getCookieGroup2,
|
getCookieGroup2,
|
||||||
getCookieGroup3,
|
getCookieGroup3,
|
||||||
getCookieGroup4,
|
getCookieGroup4,
|
||||||
|
|||||||
26
src/types/Game/Gacha.d.ts
vendored
Normal file
26
src/types/Game/Gacha.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* @file types Game Gacha.d.ts
|
||||||
|
* @description 游戏抽卡相关类型定义文件
|
||||||
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
|
* @since Beta v0.3.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare namespace TGApp.Game.Gacha {
|
||||||
|
/**
|
||||||
|
* @description 获取 authkey 返回类型
|
||||||
|
* @interface AuthkeyResponse
|
||||||
|
* @since Beta v0.3.0
|
||||||
|
* @extends TGApp.BBS.Response.Base
|
||||||
|
* @property {number} data.sign_type - 签名类型
|
||||||
|
* @property {number} data.authkey_ver - authkey 版本
|
||||||
|
* @property {string} data.authkey - authkey
|
||||||
|
* @return AuthkeyResponse
|
||||||
|
*/
|
||||||
|
export interface AuthkeyResponse extends TGApp.BBS.Response.Base {
|
||||||
|
data: {
|
||||||
|
sign_type: number;
|
||||||
|
authkey_ver: number;
|
||||||
|
authkey: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
* @since Beta v0.3.0
|
* @since Beta v0.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { genAuthkey } from "./genAuthkey";
|
||||||
import { getAbyss } from "./getAbyss";
|
import { getAbyss } from "./getAbyss";
|
||||||
import { getAnnoList, getAnnoContent } from "./getAnno";
|
import { getAnnoList, getAnnoContent } from "./getAnno";
|
||||||
import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken";
|
import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken";
|
||||||
@@ -26,6 +27,7 @@ const TGRequest = {
|
|||||||
getContent: getAnnoContent,
|
getContent: getAnnoContent,
|
||||||
},
|
},
|
||||||
User: {
|
User: {
|
||||||
|
getAuthkey: genAuthkey,
|
||||||
getRecord: getGameRecord,
|
getRecord: getGameRecord,
|
||||||
byLoginTicket: {
|
byLoginTicket: {
|
||||||
getTokens: getTokensByLoginTicket,
|
getTokens: getTokensByLoginTicket,
|
||||||
|
|||||||
43
src/web/request/genAuthkey.ts
Normal file
43
src/web/request/genAuthkey.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @file web request genAuthkey.ts
|
||||||
|
* @description 生成 authkey
|
||||||
|
* @author BTMuli <bt-muli@outlook.com>
|
||||||
|
* @since Beta v0.3.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// tauri
|
||||||
|
import { http } from "@tauri-apps/api";
|
||||||
|
// utils
|
||||||
|
import TGUtils from "../utils/TGUtils";
|
||||||
|
import TGConstant from "../constant/TGConstant";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 生成 authkey
|
||||||
|
* @since Beta v0.3.0
|
||||||
|
* @param {Record<string, string>} cookie cookie // stoken_v2 & mid
|
||||||
|
* @param {string} gameUid 游戏 uid
|
||||||
|
* @returns {Promise<string|TGApp.BBS.Response.Base>} authkey
|
||||||
|
*/
|
||||||
|
export async function genAuthkey(
|
||||||
|
cookie: Record<string, string>,
|
||||||
|
gameUid: string,
|
||||||
|
): Promise<string | TGApp.BBS.Response.Base> {
|
||||||
|
const url = "https://api-takumi.mihoyo.com/binding/api/genAuthKey";
|
||||||
|
const data = {
|
||||||
|
auth_appid: "webview_gacha",
|
||||||
|
game_biz: TGConstant.Utils.GAME_BIZ,
|
||||||
|
game_uid: Number(gameUid),
|
||||||
|
region: TGUtils.Tools.getServerByUid(gameUid),
|
||||||
|
};
|
||||||
|
const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(data), "lk2", true);
|
||||||
|
return await http
|
||||||
|
.fetch<TGApp.Game.Gacha.AuthkeyResponse>(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: header,
|
||||||
|
body: http.Body.json(data),
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data.retcode === 0) return res.data.data.authkey;
|
||||||
|
return res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user