mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
♻️ types 重构后的问题搞完了,累死
This commit is contained in:
@@ -18,20 +18,20 @@ import { getRequestHeader } from "../utils/getRequestHeader";
|
||||
* @since Alpha v0.2.0
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {string} schedule_type 0: 本期, 1: 上期
|
||||
* @param {BTMuli.User.Game.Account} account 游戏账号
|
||||
* @returns {Promise<unknown|BTMuli.Genshin.Base.Response>}
|
||||
* @param {TGApp.User.Game.Account} account 游戏账号
|
||||
* @returns {Promise<TGApp.Game.Abyss.FullData|TGApp.App.Base.Response>}
|
||||
*/
|
||||
export async function getAbyss (cookie: Record<string, string>, schedule_type: string, account: BTMuli.User.Game.Account): Promise<unknown | BTMuli.Genshin.Base.Response> {
|
||||
export async function getAbyss (cookie: Record<string, string>, schedule_type: string, account: TGApp.User.Account.Game): Promise<TGApp.Game.Abyss.FullData | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.getAbyss;
|
||||
const role_id = account.game_uid;
|
||||
const params = { role_id, schedule_type, server: getServerByUid(role_id) };
|
||||
const header = getRequestHeader(cookie, "GET", params, "common");
|
||||
return await http.fetch<any>(url, {
|
||||
return await http.fetch<TGApp.Game.Abyss.Response>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: params,
|
||||
}).then(res => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data as unknown;
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,27 +7,27 @@
|
||||
|
||||
// Tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
// Tauri.Genshin
|
||||
// Tauri.App
|
||||
import TGApi from "../api/TGApi";
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告列表
|
||||
* @since Alpha v0.1.2
|
||||
* @returns {Promise<BTMuli.Genshin.Announcement.ListData>}
|
||||
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
|
||||
*/
|
||||
export async function getAnnoList (): Promise<BTMuli.Genshin.Announcement.ListData> {
|
||||
return await http.fetch<BTMuli.Genshin.Announcement.ListResponse>(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`).then((res) => res.data.data);
|
||||
export async function getAnnoList (): Promise<TGApp.BBS.Announcement.ListData> {
|
||||
return await http.fetch<TGApp.BBS.Announcement.ListResponse>(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`).then((res) => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取游戏内公告内容
|
||||
* @since Alpha v0.1.2
|
||||
* @param {number} annId 公告 ID
|
||||
* @returns {Promise<BTMuli.Genshin.Announcement.ContentItem>}
|
||||
* @returns {Promise<TGApp.BBS.Announcement.ContentItem>}
|
||||
*/
|
||||
export async function getAnnoContent (annId: number): Promise<BTMuli.Genshin.Announcement.ContentItem> {
|
||||
const annoContents: BTMuli.Genshin.Announcement.ContentItem[] = await http
|
||||
.fetch<BTMuli.Genshin.Announcement.ContentResponse>(`${TGApi.GameAnnoContent}${TGApi.GameAnnoQuery}`)
|
||||
export async function getAnnoContent (annId: number): Promise<TGApp.BBS.Announcement.ContentItem> {
|
||||
const annoContents: TGApp.BBS.Announcement.ContentItem[] = await http
|
||||
.fetch<TGApp.BBS.Announcement.ContentResponse>(`${TGApi.GameAnnoContent}${TGApi.GameAnnoQuery}`)
|
||||
.then((res) => res.data.data.list);
|
||||
const annoContent = annoContents.find((item) => item.ann_id === annId);
|
||||
if (annoContent) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request getCookieToken.ts
|
||||
* @description 获取 Cookie Token 的请求函数
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -14,12 +14,12 @@ import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 根据 stoken 获取 cookie_token
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} stuid 登录用户 uid
|
||||
* @param {string} stoken stoken
|
||||
* @returns {Promise<string|BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<string|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getCookieTokenBySToken (stuid: string, stoken: string): Promise<string | BTMuli.Genshin.Base.Response> {
|
||||
export async function getCookieTokenBySToken (stuid: string, stoken: string): Promise<string | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameTokens.getCookieToken;
|
||||
const cookie = {
|
||||
stuid,
|
||||
@@ -27,10 +27,10 @@ export async function getCookieTokenBySToken (stuid: string, stoken: string): Pr
|
||||
};
|
||||
const params = { stoken };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
return await http.fetch<BTMuli.User.Response.CookieToken>(url, {
|
||||
return await http.fetch<TGApp.BBS.Response.getCookieTokenBySToken>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
body: http.Body.json(params),
|
||||
query: params,
|
||||
}).then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data.cookie_token;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/**
|
||||
* @file web request getEnkaData.ts
|
||||
* @description 获取 ENKA 数据
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.3
|
||||
*/
|
||||
|
||||
// Tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
// Tauri.Genshin
|
||||
import TGApi from "../api/TGApi";
|
||||
|
||||
/**
|
||||
* @description 获取 ENKA 数据
|
||||
* @since Alpha v0.1.3
|
||||
* @param {number} uid 用户 UID
|
||||
* @returns {Promise<BTMuli.Genshin.Enka.Data>}
|
||||
*/
|
||||
export async function getEnkaData (uid: number): Promise<BTMuli.Genshin.Enka.Data> {
|
||||
return await http.fetch<BTMuli.Genshin.Enka.Data>(`${TGApi.GameEnka}${uid}`).then((res) => res.data);
|
||||
}
|
||||
// /**
|
||||
// * @file web request getEnkaData.ts
|
||||
// * @description 获取 ENKA 数据
|
||||
// * @author BTMuli<bt-muli@outlook.com>
|
||||
// * @since Alpha v0.1.3
|
||||
// */
|
||||
//
|
||||
// // Tauri
|
||||
// import { http } from "@tauri-apps/api";
|
||||
// // Tauri.App
|
||||
// import TGApi from "../api/TGApi";
|
||||
//
|
||||
// /**
|
||||
// * @description 获取 ENKA 数据
|
||||
// * @since Alpha v0.1.3
|
||||
// * @param {number} uid 用户 UID
|
||||
// * @returns {Promise<TGApp.Plugins.Enka>}
|
||||
// */
|
||||
// export async function getEnkaData (uid: number): Promise<BTMuli.App.Enka.Data> {
|
||||
// return await http.fetch<BTMuli.App.Enka.Data>(`${TGApi.GameEnka}${uid}`).then((res) => res.data);
|
||||
// }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request getGameAccounts.ts
|
||||
* @description 获取游戏账号信息相关请求函数
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -15,12 +15,12 @@ import TGConstant from "../constant/TGConstant";
|
||||
|
||||
/**
|
||||
* @description 通过 stoken 获取游戏账号
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} stoken stoken
|
||||
* @param {string} stuid 登录用户 uid
|
||||
* @returns {Promise<BTMuli.User.Game.Account[]|BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<TGApp.User.Game.Account[]|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getGameAccountsBySToken (stoken: string, stuid: string): Promise<BTMuli.User.Game.Account[] | BTMuli.Genshin.Base.Response> {
|
||||
export async function getGameAccountsBySToken (stoken: string, stuid: string): Promise<TGApp.User.Account.Game[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.bySToken.getAccounts;
|
||||
const cookie = {
|
||||
stuid,
|
||||
@@ -32,12 +32,12 @@ export async function getGameAccountsBySToken (stoken: string, stuid: string): P
|
||||
|
||||
/**
|
||||
* @description 通过 cookie 获取游戏账号
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} cookie_token cookie_token
|
||||
* @param {string} account_id 游戏账号 id
|
||||
* @returns {Promise<BTMuli.User.Game.Account[]|BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<TGApp.User.Account.Game[]|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getGameAccountsByCookie (cookie_token: string, account_id: string): Promise<BTMuli.User.Game.Account[] | BTMuli.Genshin.Base.Response> {
|
||||
export async function getGameAccountsByCookie (cookie_token: string, account_id: string): Promise<TGApp.User.Account.Game[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.byCookie.getAccounts;
|
||||
const cookie = {
|
||||
account_id,
|
||||
@@ -53,14 +53,14 @@ export async function getGameAccountsByCookie (cookie_token: string, account_id:
|
||||
* @param {string} url 请求地址
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {Record<string, string>} params 请求参数
|
||||
* @returns {Promise<BTMuli.User.Game.Account[]|BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<TGApp.User.Account.Game[]|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getGameAccounts (url: string, cookie: Record<string, string>, params: Record<string, string>): Promise<BTMuli.User.Game.Account[] | BTMuli.Genshin.Base.Response> {
|
||||
async function getGameAccounts (url: string, cookie: Record<string, string>, params: Record<string, string>): Promise<TGApp.BBS.Response.Base | TGApp.User.Account.Game[]> {
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
return await http.fetch<BTMuli.User.Response.GameAccounts>(url, {
|
||||
return await http.fetch<TGApp.User.Account.GameResponse>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
body: http.Body.json(params),
|
||||
query: params,
|
||||
}).then(res => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data.list;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request getLToken.ts
|
||||
* @description 获取 ltoken 的请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -14,12 +14,12 @@ import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 根据 stoken 获取 ltoken
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} stuid 登录用户 uid
|
||||
* @param {string} stoken stoken
|
||||
* @returns {Promise<string|BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<string|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getLTokenBySToken (stuid: string, stoken: string): Promise<string | BTMuli.Genshin.Base.Response> {
|
||||
export async function getLTokenBySToken (stuid: string, stoken: string): Promise<string | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameTokens.getLToken;
|
||||
const cookie = {
|
||||
stuid,
|
||||
@@ -27,10 +27,10 @@ export async function getLTokenBySToken (stuid: string, stoken: string): Promise
|
||||
};
|
||||
const params = { stoken };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
return await http.fetch<BTMuli.User.Response.LToken>(url, {
|
||||
return await http.fetch<TGApp.BBS.Response.getLTokenBySToken>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
body: http.Body.json(params),
|
||||
query: params,
|
||||
}).then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data.ltoken;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request getTokens.ts
|
||||
* @description 获取游戏 Token
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -14,12 +14,12 @@ import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 根据 login_ticket 获取游戏 Token,包括 stoken 和 ltoken
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} ticket 登录票证
|
||||
* @param {string} uid 登录用户 uid
|
||||
* @returns {Promise<BTMuli.User.Base.TokenItem[] | BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getTokensByLoginTicket (ticket: string, uid: string): Promise<BTMuli.User.Response.TokenItem[] | BTMuli.Genshin.Base.Response> {
|
||||
export async function getTokensByLoginTicket (ticket: string, uid: string): Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base> {
|
||||
const cookie = {
|
||||
login_ticket: ticket,
|
||||
login_uid: uid,
|
||||
@@ -28,10 +28,10 @@ export async function getTokensByLoginTicket (ticket: string, uid: string): Prom
|
||||
// eslint-disable-next-line camelcase
|
||||
const params = { login_ticket: ticket, token_types: 3, uid };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
return await http.fetch<BTMuli.User.Response.Tokens>(url, {
|
||||
return await http.fetch<TGApp.BBS.Response.getTokens>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
body: http.Body.json(params),
|
||||
query: params,
|
||||
}).then((res) => {
|
||||
console.log(res);
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request getUserInfo.ts
|
||||
* @description 获取用户信息请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -19,20 +19,20 @@ import { type UserResponse } from "../../plugins/Mys/interface/user";
|
||||
* @since Alpha v0.2.0
|
||||
* @param {string} cookie_token cookie token
|
||||
* @param {string} account_id 用户 account_id
|
||||
* @returns {Promise<BTMuli.User.Base.BriefInfo | BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getUserInfoByCookie (cookie_token: string, account_id: string): Promise<BTMuli.User.Base.BriefInfo | BTMuli.Genshin.Base.Response> {
|
||||
export async function getUserInfoByCookie (cookie_token: string, account_id: string): Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base> {
|
||||
const cookie = {
|
||||
cookie_token,
|
||||
account_id,
|
||||
};
|
||||
const url = TGApi.GameData.byCookie.getUserInfo;
|
||||
const params = { gids: 2 };
|
||||
const params = { gids: "2" };
|
||||
const header = TGUtils.User.getSignHeader(cookie, "GET", {}, "common");
|
||||
return await http.fetch<UserResponse>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
body: http.Body.json(params),
|
||||
query: params,
|
||||
}).then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
const info = res.data.data.user_info;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request initCookie.ts
|
||||
* @description 首次输入 cookie 后的一系列请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// utils
|
||||
@@ -14,14 +14,14 @@ import { verifyLToken } from "./verifyLToken";
|
||||
|
||||
/**
|
||||
* @description 根据输入 cookie 获取一堆 token
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} ticket login_ticket
|
||||
* @param {string} uid login_uid
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function initCookie (ticket: string, uid: string): Promise<void> {
|
||||
const tokenRes = await getTokensByLoginTicket(ticket, uid);
|
||||
const cookie: BTMuli.User.Base.Cookie = {
|
||||
const cookie: TGApp.BBS.Constant.Cookie = {
|
||||
account_id: uid,
|
||||
cookie_token: "",
|
||||
login_ticket: ticket,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web request verifyLToken.ts
|
||||
* @description 验证 stoken 的请求函数
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -14,12 +14,12 @@ import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 验证 ltoken 有效性,返回 mid
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {string} ltoken ltoken
|
||||
* @param {string} ltuid 登录用户 uid
|
||||
* @returns {Promise<string | BTMuli.Genshin.Base.Response>}
|
||||
* @returns {Promise<string | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function verifyLToken (ltoken: string, ltuid: string): Promise<string | BTMuli.Genshin.Base.Response> {
|
||||
export async function verifyLToken (ltoken: string, ltuid: string): Promise<string | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameTokens.verifyLToken;
|
||||
const cookie = {
|
||||
ltoken,
|
||||
@@ -27,8 +27,7 @@ export async function verifyLToken (ltoken: string, ltuid: string): Promise<stri
|
||||
};
|
||||
const data = { ltoken };
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
|
||||
console.log("header:", header);
|
||||
return await http.fetch<BTMuli.User.Response.Verify>(url, {
|
||||
return await http.fetch<TGApp.BBS.Response.verifyUserInfoBySToken>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
body: http.Body.json(data),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file web utils backupData.ts
|
||||
* @description 数据备份
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
*/
|
||||
|
||||
// tauri
|
||||
|
||||
@@ -11,13 +11,13 @@ const defaultCover = "/source/UI/defaultCover.webp";
|
||||
/**
|
||||
* @description 将获取到的数据转为渲染用的卡片
|
||||
* @since Alpha v0.1.2
|
||||
* @param {BTMuli.Genshin.Announcement.ListData} data 公告数据
|
||||
* @returns {BTMuli.Genshin.Announcement.ListCard[]} 渲染用的卡片
|
||||
* @param {TGApp.BBS.Announcement.ListData[]} data 公告数据
|
||||
* @returns {TGApp.App.Announcement.ListCard[]} 渲染用的卡片
|
||||
*/
|
||||
export function getAnnoCard (data: BTMuli.Genshin.Announcement.ListData): BTMuli.Genshin.Announcement.ListCard[] {
|
||||
const cards: BTMuli.Genshin.Announcement.ListCard[] = [];
|
||||
data.list.map((annoList: BTMuli.Genshin.Announcement) => {
|
||||
return annoList.list.map((anno: BTMuli.Genshin.Announcement.ListItem) => {
|
||||
export function getAnnoCard (data: TGApp.BBS.Announcement.ListData): TGApp.App.Announcement.ListCard[] {
|
||||
const cards: TGApp.App.Announcement.ListCard[] = [];
|
||||
data.list.map((annoList: TGApp.BBS.Announcement.ListItem) => {
|
||||
return annoList.list.map((anno: TGApp.BBS.Announcement.AnnoSingle) => {
|
||||
return cards.push({
|
||||
id: anno.ann_id,
|
||||
title: anno.title,
|
||||
|
||||
Reference in New Issue
Block a user