From afe53f3d306434339d4c62e2def2602b23e55c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Fri, 15 Nov 2024 12:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E8=AF=9D=E9=A2=98=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/{Posts.vue => PostForum.vue} | 1 - src/pages/common/PostTopic.vue | 237 ++++++++++++++++++ src/plugins/Mys/request/postReq.ts | 55 ++++ src/plugins/Mys/types/Topic.d.ts | 164 ++++++++++++ src/router/modules/main.ts | 9 +- src/views/t-post.vue | 60 +++-- 6 files changed, 503 insertions(+), 23 deletions(-) rename src/pages/common/{Posts.vue => PostForum.vue} (99%) create mode 100644 src/pages/common/PostTopic.vue create mode 100644 src/plugins/Mys/types/Topic.d.ts diff --git a/src/pages/common/Posts.vue b/src/pages/common/PostForum.vue similarity index 99% rename from src/pages/common/Posts.vue rename to src/pages/common/PostForum.vue index 3a4e6e79..40387761 100644 --- a/src/pages/common/Posts.vue +++ b/src/pages/common/PostForum.vue @@ -5,7 +5,6 @@
posts 帖子 -
diff --git a/src/pages/common/PostTopic.vue b/src/pages/common/PostTopic.vue new file mode 100644 index 00000000..7e135a2a --- /dev/null +++ b/src/pages/common/PostTopic.vue @@ -0,0 +1,237 @@ + + + diff --git a/src/plugins/Mys/request/postReq.ts b/src/plugins/Mys/request/postReq.ts index c35da45e..ab370fb0 100644 --- a/src/plugins/Mys/request/postReq.ts +++ b/src/plugins/Mys/request/postReq.ts @@ -8,6 +8,8 @@ import TGHttp from "../../../utils/TGHttp.js"; // MysPostApiBaseUrl => Mpabu const Mpabu = "https://bbs-api.mihoyo.com/post/wapi/"; +// MysTopicApiBaseUrl => Mtapu +const Mtabu = "https://bbs-api.miyoushe.com/topic/wapi/"; const Referer = "https://bbs.mihoyo.com/"; /** @@ -146,6 +148,59 @@ export async function getSubReplies( return resp.data; } +/** + * @description 获取特定话题信息 + * @since Beta v0.6.3 + * @param {string} gid 游戏分区 ID + * @param {string} topicId 话题 ID + * @return {Promise} + */ +export async function getTopicFullInfo( + gid: string, + topicId: string, +): Promise { + const resp = await TGHttp(`${Mtabu}getTopicFullInfo`, { + method: "GET", + headers: { referer: Referer }, + query: { gids: gid, id: topicId }, + }); + if (resp.retcode !== 0) return resp; + return resp.data; +} + +/** + * @description 获取特定话题帖子列表 + * @since Beta v0.6.3 + * @param {string} gid 游戏分区 ID + * @param {string} topicId 话题 ID + * @param {string} orderType 排序方式 + * @param {string} lastId 最后一条帖子 ID + * @param {number} size 每页大小 + * @return {Promise} + */ +export async function getTopicPostList( + gid: string, + topicId: string, + orderType: number = 0, + lastId?: string, + size: number = 20, +): Promise { + const resp = await TGHttp(`${Mpabu}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.6.2 diff --git a/src/plugins/Mys/types/Topic.d.ts b/src/plugins/Mys/types/Topic.d.ts new file mode 100644 index 00000000..ea9d6520 --- /dev/null +++ b/src/plugins/Mys/types/Topic.d.ts @@ -0,0 +1,164 @@ +/** + * @file plugins/Mys/types/Topic.d.ts + * @description Mys 插件话题类型定义文件 + * @since Beta v0.6.3 + */ + +declare namespace TGApp.Plugins.Mys.Topic { + /** + * @description 特定话题返回数据-话题信息 + * @since Beta v0.6.3 + * @interface InfoResponse + * @extends TGApp.BBS.Response.BaseWithData + * @property {InfoData} data 特定话题数据 + * @return InfoResponse + */ + interface InfoResponse extends TGApp.BBS.Response.BaseWithData { + data: InfoData; + } + + /** + * @description 特定话题返回数据-帖子列表 + * @since Beta v0.6.3 + * @interface PostResponse + * @extends TGApp.BBS.Response.BaseWithData + * @property {PostData} data 特定话题帖子列表数据 + * @return PostResponse + */ + interface PostResponse extends TGApp.BBS.Response.BaseWithData { + data: PostData; + } + + /** + * @description 特定话题数据 + * @since Beta v0.6.3 + * @interface InfoData + * @property {GameInfo[]} game_info_list 游戏信息列表 + * @property {boolean} good_exist 是否有精华帖 + * @property {number} good_post_cnt 精华帖数量 + * @property {boolean} good_post_exist 是否有精华帖 + * @property {number} hot_post_cnt 热帖数量 + * @property {unknown[]} related_forums 相关版块 + * @property {unknown[]} related_topics 相关话题 + * @property {unknown[]} top_posts 置顶帖 + * @property {Info} topic 话题信息 + * @return InfoData + */ + interface InfoData { + game_info_list: GameInfo[]; + good_exist: boolean; + good_post_cnt: number; + good_post_exist: boolean; + hot_post_cnt: number; + related_forums: unknown[]; + related_topics: unknown[]; + top_posts: unknown[]; + topic: Info; + } + + /** + * @description 特定话题帖子列表数据 + * @since Beta v0.6.3 + * @interface PostData + * @property {boolean} is_last 是否最后一页 + * @property {boolean} is_origin 是否原创 + * @property {string} last_id 最后一条帖子 ID + * @property {TGApp.Plugins.Mys.Post.FullData[]} posts 帖子列表 + * @return PostData + */ + interface PostData { + is_last: boolean; + is_origin: boolean; + last_id: string; + posts: TGApp.Plugins.Mys.Post.FullData[]; + } + + /** + * @description 游戏信息 + * @since Beta v0.6.3 + * @interface GameInfo + * @property {number} id 游戏 ID + * @property {string} name 游戏名称 + * @property {boolean} has_good 是否有精华帖 + * @property {boolean} has_hot 是否有热帖 + * @return GameInfo + */ + interface GameInfo { + id: number; + name: string; + has_good: boolean; + has_hot: boolean; + } + + /** + * @description 话题信息 + * @since Beta v0.6.3 + * @interface Info + * @property {string[]} alias 话题别名 + * @property {number} content_type 内容类型 + * @property {string} cover 封面图片 URL + * @property {number} created_at 创建时间(秒级时间戳) + * @property {string} creator 创建者 + * @property {number} creator_type 创建者类型 + * @property {number} default_game_id 默认游戏 ID + * @property {string} desc 话题描述 + * @property {number} game_id 游戏 ID + * @property {number} good_cnt 精华帖数量 + * @property {string} id 话题 ID + * @property {number} is_deleted 是否已删除,0-未删除,1-已删除 + * @property {boolean} is_focus 是否关注 + * @property {boolean} is_interactive 是否互动 + * @property {string} name 话题名称 + * @property {number} order 排序 + * @property {unknown} related_forum_ids 相关版块 ID + * @property {unknown} stat 话题统计-可能为null + * @property {SortConfig[]} topic_sort_config 话题排序配置 + * @property {number} topic_type 话题类型 + * @property {string} updated_at 更新时间(秒级时间戳) + * @property {number[]} view_type 查看类型 + * @return Info + */ + interface Info { + alias: string[]; + content_type: number; + cover: string; + created_at: number; + creator: string; + creator_type: number; + default_game_id: number; + desc: string; + game_id: number; + good_cnt: number; + id: string; + is_deleted: number; + is_focus: boolean; + is_interactive: boolean; + name: string; + order: number; + related_forum_ids: unknown; + stat: unknown; + topic_sort_config: SortConfig[]; + topic_type: number; + updated_at: string; + view_type: number[]; + } + + /** + * @description 话题排序配置 + * @since Beta v0.6.3 + * @interface SortConfig + * @property {string} name 排序名称 + * @property {number} type 排序类型 + * @property {string} url 排序 URL + * @property {number} show_sort 展示顺序 + * @property {string} data_report_name 数据报告名称 + * @return SortConfig + */ + interface SortConfig { + name: string; + type: number; + url: string; + show_sort: number; + data_report_name: string; + } +} diff --git a/src/router/modules/main.ts b/src/router/modules/main.ts index 7877ee53..856825cd 100644 --- a/src/router/modules/main.ts +++ b/src/router/modules/main.ts @@ -1,7 +1,7 @@ /** * @file router/modules/main.ts * @description 主路由模块 - * @since Beta v0.5.1 + * @since Beta v0.6.3 */ const mainRoutes = [ @@ -23,7 +23,12 @@ const mainRoutes = [ { path: "/posts/:gid?/:forum?", name: "酒馆", - component: async () => await import("../../pages/common/Posts.vue"), + component: async () => await import("../../pages/common/PostForum.vue"), + }, + { + path: "/posts/:gid?/:topic", + name: "话题", + component: async () => await import("../../pages/common/PostTopic.vue"), }, { path: "/achievements/:app?", diff --git a/src/views/t-post.vue b/src/views/t-post.vue index 107bbffc..925d5389 100644 --- a/src/views/t-post.vue +++ b/src/views/t-post.vue @@ -61,8 +61,12 @@ {{ postData.collection.collection_title }} {{ postData.collection.cur }}/{{ postData.collection.total }}
- -
+
mdi-tag {{ topic.name }}
@@ -88,6 +92,7 @@