♻️ 请求重构,合并postWapi跟apiHub相关请求

This commit is contained in:
目棃
2024-10-24 23:08:34 +08:00
parent 41db04b7a2
commit 26041948ef
31 changed files with 399 additions and 594 deletions

View File

@@ -1,12 +0,0 @@
/**
* @file plugins/Mys/api/index.ts
* @description Mys API
* @since Beta v0.4.5
*/
const MysApi = {
Obc: "https://bbs.mihoyo.com/ys/obc/content/{contentId}/detail?bbs_presentation_style=no_header",
PostReferer: "https://bbs.mihoyo.com/",
};
export default MysApi;

View File

@@ -1,41 +1,23 @@
/**
* @file plugins/Mys/index.ts
* @description Mys plugin index
* @since Beta v0.5.5
* @since Beta v0.6.2
*/
import MysApi from "./api/index.js";
import * as ApiHub from "./request/apiHubReq.js";
import { getCaptcha, doCaptchaLogin } from "./request/doCaptchaLogin.js";
import { getLoginQr, getLoginStatus } from "./request/doGameLogin.js";
import { getCollectionPosts } from "./request/getCollectionData.js";
import getForumList from "./request/getForumList.js";
import getGachaData from "./request/getGachaData.js";
import getHomeNavigator from "./request/getHomeNavigator.js";
import getLotteryData from "./request/getLotteryData.js";
import getNewsList from "./request/getNewsList.js";
import { getPositionData } from "./request/getPositionData.js";
import getPostData from "./request/getPostData.js";
import { getPostReply, getPostSubRoot, getPostSubReply } from "./request/getPostReply.js";
import { getVoteInfo, getVoteResult } from "./request/getVoteData.js";
import searchPosts from "./request/searchPost.js";
import * as Painter from "./request/painterReq.js";
import * as Post from "./request/postReq.js";
import { getGachaCard } from "./utils/getGachaCard.js";
import getLotteryCard from "./utils/getLotteryCard.js";
import getPositionCard from "./utils/getPositionCard.js";
const Mys = {
Api: MysApi,
Post: {
get: getPostData,
reply: getPostReply,
replySubRoot: getPostSubRoot,
replySub: getPostSubReply,
},
PostCollect: getCollectionPosts,
Posts: {
get: getForumList,
nav: getHomeNavigator,
search: searchPosts,
},
Post,
ApiHub,
Gacha: {
get: getGachaData,
card: getGachaCard,
@@ -44,9 +26,8 @@ const Mys = {
get: getPositionData,
card: getPositionCard,
},
News: getNewsList,
Lottery: {
get: getLotteryData,
get: Painter.lotteryUserShow,
card: getLotteryCard,
},
User: {
@@ -55,10 +36,6 @@ const Mys = {
getCaptcha,
login: doCaptchaLogin,
},
Vote: {
get: getVoteInfo,
result: getVoteResult,
},
};
export default Mys;

View File

@@ -0,0 +1,64 @@
/**
* @file plugins/Mys/request/apiHubReq.ts
* @description apiHub下的请求
* @since Beta v0.6.2
*/
import TGHttp from "../../../utils/TGHttp.js";
// MysApiHubApiBaseUrl => Mahabu
const Mahabu = "https://bbs-api.miyoushe.com/apihub/api/";
const Referer = "https://bbs.mihoyo.com/";
/**
* @description 获取投票信息
* @since Beta v0.6.2
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>}
*/
export async function getVotes(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
return (
await TGHttp<TGApp.Plugins.Mys.Vote.InfoResponse>(`${Mahabu}getVotes`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
})
).data.data[0];
}
/**
* @description 获取投票结果
* @since Beta v0.6.2
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>}
*/
export async function getVoteResult(
id: string,
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
return (
await TGHttp<TGApp.Plugins.Mys.Vote.ResultResponse>(`${Mahabu}getVotesResult`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
})
).data.data[0];
}
/**
* @description 获取首页导航列表
* @since Beta v0.6.2
* @param {number} gid GID
* @return {Promise<TGApp.BBS.Navigator.Navigator[]>}
*/
export async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
return (
await TGHttp<TGApp.BBS.Navigator.HomeResponse>(`${Mahabu}home/new`, {
method: "GET",
headers: { "x-rpc-client_type": "2" },
query: { gids: gid },
})
).data.navigator;
}

