diff --git a/src/plugins/Mys/index.ts b/src/plugins/Mys/index.ts index 3170f946..8ce63c5c 100644 --- a/src/plugins/Mys/index.ts +++ b/src/plugins/Mys/index.ts @@ -1,11 +1,12 @@ /** * @file plugins/Mys/index.ts * @description Mys plugin index - * @since Beta v0.3.7 + * @since Beta v0.3.9 */ import MysApi from "./api"; import { getLoginQr, getLoginStatus } from "./request/doGameLogin"; +import { getCollectionData, getCollectionPosts } from "./request/getCollectionData"; import getForumList from "./request/getForumList"; import getGachaData from "./request/getGachaData"; import getHomeNavigator from "./request/getHomeNavigator"; @@ -24,6 +25,10 @@ const Mys = { Post: { get: getPostData, }, + Collection: { + info: getCollectionData, + data: getCollectionPosts, + }, Posts: { get: getForumList, card: getPostsCard, diff --git a/src/plugins/Mys/request/getCollectionData.ts b/src/plugins/Mys/request/getCollectionData.ts new file mode 100644 index 00000000..6d6234fb --- /dev/null +++ b/src/plugins/Mys/request/getCollectionData.ts @@ -0,0 +1,58 @@ +/** + * @file plugins/Mys/request/getCollectionPosts.ts + * @description Mys 获取合集帖子 + * @since Beta v0.3.9 + */ + +import { http } from "@tauri-apps/api"; + +import MysApi from "../api"; + +/** + * @description 获取合集信息 + * @since Beta v0.3.9 + * @todo invalid request + * @param {number} collectionId 合集 ID + * @returns {Promise} 合集信息 + */ +export async function getCollectionData( + collectionId: number, +): Promise { + const url = `https://bbs-api.miyoushe.com/collection/wapi/collection/detail?id=${collectionId}`; + console.log(url); + return await http + .fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + Referer: MysApi.Post.Referer, + }, + }) + .then((res) => { + console.log(res.data); + return res.data.data; + }); +} + +/** + * @description 获取合集帖子 + * @since Beta v0.3.9 + * @param {number} collectionId 合集 ID + * @returns {Promise} + */ +export async function getCollectionPosts( + collectionId: number, +): Promise { + const url = `https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection?collection_id=${collectionId}`; + return await http + .fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + Referer: MysApi.Post.Referer, + }, + }) + .then((res) => { + return res.data.data.posts; + }); +} diff --git a/src/plugins/Mys/types/Collection.d.ts b/src/plugins/Mys/types/Collection.d.ts new file mode 100644 index 00000000..588a5115 --- /dev/null +++ b/src/plugins/Mys/types/Collection.d.ts @@ -0,0 +1,92 @@ +/** + * @file plugins/Mys/types/Collection.d.ts + * @description Mys 插件合集类型声明 + * @since Beta v0.3.9 + */ + +/** + * @description Mys 合集类型 + * @since Beta v0.3.9 + * @namespace TGApp.Plugins.Mys.Collection + * @memberof TGApp.Plugins.Mys + */ +declare namespace TGApp.Plugins.Mys.Collection { + /** + * @description 合集信息返回 + * @since Beta v0.3.9 + * @interface Response + * @extends TGApp.BBS.Response.BaseWithData + * @property {ResponseData} data 返回数据 + * @return Response + */ + interface Response extends TGApp.BBS.Response.BaseWithData { + data: ResponseData; + } + + /** + * @description 合集信息返回数据 + * @since Beta v0.3.9 + * @interface ResponseData + * @property {Info} collection_info 合集信息 + * @property {TGApp.Plugins.Mys.User.Collection} author_info 用户信息 + * @return ResponseData + */ + interface ResponseData { + collection_info: Info; + author_info: TGApp.Plugins.Mys.User.Collection; + } + + /** + * @description 合集信息 + * @since Beta v0.3.9 + * @interface Info + * @property {string} cover 封面 + * @property {string} desc 描述 + * @property {number} id 合集 ID + * @property {boolean} is_delete 是否删除 + * @property {boolean} is_following 是否关注 + * @property {number} post_num 帖子数量 + * @property {number} post_updated_at 帖子更新时间(秒级时间戳) + * @property {number} status 状态 // todo: 未知 + * @property {string} title 标题 + * @property {number} uid 用户 ID + * @property {number} view_num 浏览量 + * @return Info + */ + interface Info { + cover: string; + desc: string; + id: number; + is_delete: boolean; + is_following: boolean; + post_num: number; + post_updated_at: number; + status: number; + title: string; + uid: number; + view_num: number; + } + + /** + * @description 获取合集帖子返回 + * @since Beta v0.3.9 + * @interface ResponsePosts + * @extends TGApp.BBS.Response.BaseWithData + * @property {Data[]} data.list 合集帖子列表 + * @return ResponsePosts + */ + interface ResponsePosts extends TGApp.BBS.Response.BaseWithData { + data: { + posts: Data[]; + }; + } + + /** + * @description 合集帖子 + * @since Beta v0.3.9 + * @interface Data + * @see TGApp.Plugins.Mys.Post.FullData + * @return Data + */ + type Data = TGApp.Plugins.Mys.Post.FullData; +} diff --git a/src/plugins/Mys/types/Post.d.ts b/src/plugins/Mys/types/Post.d.ts index 111230ce..d7e23d0c 100644 --- a/src/plugins/Mys/types/Post.d.ts +++ b/src/plugins/Mys/types/Post.d.ts @@ -1,12 +1,12 @@ /** * @file plugins/Mys/types/post.d.ts * @description Mys 插件帖子类型定义文件 - * @since Beta v0.3.7 + * @since Beta v0.3.9 */ /** * @description Mys 插件帖子类型 - * @since Beta v0.3.4 + * @since Beta v0.3.9 * @namespace TGApp.Plugins.Mys.Post * @memberof TGApp.Plugins.Mys */ @@ -27,7 +27,7 @@ declare namespace TGApp.Plugins.Mys.Post { /** * @description 帖子数据 - * @since Alpha v0.2.1 + * @since Beta v0.3.9 * @interface FullData * @property {Post} post 帖子信息 * @property {Forum} forum 所属版块 @@ -44,7 +44,7 @@ declare namespace TGApp.Plugins.Mys.Post { * @property {number} vot_count 投票数 * @property {number} last_modify_time 最后修改时间 * @property {string} recommend_type 推荐类型 - * @property {unknown} collection 合集,可能为 null + * @property {Collection} collection 合集,可能为 null * @property {unknown[]} vod_list 视频列表,可能为空 * @property {boolean} is_block_on 是否被屏蔽 * @property {unknown} forum_rank_info 版块排行信息,可能为 null @@ -68,7 +68,7 @@ declare namespace TGApp.Plugins.Mys.Post { vot_count: number; last_modify_time: number; recommend_type: string; - collection: unknown | null; + collection: Collection | null; vod_list: Vod[]; is_block_on: boolean; forum_rank_info: unknown | null; @@ -304,6 +304,35 @@ declare namespace TGApp.Plugins.Mys.Post { answer_num: number; } + /** + * @description 合集信息 + * @since Beta v0.3.9 + * @interface Collection + * @property {string} prev_post_id 上一篇帖子 ID,为 0 说明没有上一篇 + * @property {string} next_post_id 下一篇帖子 ID,为 0 说明没有下一篇 + * @property {string} collection_id 合集 ID + * @property {number} cur 第几篇 + * @property {number} total 总篇数 + * @property {string} collection_title 合集标题 + * @property {number} prev_post_game_id 上一篇帖子游戏 ID + * @property {number} next_post_game_id 下一篇帖子游戏 ID + * @property {number} prev_post_view_type 上一篇帖子浏览类型 + * @property {number} next_post_view_type 下一篇帖子浏览类型 + * @return Collection + */ + interface Collection { + prev_post_id: string; + next_post_id: string; + collection_id: string; + cur: number; + total: number; + collection_title: string; + prev_post_game_id: number; + next_post_game_id: number; + prev_post_view_type: number; + next_post_view_type: number; + } + /** * @description 视频信息 * @since Beta v0.3.7 diff --git a/src/plugins/Mys/types/User.d.ts b/src/plugins/Mys/types/User.d.ts index 05624a27..d78682d5 100644 --- a/src/plugins/Mys/types/User.d.ts +++ b/src/plugins/Mys/types/User.d.ts @@ -1,12 +1,12 @@ /** * @file plugins/Mys/types/user.ts * @description Mys 插件用户类型定义文件 - * @since Beta v0.3.7 + * @since Beta v0.3.9 */ /** * @description Mys 插件用户类型 - * @since Beta v0.3.7 + * @since Beta v0.3.9 * @namespace TGApp.Plugins.Mys.User * @memberof TGApp.Plugins.Mys */ @@ -310,4 +310,33 @@ declare namespace TGApp.Plugins.Mys.User { nickname: string; avatar_url: string; } + + /** + * @description collection中的用户信息 + * @since Beta v0.3.9 + * @interface Collection + * @property {string} avatar 用户头像 + * @property {string} avatar_url 用户头像链接 + * @property {Certification} certification 用户认证信息 + * @property {number} gender 用户性别 + * @property {string} introduce 用户简介 + * @property {boolean} is_followed 是否被关注 + * @property {boolean} is_following 是否关注 + * @property {string} nickname 用户昵称 + * @property {string} pendant 用户挂件 URL,可能为 "" + * @property {number} uid 用户 ID + * @return Collection + */ + interface Collection { + avatar: string; + avatar_url: string; + certification: Certification; + gender: number; + introduce: string; + is_followed: boolean; + is_following: boolean; + nickname: string; + pendant: string; + uid: string; + } }