diff --git a/src/pages/common/PostTopic.vue b/src/pages/common/PostTopic.vue index 837511aa..278403c7 100644 --- a/src/pages/common/PostTopic.vue +++ b/src/pages/common/PostTopic.vue @@ -95,6 +95,7 @@ import { useRoute, useRouter } from "vue-router"; import { createPost } from "@/utils/TGWindow.js"; import apiHubReq from "@/web/request/apiHubReq.js"; +import postReq from "@/web/request/postReq.js"; import topicReq from "@/web/request/topicReq.js"; type SortSelect = { text: string; value: number }; @@ -169,13 +170,13 @@ watch( async function firstLoad(): Promise { await showLoading.start(`正在加载话题${topicInfo.value?.topic.name}信息`); - router.push({ + await router.push({ name: "话题", params: route.params, query: { gid: curGid.value, topic: curTopic.value }, }); document.documentElement.scrollTo({ top: 0, behavior: "smooth" }); - const postList = await topicReq.posts(curGid.value, curTopic.value, curSortType.value); + const postList = await postReq.topic(curGid.value, curTopic.value, curSortType.value); if ("retcode" in postList) { await showLoading.end(); showSnackbar.error(`[${postList.retcode}] ${postList.message}`); @@ -200,7 +201,7 @@ async function freshPostData(): Promise { await showLoading.start(`正在刷新${topicInfo.value?.topic.name}帖子列表`); const mod20 = postRaw.value.total % 20; const pageSize = mod20 === 0 ? 20 : 20 - mod20; - const postList = await topicReq.posts( + const postList = await postReq.topic( curGid.value, curTopic.value, curSortType.value, diff --git a/src/web/request/postReq.ts b/src/web/request/postReq.ts index 12d89437..3af9b577 100644 --- a/src/web/request/postReq.ts +++ b/src/web/request/postReq.ts @@ -138,6 +138,39 @@ async function getSubReplies( return resp.data; } +/** + * @description 获取特定话题帖子列表 + * @since Beta v0.7.1 + * @param {number} gid 游戏分区 ID + * @param {string} topicId 话题 ID + * @param {string} orderType 排序方式 + * @param {string} lastId 最后一条帖子 ID + * @param {number} size 每页大小 + * @return {Promise} + */ +async function getTopicPostList( + gid: number, + topicId: string, + orderType: number = 0, + lastId?: string, + size: number = 20, +): Promise { + const resp = await TGHttp(`${bapBu}getTopicPostList`, { + method: "GET", + headers: { referer: Referer }, + query: { + gids: gid, + game_id: gid, + topic_id: topicId, + list_type: orderType, + last_id: lastId ?? "", + page_size: size, + }, + }); + if (resp.retcode !== 0) return resp; + return resp.data; +} + /** * @description 搜索帖子 * @since Beta v0.7.1 @@ -186,6 +219,7 @@ async function userFavouritePost( const postReq = { collection: getPostFullInCollection, post: getPostFull, + topic: getTopicPostList, reply: { main: getPostReplies, sub: getSubReplies }, search: searchPosts, userFavourite: userFavouritePost, diff --git a/src/web/request/topicReq.ts b/src/web/request/topicReq.ts index aa459383..269bb35d 100644 --- a/src/web/request/topicReq.ts +++ b/src/web/request/topicReq.ts @@ -29,39 +29,6 @@ async function getTopicFullInfo( return resp.data; } -/** - * @description 获取特定话题帖子列表 - * @since Beta v0.7.1 - * @param {number} gid 游戏分区 ID - * @param {string} topicId 话题 ID - * @param {string} orderType 排序方式 - * @param {string} lastId 最后一条帖子 ID - * @param {number} size 每页大小 - * @return {Promise} - */ -async function getTopicPostList( - gid: number, - topicId: string, - orderType: number = 0, - lastId?: string, - size: number = 20, -): Promise { - const resp = await TGHttp(`${batBu}getTopicPostList`, { - method: "GET", - headers: { referer: Referer }, - query: { - gids: gid, - game_id: gid, - topic_id: topicId, - list_type: orderType, - last_id: lastId ?? "", - page_size: size, - }, - }); - if (resp.retcode !== 0) return resp; - return resp.data; -} - -const topicReq = { info: getTopicFullInfo, posts: getTopicPostList }; +const topicReq = { info: getTopicFullInfo }; export default topicReq;