View File

@@ -1,27 +0,0 @@
/**
* @file plugins/Mys/request/getCollectionPosts.ts
* @description Mys 获取合集帖子
* @since Beta v0.5.5
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取合集帖子
* @since Beta v0.5.0
* @param {string} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
*/
export async function getCollectionPosts(
collectionId: string,
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection";
const params = { collection_id: collectionId };
const resp = await TGHttp<TGApp.Plugins.Mys.Collection.ResponsePosts>(url, {
method: "GET",
query: params,
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
});
return resp.data.posts;
}

View File

@@ -1,35 +0,0 @@
/**
* @file plugins/Mys/request/getForumList.ts
* @description Mys 插件特定论坛请求
* @since Beta v0.5.1
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取特定论坛列表
* @since Beta v0.5.1
* @param {number} forumId 特定论坛 ID
* @param {number} type 排序方式: 0-按热度排序1-最新回复2-按时间排序
* @param {number} page_size 每页数量
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
*/
async function getForumList(
forumId: number,
type: number = 0,
page_size: number = 20,
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getForumPostList";
const params = {
forum_id: forumId.toString(),
sort_type: type.toString(),
page_size: page_size.toString(),
};
const resp = await TGHttp<TGApp.Plugins.Mys.Forum.Response>(url, {
method: "GET",
query: params,
});
return resp.data;
}
export default getForumList;

View File

@@ -1,27 +0,0 @@
/**
* @file plugins/Mys/request/getHomeNavigator.ts
* @description Mys 插件首页导航请求
* @since Beta v0.5.1
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取首页导航列表
* @since Beta v0.5.1
* @param {number} gid GID
* @return {Promise<TGApp.BBS.Navigator.Navigator[]>}
*/
async function getHomeNavigator(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
const url = "https://bbs-api.miyoushe.com/apihub/api/home/new";
const params = { gids: gid.toString() };
const header = { "x-rpc-client_type": "2" };
const resp = await TGHttp<TGApp.BBS.Navigator.HomeResponse>(url, {
method: "GET",
headers: header,
query: params,
});
return resp.data.navigator;
}
export default getHomeNavigator;

View File

@@ -1,39 +0,0 @@
/**
* @file plugins/Mys/request/getNewsList.ts
* @description Mys 插件咨讯请求
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取 News 列表
* @since Beta v0.5.0
* @param {string} gid GID
* @param {string} newsType 咨讯类型: 1 为公告2 为活动3 为咨讯
* @param {number} pageSize 返回数量
* @param {number} lastId 上一次请求的最后一条数据的 id
* @return {Promise<TGApp.Plugins.Mys.News.FullData>}
*/
async function getNewsList(
gid: string = "2",
newsType: string = "1",
pageSize: number = 20,
lastId: number = 0,
): Promise<TGApp.Plugins.Mys.News.FullData> {
const url = "https://bbs-api.mihoyo.com/post/wapi/getNewsList";
const params = {
gids: gid,
page_size: pageSize.toString(),
type: newsType,
last_id: lastId.toString(),
};
const resp = await TGHttp<TGApp.Plugins.Mys.News.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data;
}
export default getNewsList;

View File

