mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-07 08:42:49 +08:00
🌱 获取用户关注动态
This commit is contained in:
@@ -19,8 +19,25 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
import { useUserStore } from "@/store/modules/user.js";
|
||||
import painterReq from "@/web/request/painterReq.js";
|
||||
|
||||
const { cookie } = storeToRefs(useUserStore());
|
||||
const offset = ref<number>();
|
||||
|
||||
async function test(): Promise<void> {
|
||||
console.log("test");
|
||||
if (!cookie.value) return;
|
||||
const resp = await painterReq.follow(cookie.value, offset.value);
|
||||
console.log(resp);
|
||||
if ("retcode" in resp) {
|
||||
showSnackbar.warn(`[${resp.retcode}] ${resp.message}`);
|
||||
return;
|
||||
}
|
||||
offset.value = resp.next_offset;
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
27
src/types/BBS/Post.d.ts
vendored
27
src/types/BBS/Post.d.ts
vendored
@@ -95,6 +95,33 @@ declare namespace TGApp.BBS.Post {
|
||||
*/
|
||||
type UserPostRes = { list: Array<FullData>; is_last: boolean; next_offset: string };
|
||||
|
||||
/**
|
||||
* @description 关注动态返回
|
||||
* @since Beta v0.7.2
|
||||
* @interface FollowPostResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {FollowPostRes} data 返回数据
|
||||
* @return FollowPostResp
|
||||
*/
|
||||
type FollowPostResp = TGApp.BBS.Response.BaseWithData<FollowPostRes>;
|
||||
|
||||
/**
|
||||
* @description 关注动态返回数据
|
||||
* @since Beta v0.7.2
|
||||
* @interface FollowPostRes
|
||||
* @property {boolean} has_follow_users 是否有关注用户
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {Array<FullData>} list 帖子列表
|
||||
* @property {number} next_offset 下一页偏移量
|
||||
* @return FollowPostRes
|
||||
*/
|
||||
type FollowPostRes = {
|
||||
has_follow_users: boolean;
|
||||
is_last: boolean;
|
||||
list: Array<FullData>;
|
||||
next_offset: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 帖子数据
|
||||
* @since Beta v0.7.2
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* @file web/request/painterReq.ts
|
||||
* @description painter 下的请求
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.7.2
|
||||
*/
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
import { getRequestHeader } from "@/web/utils/getRequestHeader.js";
|
||||
|
||||
// BBSApiPainterBaseUrl => bapBu
|
||||
const bapBu: Readonly<string> = "https://bbs-api.miyoushe.com/painter/wapi/";
|
||||
@@ -110,6 +111,33 @@ async function getRecentForumPostList(
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取关注动态帖子
|
||||
* @since Beta v0.7.2
|
||||
* @param {TGApp.App.Account.Cookie} cookie 用户 Cookie
|
||||
* @param {number} offset
|
||||
* @return {Promise<TGApp.BBS.Response.Base|TGApp.BBS.Post.FollowPostRes>}
|
||||
*/
|
||||
async function getTimelineList(
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
offset?: number,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.Post.FollowPostRes> {
|
||||
let param: Record<string, number> = { gids: 2, size: 20 };
|
||||
if (offset) param = { ...param, offset };
|
||||
const ck = { ltoken: cookie.ltoken, ltuid: cookie.ltuid };
|
||||
const header = getRequestHeader(ck, "GET", param, "X4", true);
|
||||
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.BBS.Post.FollowPostResp>(
|
||||
`${bapBu}timeline/list`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: param,
|
||||
},
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取抽奖信息
|
||||
* @since Beta v0.7.1
|
||||
@@ -136,6 +164,7 @@ const painterReq = {
|
||||
hot: getHotForumPostList,
|
||||
recent: getRecentForumPostList,
|
||||
},
|
||||
follow: getTimelineList,
|
||||
lottery: lotteryUserShow,
|
||||
news: getNewsList,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user