mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
👽️ 适配帖子api更新
This commit is contained in:
@@ -218,6 +218,26 @@ function getSortLabel(value: number): string {
|
|||||||
return order ? order.text : "";
|
return order ? order.text : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getCurrentPosts(
|
||||||
|
loadMore: boolean = false,
|
||||||
|
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||||
|
if (curSortType.value === 3) {
|
||||||
|
if (loadMore) {
|
||||||
|
return await Mys.Painter.getHotForumPostList(curForum.value, curGid.value, lastId.value);
|
||||||
|
}
|
||||||
|
return await Mys.Painter.getHotForumPostList(curForum.value, curGid.value);
|
||||||
|
}
|
||||||
|
if (loadMore) {
|
||||||
|
return await Mys.Painter.getRecentForumPostList(
|
||||||
|
curForum.value,
|
||||||
|
curGid.value,
|
||||||
|
curSortType.value,
|
||||||
|
lastId.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return await Mys.Painter.getRecentForumPostList(curForum.value, curGid.value, curSortType.value);
|
||||||
|
}
|
||||||
|
|
||||||
async function freshPostData(): Promise<void> {
|
async function freshPostData(): Promise<void> {
|
||||||
await showLoading.start(`正在刷新${getGameLabel(curGid.value)}帖子`);
|
await showLoading.start(`正在刷新${getGameLabel(curGid.value)}帖子`);
|
||||||
const gameLabel = getGameLabel(curGid.value);
|
const gameLabel = getGameLabel(curGid.value);
|
||||||
@@ -228,7 +248,7 @@ async function freshPostData(): Promise<void> {
|
|||||||
);
|
);
|
||||||
await showLoading.update(`版块:${forumLabel},排序:${sortLabel}`);
|
await showLoading.update(`版块:${forumLabel},排序:${sortLabel}`);
|
||||||
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
const postsGet = await Mys.Post.getForumPostList(curForum.value, curSortType.value);
|
const postsGet = await getCurrentPosts();
|
||||||
posts.value = postsGet.list;
|
posts.value = postsGet.list;
|
||||||
lastId.value = postsGet.last_id;
|
lastId.value = postsGet.last_id;
|
||||||
isLast.value = postsGet.is_last;
|
isLast.value = postsGet.is_last;
|
||||||
@@ -242,7 +262,7 @@ async function loadMore(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await showLoading.start("正在加载更多帖子数据", `游戏:${getGameLabel(curGid.value)}`);
|
await showLoading.start("正在加载更多帖子数据", `游戏:${getGameLabel(curGid.value)}`);
|
||||||
const postsGet = await Mys.Post.getForumPostList(curForum.value, curSortType.value, lastId.value);
|
const postsGet = await getCurrentPosts(true);
|
||||||
await showLoading.update(
|
await showLoading.update(
|
||||||
`版块:${curForumLabel.value},排序:${getSortLabel(curSortType.value)},数量:${postsGet.list.length}`,
|
`版块:${curForumLabel.value},排序:${getSortLabel(curSortType.value)},数量:${postsGet.list.length}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,6 +32,84 @@ export async function getNewsList(
|
|||||||
).data;
|
).data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取最近版块热门帖子列表
|
||||||
|
* @since Beta v0.6.7
|
||||||
|
* @param {number} forumId 版块 ID
|
||||||
|
* @param {number} gid 社区 ID
|
||||||
|
* @param {number} pageSize 每页数量
|
||||||
|
* @param {string} lastId 最后 ID
|
||||||
|
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
||||||
|
*/
|
||||||
|
export async function getHotForumPostList(
|
||||||
|
forumId: number,
|
||||||
|
gid: number,
|
||||||
|
lastId?: string,
|
||||||
|
pageSize: number = 20,
|
||||||
|
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||||
|
type ReqParams = {
|
||||||
|
forum_id: number;
|
||||||
|
gids: number;
|
||||||
|
page_size: number;
|
||||||
|
is_good: boolean;
|
||||||
|
last_id?: string;
|
||||||
|
};
|
||||||
|
const params: ReqParams = {
|
||||||
|
forum_id: forumId,
|
||||||
|
gids: gid,
|
||||||
|
page_size: pageSize,
|
||||||
|
is_good: false,
|
||||||
|
};
|
||||||
|
if (lastId) params.last_id = lastId;
|
||||||
|
return (
|
||||||
|
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getHotForumPostList`, {
|
||||||
|
method: "GET",
|
||||||
|
query: params,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取最近版块帖子列表
|
||||||
|
* @since Beta v0.6.7
|
||||||
|
* @param {number} forumId 版块 ID
|
||||||
|
* @param {number} gid 社区 ID
|
||||||
|
* @param {number} type 排序方式: 1-最新回复,2-最新发布
|
||||||
|
* @param {string} lastId 最后 ID
|
||||||
|
* @param {number} pageSize 每页数量
|
||||||
|
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
||||||
|
*/
|
||||||
|
export async function getRecentForumPostList(
|
||||||
|
forumId: number,
|
||||||
|
gid: number,
|
||||||
|
type: number = 1,
|
||||||
|
lastId?: string,
|
||||||
|
pageSize: number = 20,
|
||||||
|
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||||
|
type ReqParams = {
|
||||||
|
forum_id: number;
|
||||||
|
gids: number;
|
||||||
|
sort_type: number;
|
||||||
|
is_good: boolean;
|
||||||
|
page_size: number;
|
||||||
|
last_id?: string;
|
||||||
|
};
|
||||||
|
const params: ReqParams = {
|
||||||
|
forum_id: forumId,
|
||||||
|
gids: gid,
|
||||||
|
sort_type: type,
|
||||||
|
is_good: false,
|
||||||
|
page_size: pageSize,
|
||||||
|
};
|
||||||
|
if (lastId) params.last_id = lastId;
|
||||||
|
return (
|
||||||
|
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getRecentForumPostList`, {
|
||||||
|
method: "GET",
|
||||||
|
query: params,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取抽奖信息
|
* @description 获取抽奖信息
|
||||||
* @since Beta v0.6.2
|
* @since Beta v0.6.2
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file plugins/Mys/request/postReq.ts
|
* @file plugins/Mys/request/postReq.ts
|
||||||
* @description 帖子相关的获取
|
* @description 帖子相关的获取
|
||||||
* @since Beta v0.6.4
|
* @since Beta v0.6.7
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import TGHttp from "@/utils/TGHttp.js";
|
import TGHttp from "@/utils/TGHttp.js";
|
||||||
@@ -12,47 +12,6 @@ const Mpabu: Readonly<string> = "https://bbs-api.mihoyo.com/post/wapi/";
|
|||||||
const Mtabu: Readonly<string> = "https://bbs-api.miyoushe.com/topic/wapi/";
|
const Mtabu: Readonly<string> = "https://bbs-api.miyoushe.com/topic/wapi/";
|
||||||
const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
|
const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 获取特定论坛列表
|
|
||||||
* @since Beta v0.6.2
|
|
||||||
* @param {number} forumId 特定论坛 ID
|
|
||||||
* @param {number} type 排序方式: 0-按热度排序,1-最新回复,2-按时间排序
|
|
||||||
* @param {string} last_id 最后 ID
|
|
||||||
* @param {number} page_size 每页数量
|
|
||||||
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
|
||||||
*/
|
|
||||||
export async function getForumPostList(
|
|
||||||
forumId: number,
|
|
||||||
type: number = 1,
|
|
||||||
last_id?: string,
|
|
||||||
page_size: number = 20,
|
|
||||||
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
|
||||||
let params;
|
|
||||||
if (type === 3) {
|
|
||||||
params = {
|
|
||||||
forum_id: forumId,
|
|
||||||
is_hot: true,
|
|
||||||
page_size: page_size,
|
|
||||||
last_id: last_id,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
params = {
|
|
||||||
forum_id: forumId,
|
|
||||||
sort_type: type,
|
|
||||||
is_good: false,
|
|
||||||
is_hot: false,
|
|
||||||
page_size: page_size,
|
|
||||||
last_id: last_id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getForumPostList`, {
|
|
||||||
method: "GET",
|
|
||||||
query: params,
|
|
||||||
})
|
|
||||||
).data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取单个帖子信息
|
* @description 获取单个帖子信息
|
||||||
* @since Beta v0.6.3
|
* @since Beta v0.6.3
|
||||||
|
|||||||
Reference in New Issue
Block a user