From bdd5e99f95643497f42b73936c36f943b341107d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Mon, 1 Jul 2024 14:17:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=89=A9=E4=BD=99=E7=9A=84import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/Mys/request/doGameLogin.ts | 44 +++++++++----------- src/plugins/Mys/request/getCollectionData.ts | 27 ++++-------- src/plugins/Mys/request/getEmojis.ts | 5 ++- src/plugins/Mys/request/getForumList.ts | 16 ++----- src/plugins/Mys/request/getGachaData.ts | 12 ++---- src/plugins/Mys/request/getHomeNavigator.ts | 15 ++----- src/plugins/Mys/request/getLotteryData.ts | 15 ++----- src/plugins/Mys/request/getNewsList.ts | 11 ++--- src/plugins/Mys/request/getPositionData.ts | 12 ++---- src/plugins/Mys/request/getPostData.ts | 14 +++---- src/plugins/Mys/request/getVoteData.ts | 8 +--- src/plugins/Mys/request/searchPost.ts | 20 ++------- src/plugins/Sqlite/modules/avatarBirth.ts | 2 +- src/web/request/genAuthkey.ts | 21 ++++------ src/web/request/getAbyss.ts | 13 +++--- src/web/request/getActionTicket.ts | 24 +++-------- src/web/request/getAnno.ts | 15 +++---- src/web/request/getCookieToken.ts | 33 ++++++--------- src/web/request/getDeviceFp.ts | 13 +++--- src/web/request/getGachaLog.ts | 8 ++-- src/web/request/getGameAccounts.ts | 25 ++++------- src/web/request/getLToken.ts | 18 +++----- src/web/request/getRoleList.ts | 13 +++--- src/web/request/getStoken.ts | 29 ++++--------- src/web/request/getSyncAvatarDetail.ts | 21 +++++----- src/web/request/getSyncAvatarListAll.ts | 27 +++++------- src/web/request/getUserCollect.ts | 11 ++--- 27 files changed, 162 insertions(+), 310 deletions(-) diff --git a/src/plugins/Mys/request/doGameLogin.ts b/src/plugins/Mys/request/doGameLogin.ts index 6a50d7a0..6f4c1075 100644 --- a/src/plugins/Mys/request/doGameLogin.ts +++ b/src/plugins/Mys/request/doGameLogin.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import { getDeviceInfo } from "../../../utils/toolFunc"; -import { getRequestHeader } from "../../../web/utils/getRequestHeader"; +import { getDeviceInfo } from "../../../utils/toolFunc.js"; +import { getRequestHeader } from "../../../web/utils/getRequestHeader.js"; const APP_ID = 8; @@ -21,21 +22,16 @@ export async function getLoginQr(): Promise< > { const url = "https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode/fetch"; const device = getDeviceInfo("device_id"); - const data = { - app_id: APP_ID, - device, - }; + const data = { app_id: APP_ID, device }; const header = getRequestHeader({}, "POST", data, "common"); return await http - .fetch(url, { - headers: header, - method: "POST", - body: http.Body.json(data), - }) - .then((res) => { - if (res.data.retcode === 0) return res.data.data; - return res.data; - }); + .fetch(url, { headers: header, method: "POST", body: http.Body.json(data) }) + .then( + (res: Response) => { + if (res.data.retcode === 0) return res.data.data; + return res.data; + }, + ); } /** @@ -52,13 +48,13 @@ export async function getLoginStatus( const data = { app_id: APP_ID, device, ticket }; const header = getRequestHeader({}, "POST", data, "common"); return await http - .fetch(url, { - headers: header, - method: "POST", - body: http.Body.json(data), - }) - .then((res) => { - if (res.data.retcode === 0) return res.data.data; - return res.data; - }); + .fetch(url, { headers: header, method: "POST", body: http.Body.json(data) }) + .then( + ( + res: Response, + ) => { + if (res.data.retcode === 0) return res.data.data; + return res.data; + }, + ); } diff --git a/src/plugins/Mys/request/getCollectionData.ts b/src/plugins/Mys/request/getCollectionData.ts index 7f0e821b..b28ba876 100644 --- a/src/plugins/Mys/request/getCollectionData.ts +++ b/src/plugins/Mys/request/getCollectionData.ts @@ -5,8 +5,9 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import MysApi from "../api"; +import MysApi from "../api/index.js"; /** * @description 获取合集信息 @@ -23,15 +24,12 @@ export async function getCollectionData( id: collectionId.toString(), }; return await http - .fetch(url, { + .fetch(url, { method: "GET", - headers: { - "Content-Type": "application/json", - Referer: MysApi.PostReferer, - }, + headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer }, query: params, }) - .then((res) => { + .then((res: Response) => { console.log(res.data); return res.data.data; }); @@ -47,19 +45,12 @@ export async function getCollectionPosts( collectionId: string, ): Promise { const url = "https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection"; - const params = { - collection_id: collectionId, - }; + const params = { collection_id: collectionId }; return await http - .fetch(url, { + .fetch(url, { method: "GET", - headers: { - "Content-Type": "application/json", - Referer: MysApi.PostReferer, - }, + headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer }, query: params, }) - .then((res) => { - return res.data.data.posts; - }); + .then((res: Response) => res.data.data.posts); } diff --git a/src/plugins/Mys/request/getEmojis.ts b/src/plugins/Mys/request/getEmojis.ts index 7e760ba1..d229c885 100644 --- a/src/plugins/Mys/request/getEmojis.ts +++ b/src/plugins/Mys/request/getEmojis.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取表情包列表 @@ -14,8 +15,8 @@ import { http } from "@tauri-apps/api"; export async function getEmojis(): Promise | TGApp.BBS.Response.Base> { const url = "https://bbs-api-static.miyoushe.com/misc/api/emoticon_set"; return await http - .fetch(url) - .then((res) => { + .fetch(url) + .then((res: Response) => { if (res.data.retcode === 0) { const emojis: Record = {}; res.data.data.list.forEach((series) => { diff --git a/src/plugins/Mys/request/getForumList.ts b/src/plugins/Mys/request/getForumList.ts index 6a3c7acc..8c5ed66b 100644 --- a/src/plugins/Mys/request/getForumList.ts +++ b/src/plugins/Mys/request/getForumList.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取特定论坛列表 @@ -18,19 +19,10 @@ async function getForumList( type: number = 0, ): Promise { const url = "https://bbs-api.miyoushe.com/post/wapi/getForumPostList"; - const params = { - forum_id: forumId.toString(), - sort_type: type.toString(), - }; + const params = { forum_id: forumId.toString(), sort_type: type.toString() }; return await http - .fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - query: params, - }) - .then((res) => res.data.data); + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params }) + .then((res: Response) => res.data.data); } export default getForumList; diff --git a/src/plugins/Mys/request/getGachaData.ts b/src/plugins/Mys/request/getGachaData.ts index 4b38ef14..76c5f57f 100644 --- a/src/plugins/Mys/request/getGachaData.ts +++ b/src/plugins/Mys/request/getGachaData.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取卡池信息 @@ -14,15 +15,8 @@ import { http } from "@tauri-apps/api"; async function getGachaData(): Promise { const url = "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc"; return await http - .fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then((res) => { - return res.data.data.list; - }); + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" } }) + .then((res: Response) => res.data.data.list); } export default getGachaData; diff --git a/src/plugins/Mys/request/getHomeNavigator.ts b/src/plugins/Mys/request/getHomeNavigator.ts index 88ddfdd8..d57e3769 100644 --- a/src/plugins/Mys/request/getHomeNavigator.ts +++ b/src/plugins/Mys/request/getHomeNavigator.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取首页导航列表 @@ -14,18 +15,10 @@ import { http } from "@tauri-apps/api"; */ async function getHomeNavigator(gid: number = 2): Promise { const url = "https://bbs-api.miyoushe.com/apihub/api/home/new"; - const params = { - gids: gid.toString(), - }; + const params = { gids: gid.toString() }; return await http - .fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - query: params, - }) - .then((res) => res.data.data.navigator); + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params }) + .then((res: Response) => res.data.data.navigator); } export default getHomeNavigator; diff --git a/src/plugins/Mys/request/getLotteryData.ts b/src/plugins/Mys/request/getLotteryData.ts index 068cee6c..d83fe01e 100644 --- a/src/plugins/Mys/request/getLotteryData.ts +++ b/src/plugins/Mys/request/getLotteryData.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取抽奖信息 @@ -16,18 +17,10 @@ async function getLotteryData( lotteryId: string, ): Promise { const url = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show"; - const params = { - id: lotteryId, - }; + const params = { id: lotteryId }; return await http - .fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data.show_lottery; }); diff --git a/src/plugins/Mys/request/getNewsList.ts b/src/plugins/Mys/request/getNewsList.ts index ddec9749..3d902d8d 100644 --- a/src/plugins/Mys/request/getNewsList.ts +++ b/src/plugins/Mys/request/getNewsList.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取 News 列表 @@ -29,14 +30,8 @@ async function getNewsList( last_id: lastId.toString(), }; return await http - .fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - query: params, - }) - .then((res) => res.data.data); + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params }) + .then((res: Response) => res.data.data); } export default getNewsList; diff --git a/src/plugins/Mys/request/getPositionData.ts b/src/plugins/Mys/request/getPositionData.ts index f8323703..70fb07e3 100644 --- a/src/plugins/Mys/request/getPositionData.ts +++ b/src/plugins/Mys/request/getPositionData.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 深度优先遍历 @@ -34,14 +35,7 @@ export async function getPositionData(): Promise(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then((res) => { - return res.data.data.list; - }); + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" } }) + .then((res: Response) => res.data.data.list); return DfsObc(res); } diff --git a/src/plugins/Mys/request/getPostData.ts b/src/plugins/Mys/request/getPostData.ts index bd5f92b3..085e8748 100644 --- a/src/plugins/Mys/request/getPostData.ts +++ b/src/plugins/Mys/request/getPostData.ts @@ -5,8 +5,9 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import MysApi from "../api"; +import MysApi from "../api/index.js"; /** * @description 获取帖子信息 @@ -20,17 +21,12 @@ async function getPostData(postId: number): Promise(url, { + .fetch(url, { method: "GET", - headers: { - "Content-Type": "application/json", - Referer: MysApi.PostReferer, - }, + headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer }, query: params, }) - .then((res) => { - return res.data.data.post; - }); + .then((res: Response) => res.data.data.post); } export default getPostData; diff --git a/src/plugins/Mys/request/getVoteData.ts b/src/plugins/Mys/request/getVoteData.ts index 26590669..d4a0a3a5 100644 --- a/src/plugins/Mys/request/getVoteData.ts +++ b/src/plugins/Mys/request/getVoteData.ts @@ -25,9 +25,7 @@ export async function getVoteInfo(id: string, uid: string): Promise) => { - return res.data.data.data[0]; - }); + .then((res: Response) => res.data.data.data[0]); } /** @@ -49,7 +47,5 @@ export async function getVoteResult( headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer }, query: params, }) - .then((res: Response) => { - return res.data.data.data[0]; - }); + .then((res: Response) => res.data.data.data[0]); } diff --git a/src/plugins/Mys/request/searchPost.ts b/src/plugins/Mys/request/searchPost.ts index 2755741d..af27a74d 100644 --- a/src/plugins/Mys/request/searchPost.ts +++ b/src/plugins/Mys/request/searchPost.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 搜索帖子 @@ -20,23 +21,10 @@ async function searchPosts( last_id: string, ): Promise { const url = "https://bbs-api.miyoushe.com/post/wapi/searchPosts"; - const params = { - gids: gid, - keyword, - last_id, - size: "20", - }; + const params = { gids: gid, keyword, last_id, size: "20" }; return await http - .fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - query: params, - }) - .then((res) => { - return res.data.data; - }); + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, query: params }) + .then((res: Response) => res.data.data); } export default searchPosts; diff --git a/src/plugins/Sqlite/modules/avatarBirth.ts b/src/plugins/Sqlite/modules/avatarBirth.ts index 15f2ca54..f975c0f0 100644 --- a/src/plugins/Sqlite/modules/avatarBirth.ts +++ b/src/plugins/Sqlite/modules/avatarBirth.ts @@ -4,7 +4,7 @@ * @since Beta v0.4.6 */ -import { AppCharacterData, ArcBirCalendar, ArcBirRole } from "../../../data"; +import { AppCharacterData, ArcBirCalendar, ArcBirRole } from "../../../data/index.js"; /** * @description 判断今天是不是角色生日 diff --git a/src/web/request/genAuthkey.ts b/src/web/request/genAuthkey.ts index 0b747f97..6e2c5baf 100644 --- a/src/web/request/genAuthkey.ts +++ b/src/web/request/genAuthkey.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGConstant from "../constant/TGConstant"; -import TGUtils from "../utils/TGUtils"; +import TGConstant from "../constant/TGConstant.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 生成 authkey @@ -29,12 +30,8 @@ export async function genAuthkey( }; const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(data), "lk2", true); return await http - .fetch(url, { - method: "POST", - headers: header, - body: http.Body.json(data), - }) - .then((res) => { + .fetch(url, { method: "POST", headers: header, body: http.Body.json(data) }) + .then((res: Response) => { if (res.data.retcode === 0) return res.data.data.authkey; return res.data; }); @@ -54,10 +51,6 @@ export async function genAuthkey2( 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(url, { - method: "POST", - headers: header, - body: http.Body.json(payload), - }) - .then((res) => res.data); + .fetch(url, { method: "POST", headers: header, body: http.Body.json(payload) }) + .then((res: Response) => res.data); } diff --git a/src/web/request/getAbyss.ts b/src/web/request/getAbyss.ts index c460e68c..11c0058d 100644 --- a/src/web/request/getAbyss.ts +++ b/src/web/request/getAbyss.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 获取深渊信息 @@ -27,12 +28,8 @@ export async function getAbyss( const params = { role_id, schedule_type, server: account.region }; const header = TGUtils.User.getHeader(cookie, "GET", params, "common"); return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", headers: header, query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data; }); diff --git a/src/web/request/getActionTicket.ts b/src/web/request/getActionTicket.ts index d541839d..7af34a95 100644 --- a/src/web/request/getActionTicket.ts +++ b/src/web/request/getActionTicket.ts @@ -5,8 +5,9 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGUtils from "../utils/TGUtils"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 通过 stoken 获取 ActionTicket @@ -24,23 +25,10 @@ export async function getActionTicketBySToken( UID: string, ): Promise { const url = "https://api-takumi.mihoyo.com/auth/api/getActionTicketBySToken"; - const params = { - action_type: ActionType, - stoken: SToken, - uid: UID, - }; - const cookie = { - mid: MID, - stoken: SToken, - }; + const params = { action_type: ActionType, stoken: SToken, uid: UID }; + const cookie = { mid: MID, stoken: SToken }; const header = TGUtils.User.getHeader(cookie, "GET", params, "k2"); return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { - return res.data; - }); + .fetch(url, { method: "GET", headers: header, query: params }) + .then((res: Response) => res.data); } diff --git a/src/web/request/getAnno.ts b/src/web/request/getAnno.ts index 04953fae..ff17ae4b 100644 --- a/src/web/request/getAnno.ts +++ b/src/web/request/getAnno.ts @@ -4,6 +4,7 @@ * @since Beta v0.4.4 */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; export enum AnnoServer { CN_ISLAND = "cn_gf01", @@ -62,11 +63,8 @@ export async function getAnnoList( url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnList"; } return await http - .fetch(url, { - method: "GET", - query: params, - }) - .then((res) => res.data.data); + .fetch(url, { method: "GET", query: params }) + .then((res: Response) => res.data.data); } /** @@ -88,11 +86,8 @@ export async function getAnnoContent( url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnContent"; } const annoContents: TGApp.BBS.Announcement.ContentItem[] = await http - .fetch(url, { - method: "GET", - query: params, - }) - .then((res) => res.data.data.list); + .fetch(url, { method: "GET", query: params }) + .then((res: Response) => res.data.data.list); const annoContent = annoContents.find((item) => item.ann_id === annId); if (annoContent != null) { return annoContent; diff --git a/src/web/request/getCookieToken.ts b/src/web/request/getCookieToken.ts index adc092a2..d9d71460 100644 --- a/src/web/request/getCookieToken.ts +++ b/src/web/request/getCookieToken.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 根据 stoken 获取 cookie_token @@ -21,19 +22,12 @@ export async function getCookieTokenBySToken( Stoken: string, ): Promise { const url = TGApi.GameTokens.getCookieToken; - const cookie = { - mid: Mid, - stoken: Stoken, - }; + const cookie = { mid: Mid, stoken: Stoken }; const params = { stoken: Stoken }; const header = TGUtils.User.getHeader(cookie, "GET", params, "common"); return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", headers: header, query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data.cookie_token; }); @@ -53,12 +47,11 @@ export async function getCookieTokenByGameToken( const url = "https://api-takumi.mihoyo.com/auth/api/getCookieAccountInfoByGameToken"; const data = { account_id: Number(accountId), game_token: gameToken }; return await http - .fetch(url, { - method: "POST", - body: http.Body.json(data), - }) - .then((res) => { - if (res.data.retcode !== 0) return res.data; - return res.data.data.cookie_token; - }); + .fetch(url, { method: "POST", body: http.Body.json(data) }) + .then( + (res: Response) => { + if (res.data.retcode !== 0) return res.data; + return res.data.data.cookie_token; + }, + ); } diff --git a/src/web/request/getDeviceFp.ts b/src/web/request/getDeviceFp.ts index c7fa75fe..7179d7cf 100644 --- a/src/web/request/getDeviceFp.ts +++ b/src/web/request/getDeviceFp.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import { getInitDeviceInfo } from "../../utils/toolFunc"; -import TGConstant from "../constant/TGConstant"; +import { getInitDeviceInfo } from "../../utils/toolFunc.js"; +import TGConstant from "../constant/TGConstant.js"; /** * @description 获取设备指纹 @@ -93,12 +94,8 @@ export async function getDeviceFp( Referer: "https://webstatic.mihoyo.com/", }; info.device_fp = await http - .fetch(url, { - method: "POST", - body: http.Body.json(data), - headers: header, - }) - .then((res) => { + .fetch(url, { method: "POST", body: http.Body.json(data), headers: header }) + .then((res: Response) => { if (res.data.data.code === 200) return res.data.data.device_fp; return "0000000000000"; }); diff --git a/src/web/request/getGachaLog.ts b/src/web/request/getGachaLog.ts index 6dd04dcd..2c759e38 100644 --- a/src/web/request/getGachaLog.ts +++ b/src/web/request/getGachaLog.ts @@ -5,6 +5,7 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; /** * @description 获取抽卡记录 @@ -31,11 +32,8 @@ export async function getGachaLog( end_id: endId, }; return await http - .fetch(url, { - method: "GET", - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data.list; }); diff --git a/src/web/request/getGameAccounts.ts b/src/web/request/getGameAccounts.ts index fadc89fc..6aff08c6 100644 --- a/src/web/request/getGameAccounts.ts +++ b/src/web/request/getGameAccounts.ts @@ -5,10 +5,11 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGConstant from "../constant/TGConstant"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGConstant from "../constant/TGConstant.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 通过 stoken 获取游戏账号 @@ -22,10 +23,7 @@ export async function getGameAccountsBySToken( stuid: string, ): Promise { const url = TGApi.GameData.bySToken.getAccounts; - const cookie = { - stuid, - stoken, - }; + const cookie = { stuid, stoken }; const params = { stoken, stuid, game_biz: TGConstant.Utils.GAME_BIZ }; return await getGameAccounts(url, cookie, params); } @@ -42,10 +40,7 @@ export async function getGameAccountsByCookie( account_id: string, ): Promise { const url = TGApi.GameData.byCookie.getAccounts; - const cookie = { - account_id, - cookie_token, - }; + const cookie = { account_id, cookie_token }; const params = { game_biz: TGConstant.Utils.GAME_BIZ }; return await getGameAccounts(url, cookie, params); } @@ -65,12 +60,8 @@ async function getGameAccounts( ): Promise { const header = TGUtils.User.getHeader(cookie, "GET", params, "common"); return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", headers: header, query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data.list; }); diff --git a/src/web/request/getLToken.ts b/src/web/request/getLToken.ts index 72753916..674891b5 100644 --- a/src/web/request/getLToken.ts +++ b/src/web/request/getLToken.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 根据 stoken_v2 获取 ltoken @@ -21,19 +22,12 @@ export async function getLTokenBySToken( Stoken: string, ): Promise { const url = TGApi.GameTokens.getLToken; - const cookie = { - mid: Mid, - stoken: Stoken, - }; + const cookie = { mid: Mid, stoken: Stoken }; const params = { stoken: Stoken }; const header = TGUtils.User.getHeader(cookie, "GET", params, "common"); return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", headers: header, query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data.ltoken; }); diff --git a/src/web/request/getRoleList.ts b/src/web/request/getRoleList.ts index 67aff6d3..dd92a48d 100644 --- a/src/web/request/getRoleList.ts +++ b/src/web/request/getRoleList.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 通过 Cookie 获取用户角色列表 @@ -26,12 +27,8 @@ export async function getGameRoleListByLToken( const data = { role_id: uid, server: TGUtils.Tools.getServerByUid(uid) }; const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(data), "common"); return await http - .fetch(url, { - method: "POST", - headers: header, - body: http.Body.json(data), - }) - .then((res) => { + .fetch(url, { method: "POST", headers: header, body: http.Body.json(data) }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data.avatars; }); diff --git a/src/web/request/getStoken.ts b/src/web/request/getStoken.ts index dab997fa..d0398a64 100644 --- a/src/web/request/getStoken.ts +++ b/src/web/request/getStoken.ts @@ -5,9 +5,10 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGConstant from "../constant/TGConstant"; -import { getRequestHeader } from "../utils/getRequestHeader"; +import TGConstant from "../constant/TGConstant.js"; +import { getRequestHeader } from "../utils/getRequestHeader.js"; /** * @description 获取 stoken @@ -27,16 +28,10 @@ export async function getStokenByGameToken( url = "https://api-takumi.mihoyo.com/account/ma-cn-session/app/getTokenByGameToken"; } const data = { account_id: Number(accountId), game_token: token }; - const header = { - "x-rpc-app_id": TGConstant.BBS.APP_ID, - }; + const header = { "x-rpc-app_id": TGConstant.BBS.APP_ID }; return await http - .fetch(url, { - method: "POST", - headers: header, - body: http.Body.json(data), - }) - .then((res) => { + .fetch(url, { method: "POST", headers: header, body: http.Body.json(data) }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data; }); @@ -54,20 +49,14 @@ export async function getTokenBySToken( stuid: string, ): Promise { const url = "https://passport-api.mihoyo.com/account/ma-cn-session/app/getTokenBySToken"; - const cookie = { - stoken, - stuid, - }; + const cookie = { stoken, stuid }; const header = { "x-rpc-app_id": TGConstant.BBS.APP_ID, ...getRequestHeader(cookie, "POST", "", "prod"), }; return await http - .fetch(url, { - method: "POST", - headers: header, - }) - .then((res) => { + .fetch(url, { method: "POST", headers: header }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data; }); diff --git a/src/web/request/getSyncAvatarDetail.ts b/src/web/request/getSyncAvatarDetail.ts index aa89f6da..c9f01813 100644 --- a/src/web/request/getSyncAvatarDetail.ts +++ b/src/web/request/getSyncAvatarDetail.ts @@ -5,9 +5,10 @@ */ import { app, http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 获取同步角色详情 @@ -37,15 +38,13 @@ async function getSyncAvatarDetail( Cookie: TGUtils.Tools.transCookie({ account_id: accountId, cookie_token: cookieToken }), }; return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { - if (res.data.retcode !== 0) return res.data; - return res.data.data; - }); + .fetch(url, { method: "GET", headers: header, query: params }) + .then( + (res: Response) => { + if (res.data.retcode !== 0) return res.data; + return res.data.data; + }, + ); } export default getSyncAvatarDetail; diff --git a/src/web/request/getSyncAvatarListAll.ts b/src/web/request/getSyncAvatarListAll.ts index 64d96306..df9c0b80 100644 --- a/src/web/request/getSyncAvatarListAll.ts +++ b/src/web/request/getSyncAvatarListAll.ts @@ -5,9 +5,10 @@ */ import { app, http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGApi from "../api/TGApi"; -import TGUtils from "../utils/TGUtils"; +import TGApi from "../api/TGApi.js"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 获取同步角色列表请求 @@ -23,11 +24,7 @@ async function getSyncAvatarList( page: number, ): Promise { const url = TGApi.GameData.calculate.getSyncAvatarList; // 获取同步角色列表请求地址 - const data = { - uid, - region: TGUtils.Tools.getServerByUid(uid), - page, - }; + const data = { uid, region: TGUtils.Tools.getServerByUid(uid), page }; const version = await app.getVersion(); const header = { "User-Agent": `TeyvatGuide/${version}`, @@ -35,15 +32,13 @@ async function getSyncAvatarList( Cookie: TGUtils.Tools.transCookie(cookie), }; return await http - .fetch(url, { - method: "POST", - body: http.Body.json(data), - headers: header, - }) - .then((res) => { - if (res.data.retcode !== 0) return res.data; - return res.data.data.list; - }); + .fetch(url, { method: "POST", body: http.Body.json(data), headers: header }) + .then( + (res: Response) => { + if (res.data.retcode !== 0) return res.data; + return res.data.data.list; + }, + ); } /** diff --git a/src/web/request/getUserCollect.ts b/src/web/request/getUserCollect.ts index 43d58599..c89d4654 100644 --- a/src/web/request/getUserCollect.ts +++ b/src/web/request/getUserCollect.ts @@ -5,8 +5,9 @@ */ import { http } from "@tauri-apps/api"; +import type { Response } from "@tauri-apps/api/http"; -import TGUtils from "../utils/TGUtils"; +import TGUtils from "../utils/TGUtils.js"; /** * @description 获取用户收藏帖子 @@ -25,12 +26,8 @@ export async function getUserCollect( const params = { size: "20", uid, offset }; const header = TGUtils.User.getHeader(cookie, "GET", params, "common"); return await http - .fetch(url, { - method: "GET", - headers: header, - query: params, - }) - .then((res) => { + .fetch(url, { method: "GET", headers: header, query: params }) + .then((res: Response) => { if (res.data.retcode !== 0) return res.data; return res.data.data; });