帖子收藏 #100

This commit is contained in:
目棃
2024-03-19 21:51:57 +08:00
parent c5587211fd
commit 8996c1bce1
12 changed files with 602 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
/**
* @file web/request/TGRequest.ts
* @description 应用用到的请求函数
* @since Beta v0.4.3
* @since Beta v0.4.5
*/
import { genAuthkey, genAuthkey2 } from "./genAuthkey";
@@ -20,6 +20,7 @@ import { getStokenByGameToken, getTokenBySToken } from "./getStoken";
import getSyncAvatarDetail from "./getSyncAvatarDetail";
import getSyncAvatarListAll from "./getSyncAvatarListAll";
import { getTokensByLoginTicket } from "./getTokens";
import { getUserCollect } from "./getUserCollect";
import { getUserInfoByCookie } from "./getUserInfo";
import { verifyLToken } from "./verifyLToken";
@@ -43,6 +44,7 @@ const TGRequest = {
getAbyss,
getAccounts: getGameAccountsByCookie,
getUserInfo: getUserInfoByCookie,
getCollect: getUserCollect,
},
byLToken: {
verify: verifyLToken,

View File

@@ -0,0 +1,35 @@
/**
* @file web/request/getUserCollect.ts
* @description 获取用户收藏请求模块
* @since Beta v0.4.5
*/
import { http } from "@tauri-apps/api";
import TGUtils from "../utils/TGUtils";
/**
* @description 获取用户收藏帖子
* @since Beta v0.4.5
* @param {Record<string, string>} cookie - 用户 cookie
* @param {string} offset - 偏移量
* @returns {Promise<TGApp.BBS.Collection.PostRespData|TGApp.BBS.Response.Base>} 用户收藏帖子
*/
export async function getUserCollect(
cookie: Record<string, string>,
offset: string = "",
): Promise<TGApp.BBS.Collection.PostRespData | TGApp.BBS.Response.Base> {
const url = "https://bbs-api.miyoushe.com/post/wapi/userFavouritePost";
const params = { size: "20", offset };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http
.fetch<TGApp.BBS.Collection.PostResponse | TGApp.BBS.Response.Base>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
return res.data.data;
});
}