🌱 添加帖子合集相关类型&请求

This commit is contained in:
BTMuli
2023-12-27 21:27:47 +08:00
parent f708b455fa
commit 6c6ff7fef0
5 changed files with 221 additions and 8 deletions

View File

@@ -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<TGApp.Plugins.Mys.Collection.ResponseData>} 合集信息
*/
export async function getCollectionData(
collectionId: number,
): Promise<TGApp.Plugins.Mys.Collection.ResponseData> {
const url = `https://bbs-api.miyoushe.com/collection/wapi/collection/detail?id=${collectionId}`;
console.log(url);
return await http
.fetch<TGApp.Plugins.Mys.Collection.Response>(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<TGApp.Plugins.Mys.Post.FullData[]>}
*/
export async function getCollectionPosts(
collectionId: number,
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
const url = `https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection?collection_id=${collectionId}`;
return await http
.fetch<TGApp.Plugins.Mys.Collection.ResponsePosts>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.Post.Referer,
},
})
.then((res) => {
return res.data.data.posts;
});
}