@@ -1,27 +0,0 @@
/**
* @file plugins Mys request getPostData.ts
* @description Mys帖子请求
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取帖子信息
* @since Beta v0.5.0
* @param {number} postId 帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Post.FullData>}
*/
async function getPostData(postId: number): Promise<TGApp.Plugins.Mys.Post.FullData> {
const url = "https://bbs-api.mihoyo.com/post/wapi/getPostFull";
const params = { post_id: postId.toString() };
const resp = await TGHttp<TGApp.Plugins.Mys.Post.Response>(url, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
return resp.data.post;
}
export default getPostData;

View File

@@ -1,115 +0,0 @@
/**
* @file plugins/Mys/request/getPostReply.ts
* @description Mys 插件帖子回复请求
* @since Beta v0.5.5
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取帖子回复信息
* @since Beta v0.5.5
* @param {string} postId 帖子 ID
* @param {number} gid 社区 ID
* @param {boolean} isHot 是否热门
* @param {boolean} onlyMaster 是否只看楼主
* @param {number} orderType 排序类型
* @param {string} lastId 最后 ID
* @param {number} size 每页大小
* @return {Promise<TGApp.Plugins.Mys.Reply.ReplyData|TGApp.BBS.Response.Base>}
*/
export async function getPostReply(
postId: string,
gid: number,
isHot: boolean = true,
lastId?: string,
onlyMaster: boolean = false,
orderType?: 1 | 2,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.ReplyData | TGApp.BBS.Response.Base> {
const params: Record<string, string | number | boolean> = {
post_id: postId,
gids: gid,
is_hot: isHot,
size: size,
};
if (lastId) {
params["last_id"] = lastId;
}
if (orderType) {
params["order_type"] = orderType;
}
if (onlyMaster) {
params["is_hot"] = false;
params["only_master"] = onlyMaster;
}
const link = "https://bbs-api.miyoushe.com/post/wapi/getPostReplies";
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.Response>(link, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取帖子子回复根信息
* @since Beta v0.5.5
* @param {number} gid 社区 ID
* @param {string} postId 帖子 ID
* @param {string} replyId 回复 ID
* @return {Promise<TGApp.Plugins.Mys.Reply.SubRootData|TGApp.BBS.Response.Base>}
*/
export async function getPostSubRoot(
gid: number,
postId: string,
replyId: string,
): Promise<TGApp.Plugins.Mys.Reply.SubRootData | TGApp.BBS.Response.Base> {
const link = "https://bbs-api.miyoushe.com/post/wapi/getRootReplyInfo";
const params = { gids: gid, post_id: postId, reply_id: replyId };
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.SubRootResponse>(link, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取帖子子回复信息
* @since Beta v0.5.5
* @param {number} floorId 楼层 ID
* @param {number} gid 社区 ID
* @param {string} postId 帖子 ID
* @param {string} lastId 最后 ID
* @param {number} size 每页大小
* @return {Promise<TGApp.Plugins.Mys.Reply.SubData|TGApp.BBS.Response.Base>}
*/
export async function getPostSubReply(
floorId: number,
gid: number,
postId: string,
lastId?: string,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.SubData | TGApp.BBS.Response.Base> {
const params: Record<string, string | number> = {
floor_id: floorId,
gids: gid,
post_id: postId,
size: size,
};
if (lastId) {
params["last_id"] = lastId;
}
const link = "https://bbs-api.miyoushe.com/post/wapi/getSubReplies";
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.SubResponse>(link, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}

View File

@@ -1,47 +0,0 @@
/**
* @file plugins/Mys/request/getVoteData.ts
* @description Mys 插件投票请求
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取投票信息
* @since Beta v0.5.0
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>}
*/
export async function getVoteInfo(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotes";
const params = { owner_uid: uid, vote_ids: id };
const resp = await TGHttp<TGApp.Plugins.Mys.Vote.InfoResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.data[0];
}
/**
* @description 获取投票结果
* @since Beta v0.5.0
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>}
*/
export async function getVoteResult(
id: string,
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotesResult";
const params = { owner_uid: uid, vote_ids: id };
const resp = await TGHttp<TGApp.Plugins.Mys.Vote.ResultResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.data[0];
}

View File

@@ -1,29 +1,30 @@
/**
* @file plugins/Mys/request/getLotteryData.ts
* @description Mys
* @since Beta v0.5.0
* @file plugins/Mys/request/painterReq.ts
* @description painter下的请求
* @since Beta v0.6.2
*/
import TGHttp from "../../../utils/TGHttp.js";
// MysPainterApiBaseUrl => Mpabu
const Mpabu = "https://bbs-api.miyoushe.com/painter/wapi/";
/**
* @description
* @since Beta v0.5.0
* @since Beta v0.6.2
* @param {string} lotteryId ID
* @return {Promise<TGApp.BBS.Response.Base|TGApp.Plugins.Mys.Lottery.FullData>}
*/
async function getLotteryData(
export async function lotteryUserShow(
lotteryId: string,
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.FullData> {
const url = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show";
const params = { id: lotteryId };
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>(
`${Mpabu}lottery/user/show`,
{
method: "GET",
headers: { "Content-Type": "application/json" },
query: { id: lotteryId },
},
);
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.show_lottery;
}
export default getLotteryData;

View File

@@ -0,0 +1,193 @@
/**
* @file plugins/Mys/request/postReq.ts
* @description 帖子相关的获取
* @since Beta v0.6.2
*/
import TGHttp from "../../../utils/TGHttp.js";
// MysPostApiBaseUrl => Mpabu
const Mpabu = "https://bbs-api.mihoyo.com/post/wapi/";
const Referer = "https://bbs.mihoyo.com/";
/**
* @description 获取特定论坛列表
* @since Beta v0.6.2
* @param {number} forumId 特定论坛 ID
* @param {number} type 排序方式: 0-按热度排序1-最新回复2-按时间排序
* @param {number} page_size 每页数量
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
*/
export async function getForumPostList(
forumId: number,
type: number = 0,
page_size: number = 20,
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
return (
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getForumPostList`, {
method: "GET",
query: { forum_id: forumId, sort_type: type, page_size: page_size },
})
).data;
}
/**
* @description 获取 News 列表
* @since Beta v0.6.2
* @param {string} gid GID
* @param {string} newsType 咨讯类型: 1 为公告2 为活动3 为咨讯
* @param {number} pageSize 返回数量
* @param {number} lastId 上一次请求的最后一条数据的 id
* @return {Promise<TGApp.Plugins.Mys.News.FullData>}
*/
export async function getNewsList(
gid: string = "2",
newsType: string = "1",
pageSize: number = 20,
lastId: number = 0,
): Promise<TGApp.Plugins.Mys.News.FullData> {
return (
await TGHttp<TGApp.Plugins.Mys.News.Response>(`${Mpabu}getNewsList`, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: { gids: gid, page_size: pageSize, type: newsType, last_id: lastId },
})
).data;
}
/**
* @description 获取单个帖子信息
* @since Beta v0.6.2
* @param {number} postId 帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Post.FullData>}
*/
export async function getPostFull(postId: number): Promise<TGApp.Plugins.Mys.Post.FullData> {
return (
await TGHttp<TGApp.Plugins.Mys.Post.Response>(`${Mpabu}getPostFull`, {
method: "GET",
headers: { referer: Referer },
query: { post_id: postId },
})
).data.post;
}
/**
* @description 获取合集帖子
* @since Beta v0.6.2
* @param {string} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
*/
export async function getPostFullInCollection(
collectionId: string,
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
return (
await TGHttp<TGApp.Plugins.Mys.Collection.ResponsePosts>(`${Mpabu}getPostFullInCollection`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { collection_id: collectionId },
})
).data.posts;
}
/**
* @description 获取帖子回复信息
* @since Beta v0.6.2
* @param {string} postId 帖子 ID
* @param {number} gid 社区 ID
* @param {boolean} isHot 是否热门
* @param {boolean} onlyMaster 是否只看楼主
* @param {number} orderType 排序类型
* @param {string} lastId 最后 ID
* @param {number} size 每页大小
* @return {Promise<TGApp.Plugins.Mys.Reply.ReplyData|TGApp.BBS.Response.Base>}
*/
export async function getPostReplies(
postId: string,
gid: number,
isHot: boolean = true,
lastId?: string,
onlyMaster: boolean = false,
orderType?: 1 | 2,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.ReplyData | TGApp.BBS.Response.Base> {
type GprParam = {
post_id: string;
gids: number;
is_hot: boolean;
size: number;
last_id?: string;
order_type?: 1 | 2;
only_master?: boolean;
};
const params: GprParam = { post_id: postId, gids: gid, is_hot: isHot, size: size };
if (lastId) params.last_id = lastId;
if (orderType) params.order_type = orderType;
if (onlyMaster) {
params.is_hot = false;
params.only_master = onlyMaster;
}
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.Response>(`${Mpabu}getPostReplies`, {
method: "GET",
headers: { referer: Referer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取帖子子回复信息
* @since Beta v0.6.2
* @param {number} floorId 楼层 ID
* @param {number} gid 社区 ID
* @param {string} postId 帖子 ID
* @param {string} lastId 最后 ID
* @param {number} size 每页大小
* @return {Promise<TGApp.Plugins.Mys.Reply.SubData|TGApp.BBS.Response.Base>}
*/
export async function getSubReplies(
floorId: number,
gid: number,
postId: string,
lastId?: string,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.SubData | TGApp.BBS.Response.Base> {
type GsrParam = {
floor_id: number;
gids: number;
post_id: string;
size: number;
last_id?: string;
};
const params: GsrParam = { floor_id: floorId, gids: gid, post_id: postId, size: size };
if (lastId) params.last_id = lastId;
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.SubResponse>(`${Mpabu}getSubReplies`, {
method: "GET",
headers: { referer: Referer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 搜索帖子
* @since Beta v0.6.2
* @param {string} gid 游戏分区 ID
* @param {string} keyword 关键词
* @param {string} lastId 最后一条帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Search.PostsResponseData>} 返回帖子列表
*/
export async function searchPosts(
gid: string = "2",
keyword: string,
lastId: string,
): Promise<TGApp.Plugins.Mys.Search.PostsResponseData> {
return (
await TGHttp<TGApp.Plugins.Mys.Search.PostsResponse>(`${Mpabu}searchPosts`, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: { gids: gid, keyword, last_id: lastId, size: 20 },
})
).data;
}

View File

@@ -1,32 +0,0 @@
/**
* @file plugins/Mys/request/searchPost.ts
* @description 帖子搜索
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 搜索帖子
* @since Beta v0.5.0
* @param {string} gid 游戏分区 ID
* @param {string} keyword 关键词
* @param {string} last_id 最后一条帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Search.PostsResponseData>} 返回帖子列表
*/
async function searchPosts(
gid: string = "2",
keyword: string,
last_id: string,
): Promise<TGApp.Plugins.Mys.Search.PostsResponseData> {
const url = "https://bbs-api.miyoushe.com/post/wapi/searchPosts";
const params = { gids: gid, keyword, last_id, size: "20" };
const resp = await TGHttp<TGApp.Plugins.Mys.Search.PostsResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data;
}
export default searchPosts;

View File

@@ -1,15 +1,15 @@
/**
* @file plugins/Mys/utils/getGachaCard.ts
* @description Mys 插件抽卡工具
* @since Beta v0.5.0
* @since Beta v0.6.2
*/
import { AppCharacterData } from "../../../data/index.js";
import getPostData from "../request/getPostData.js";
import { getPostFull } from "../request/postReq.js";
/**
* @description 根据单个卡池信息转为渲染用的卡池信息
* @since Beta v0.5.0
* @since Beta v0.6.2
* @param {TGApp.Plugins.Mys.Gacha.Data} data 卡池信息
* @param {string} poolCover 卡池封面
* @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard>}
@@ -28,7 +28,7 @@ async function getGachaItemCard(
} else {
try {
console.log("调用 getPostData");
const post = await getPostData(postId);
const post = await getPostFull(postId);
cover = post.cover?.url ?? post.post.images[0];
} catch (error) {
console.error(error);

View File

@@ -1,14 +1,12 @@
/**
* @file plugins/Mys/utils/getPositionCard.ts
* @description Mys 插件热点追踪工具
* @since Beta v0.5.3
* @since Beta v0.6.2
*/
import Mys from "../index.js";
/**
* @description 根据热点追踪信息转为渲染用的数据
* @since Beta v0.5.3
* @since Beta v0.6.2
* @param {TGApp.Plugins.Mys.Position.Data[]} positionData 列表
* @returns {TGApp.Plugins.Mys.Position.RenderCard[]} 返回列表
*/
@@ -25,7 +23,7 @@ function getPositionCard(
}
let link = position.url;
if (position.url === "" && position.content_id !== 0) {
link = Mys.Api.Obc.replace("{contentId}", position.content_id.toString());
link = `https://bbs.mihoyo.com/ys/obc/content/${position.content_id}/detail?bbs_presentation_style=no_header`;
}
const card: TGApp.Plugins.Mys.Position.RenderCard = {
title: position.title,