From 623d137457859e4642bf30eb7d52a185fc1dfd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Thu, 4 Apr 2024 15:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E7=B1=B3=E7=A4=BE?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/Mys/api/index.ts | 15 ++-------- src/plugins/Mys/index.ts | 2 +- src/plugins/Mys/request/getCollectionData.ts | 23 ++++++++++------ src/plugins/Mys/request/getForumList.ts | 25 +++++++++++------ src/plugins/Mys/request/getGachaData.ts | 11 ++++---- src/plugins/Mys/request/getHomeNavigator.ts | 19 +++++++++---- src/plugins/Mys/request/getLotteryData.ts | 9 ++++-- src/plugins/Mys/request/getNewsList.ts | 29 +++++++++++++------- src/plugins/Mys/request/getPositionData.ts | 16 +++++------ src/plugins/Mys/request/getPostData.ts | 12 +++++--- src/plugins/Mys/request/getVoteData.ts | 24 +++++++++++----- 11 files changed, 109 insertions(+), 76 deletions(-) diff --git a/src/plugins/Mys/api/index.ts b/src/plugins/Mys/api/index.ts index c125b3f5..2e0b90ff 100644 --- a/src/plugins/Mys/api/index.ts +++ b/src/plugins/Mys/api/index.ts @@ -1,23 +1,12 @@ /** * @file plugins/Mys/api/index.ts * @description Mys API - * @since Beta v0.3.9 + * @since Beta v0.4.5 */ const MysApi = { Obc: "https://bbs.mihoyo.com/ys/obc/content/{contentId}/detail?bbs_presentation_style=no_header", - Gacha: "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc", - Lottery: "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?id={lotteryId}", - News: "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids={gid}&page_size={pageSize}&type={newsType}&last_id={lastId}", - Forum: - "https://bbs-api.miyoushe.com/post/wapi/getForumPostList?forum_id={forum}&sort_type={type}", - Feed: "https://bbs-api.miyoushe.com/post/api/feeds/posts?gids={gid}", - Navigator: "https://bbs-api.miyoushe.com/apihub/api/home/new?gids={gid}", - Position: "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc", - Post: { - Api: "https://bbs-api.mihoyo.com/post/wapi/getPostFull?post_id={postId}", - Referer: "https://bbs.mihoyo.com/", - }, + PostReferer: "https://bbs.mihoyo.com/", }; export default MysApi; diff --git a/src/plugins/Mys/index.ts b/src/plugins/Mys/index.ts index e0fad624..3c32139e 100644 --- a/src/plugins/Mys/index.ts +++ b/src/plugins/Mys/index.ts @@ -12,7 +12,7 @@ import getGachaData from "./request/getGachaData"; import getHomeNavigator from "./request/getHomeNavigator"; import getLotteryData from "./request/getLotteryData"; import getNewsList from "./request/getNewsList"; -import getPositionData from "./request/getPositionData"; +import { getPositionData } from "./request/getPositionData"; import getPostData from "./request/getPostData"; import { getVoteInfo, getVoteResult } from "./request/getVoteData"; import { getGachaCard } from "./utils/getGachaCard"; diff --git a/src/plugins/Mys/request/getCollectionData.ts b/src/plugins/Mys/request/getCollectionData.ts index 8d07fb36..7f0e821b 100644 --- a/src/plugins/Mys/request/getCollectionData.ts +++ b/src/plugins/Mys/request/getCollectionData.ts @@ -1,7 +1,7 @@ /** * @file plugins/Mys/request/getCollectionPosts.ts * @description Mys 获取合集帖子 - * @since Beta v0.3.9 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; @@ -10,7 +10,7 @@ import MysApi from "../api"; /** * @description 获取合集信息 - * @since Beta v0.3.9 + * @since Beta v0.4.5 * @todo invalid request * @param {number} collectionId 合集 ID * @returns {Promise} 合集信息 @@ -18,15 +18,18 @@ import MysApi from "../api"; export async function getCollectionData( collectionId: number, ): Promise { - const url = `https://bbs-api.miyoushe.com/collection/wapi/collection/detail?id=${collectionId}`; - console.log(url); + const url = "https://bbs-api.miyoushe.com/collection/wapi/collection/detail"; + const params = { + id: collectionId.toString(), + }; return await http .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", - Referer: MysApi.Post.Referer, + Referer: MysApi.PostReferer, }, + query: params, }) .then((res) => { console.log(res.data); @@ -36,21 +39,25 @@ export async function getCollectionData( /** * @description 获取合集帖子 - * @since Beta v0.3.9 + * @since Beta v0.4.5 * @param {string} collectionId 合集 ID * @returns {Promise} */ export async function getCollectionPosts( collectionId: string, ): Promise { - const url = `https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection?collection_id=${collectionId}`; + const url = "https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection"; + const params = { + collection_id: collectionId, + }; return await http .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", - Referer: MysApi.Post.Referer, + Referer: MysApi.PostReferer, }, + query: params, }) .then((res) => { return res.data.data.posts; diff --git a/src/plugins/Mys/request/getForumList.ts b/src/plugins/Mys/request/getForumList.ts index 1d353214..6a3c7acc 100644 --- a/src/plugins/Mys/request/getForumList.ts +++ b/src/plugins/Mys/request/getForumList.ts @@ -1,16 +1,14 @@ /** * @file plugins/Mys/request/getForumList.ts * @description Mys 插件特定论坛请求 - * @since Beta v0.3.7 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; -import MysApi from "../api"; - /** * @description 获取特定论坛列表 - * @since Beta v0.3.9 + * @since Beta v0.4.5 * @param {number} forumId 特定论坛 ID * @param {number} type 排序方式: 0-按热度排序,1-最新回复,2-按时间排序 * @return {Promise} @@ -19,11 +17,20 @@ async function getForumList( forumId: number, type: number = 0, ): Promise { - const url = MysApi.Forum.replace("{forum}", forumId.toString()).replace( - "{type}", - type.toString(), - ); - return await http.fetch(url).then((res) => res.data.data); + const url = "https://bbs-api.miyoushe.com/post/wapi/getForumPostList"; + 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); } export default getForumList; diff --git a/src/plugins/Mys/request/getGachaData.ts b/src/plugins/Mys/request/getGachaData.ts index c30916b7..4b38ef14 100644 --- a/src/plugins/Mys/request/getGachaData.ts +++ b/src/plugins/Mys/request/getGachaData.ts @@ -1,21 +1,20 @@ /** - * @file plugins Mys request getGachaData.ts + * @file plugins/Mys/request/getGachaData.ts * @description Mys 抽卡请求 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; -import MysApi from "../api"; - /** * @description 获取卡池信息 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 * @return {Promise} */ 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(MysApi.Gacha, { + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", diff --git a/src/plugins/Mys/request/getHomeNavigator.ts b/src/plugins/Mys/request/getHomeNavigator.ts index 32756ec2..88ddfdd8 100644 --- a/src/plugins/Mys/request/getHomeNavigator.ts +++ b/src/plugins/Mys/request/getHomeNavigator.ts @@ -1,23 +1,30 @@ /** * @file plugins/Mys/request/getHomeNavigator.ts * @description Mys 插件首页导航请求 - * @since Beta v0.3.7 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; -import MysApi from "../api"; - /** * @description 获取首页导航列表 - * @since Beta v0.3.7 + * @since Beta v0.4.5 * @param {number} gid GID * @return {Promise} */ async function getHomeNavigator(gid: number = 2): Promise { - const url = MysApi.Navigator.replace("{gid}", gid.toString()); + const url = "https://bbs-api.miyoushe.com/apihub/api/home/new"; + const params = { + gids: gid.toString(), + }; return await http - .fetch(url) + .fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + query: params, + }) .then((res) => res.data.data.navigator); } diff --git a/src/plugins/Mys/request/getLotteryData.ts b/src/plugins/Mys/request/getLotteryData.ts index a908d144..068cee6c 100644 --- a/src/plugins/Mys/request/getLotteryData.ts +++ b/src/plugins/Mys/request/getLotteryData.ts @@ -6,8 +6,6 @@ import { http } from "@tauri-apps/api"; -import MysApi from "../api"; - /** * @description 获取抽奖信息 * @since Beta v0.4.5 @@ -17,12 +15,17 @@ import MysApi from "../api"; async function getLotteryData( lotteryId: string, ): Promise { + const url = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show"; + const params = { + id: lotteryId, + }; return await http - .fetch(MysApi.Lottery.replace("{lotteryId}", lotteryId), { + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", }, + query: params, }) .then((res) => { if (res.data.retcode !== 0) return res.data; diff --git a/src/plugins/Mys/request/getNewsList.ts b/src/plugins/Mys/request/getNewsList.ts index 934f3c1a..ddec9749 100644 --- a/src/plugins/Mys/request/getNewsList.ts +++ b/src/plugins/Mys/request/getNewsList.ts @@ -1,16 +1,14 @@ /** - * @file plugins Mys request getNewsList.ts + * @file plugins/Mys/request/getNewsList.ts * @description Mys 插件咨讯请求 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; -import MysApi from "../api"; - /** * @description 获取 News 列表 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 * @param {string} gid GID * @param {string} newsType 咨讯类型: 1 为公告,2 为活动,3 为咨讯 * @param {number} pageSize 返回数量 @@ -23,11 +21,22 @@ async function getNewsList( pageSize: number = 20, lastId: number = 0, ): Promise { - const url = MysApi.News.replace("{pageSize}", pageSize.toString()) - .replace("{gid}", gid) - .replace("{newsType}", newsType) - .replace("{lastId}", lastId.toString()); - return await http.fetch(url).then((res) => res.data.data); + const url = "https://bbs-api.mihoyo.com/post/wapi/getNewsList"; + const params = { + gids: gid, + page_size: pageSize.toString(), + type: newsType, + last_id: lastId.toString(), + }; + return await http + .fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + query: params, + }) + .then((res) => res.data.data); } export default getNewsList; diff --git a/src/plugins/Mys/request/getPositionData.ts b/src/plugins/Mys/request/getPositionData.ts index def59c18..f8323703 100644 --- a/src/plugins/Mys/request/getPositionData.ts +++ b/src/plugins/Mys/request/getPositionData.ts @@ -1,13 +1,11 @@ /** - * @file plugins Mys request getPositionData.ts + * @file plugins/Mys/request/getPositionData.ts * @description Mys 插件热点追踪请求 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; -import MysApi from "../api"; - /** * @description 深度优先遍历 * @since Alpha v0.2.1 @@ -29,12 +27,14 @@ function DfsObc(list: TGApp.Plugins.Mys.Position.ObcItem[]): TGApp.Plugins.Mys.P /** * @description 获取热点追踪信息 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 * @return {Promise} */ -async function getPositionData(): Promise { +export async function getPositionData(): Promise { + const url = + "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc"; const res = await http - .fetch(MysApi.Position, { + .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", @@ -45,5 +45,3 @@ async function getPositionData(): Promise { }); return DfsObc(res); } - -export default getPositionData; diff --git a/src/plugins/Mys/request/getPostData.ts b/src/plugins/Mys/request/getPostData.ts index 963c4a50..bd5f92b3 100644 --- a/src/plugins/Mys/request/getPostData.ts +++ b/src/plugins/Mys/request/getPostData.ts @@ -1,7 +1,7 @@ /** * @file plugins Mys request getPostData.ts * @description Mys帖子请求 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; @@ -10,19 +10,23 @@ import MysApi from "../api"; /** * @description 获取帖子信息 - * @since Alpha v0.2.1 + * @since Beta v0.4.5 * @param {number} postId 帖子 ID * @return {Promise} */ async function getPostData(postId: number): Promise { - const url = MysApi.Post.Api.replace("{postId}", postId.toString()); + const url = "https://bbs-api.mihoyo.com/post/wapi/getPostFull"; + const params = { + post_id: postId.toString(), + }; return await http .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", - Referer: MysApi.Post.Referer, + Referer: MysApi.PostReferer, }, + query: params, }) .then((res) => { return res.data.data.post; diff --git a/src/plugins/Mys/request/getVoteData.ts b/src/plugins/Mys/request/getVoteData.ts index 0bb03433..9dc699fb 100644 --- a/src/plugins/Mys/request/getVoteData.ts +++ b/src/plugins/Mys/request/getVoteData.ts @@ -1,7 +1,7 @@ /** * @file plugins/Mys/request/getVoteData.ts * @description Mys 插件投票请求 - * @since Beta v0.3.9 + * @since Beta v0.4.5 */ import { http } from "@tauri-apps/api"; @@ -10,20 +10,25 @@ import MysApi from "../api"; /** * @description 获取投票信息 - * @since Beta v0.3.9 + * @since Beta v0.4.5 * @param {string} id 投票 ID * @param {string} uid 用户 ID * @return {Promise} */ export async function getVoteInfo(id: string, uid: string): Promise { - const url = `https://bbs-api.miyoushe.com/apihub/api/getVotes?owner_uid=${uid}&vote_ids=${id}`; + const url = "https://bbs-api.miyoushe.com/apihub/api/getVotes"; + const params = { + owner_uid: uid, + vote_ids: id, + }; return await http .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", - Referer: MysApi.Post.Referer, + Referer: MysApi.PostReferer, }, + query: params, }) .then((res) => { return res.data.data.data[0]; @@ -32,7 +37,7 @@ export async function getVoteInfo(id: string, uid: string): Promise} @@ -41,14 +46,19 @@ export async function getVoteResult( id: string, uid: string, ): Promise { - const url = `https://bbs-api.miyoushe.com/apihub/api/getVotesResult?owner_uid=${uid}&vote_ids=${id}`; + const url = "https://bbs-api.miyoushe.com/apihub/api/getVotesResult"; + const params = { + owner_uid: uid, + vote_ids: id, + }; return await http .fetch(url, { method: "GET", headers: { "Content-Type": "application/json", - Referer: MysApi.Post.Referer, + Referer: MysApi.PostReferer, }, + query: params, }) .then((res) => { return res.data.data.data[0];