mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-30 06:19:45 +08:00
🌱 获取合集信息
This commit is contained in:
@@ -52,9 +52,10 @@ import { nextTick, onMounted, shallowRef, useTemplateRef, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import { timestampToDate } from "@/utils/toolFunc.js";
|
||||
// import bbsReq from "@/web/request/bbsReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type TpoCollectionProps = { collection: TGApp.BBS.Post.Collection };
|
||||
type TpoCollectionProps = { collection: TGApp.BBS.Post.Collection; gid: number };
|
||||
type TpoCollectionItem = {
|
||||
postId: string;
|
||||
title: string;
|
||||
@@ -86,9 +87,11 @@ watch(
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
const collectionPosts = await postReq.collection(props.collection.collection_id);
|
||||
const resp = await postReq.collection(props.collection.collection_id);
|
||||
// const resp2 = await bbsReq.collection(props.collection.collection_id, props.gid);
|
||||
// console.log(resp2);
|
||||
const tempArr: Array<TpoCollectionItem> = [];
|
||||
for (const postItem of collectionPosts) {
|
||||
for (const postItem of resp) {
|
||||
const post: TpoCollectionItem = {
|
||||
postId: postItem.post.post_id,
|
||||
title: postItem.post.subject,
|
||||
|
||||
104
src/types/BBS/Collection.d.ts
vendored
104
src/types/BBS/Collection.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file types/BBS/Collection.d.ts
|
||||
* @description BBS 收藏相关类型定义文件
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.7.2
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Collection {
|
||||
@@ -15,6 +15,21 @@ declare namespace TGApp.BBS.Collection {
|
||||
*/
|
||||
type UserPostResp = TGApp.BBS.Response.BaseWithData<UserPostRes>;
|
||||
|
||||
/**
|
||||
* @description 用户收藏帖子响应数据
|
||||
* @since Beta v0.7.1
|
||||
* @interface UserPostRes
|
||||
* @property {boolean} is_last - 是否最后一页
|
||||
* @property {string} next_offset - 下一页偏移量
|
||||
* @property {Array<TGApp.BBS.Post.FullData>} list - 帖子列表
|
||||
* @return UserPostRes
|
||||
*/
|
||||
type UserPostRes = {
|
||||
is_last: boolean;
|
||||
next_offset: string;
|
||||
list: Array<TGApp.BBS.Post.FullData>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 合集帖子返回
|
||||
* @since Beta v0.7.1
|
||||
@@ -35,17 +50,82 @@ declare namespace TGApp.BBS.Collection {
|
||||
type PostsRes = { posts: Array<TGApp.BBS.Post.FullData> };
|
||||
|
||||
/**
|
||||
* @description 用户收藏帖子响应数据
|
||||
* @since Beta v0.7.1
|
||||
* @interface UserPostRes
|
||||
* @property {boolean} is_last - 是否最后一页
|
||||
* @property {string} next_offset - 下一页偏移量
|
||||
* @property {Array<TGApp.BBS.Post.FullData>} list - 帖子列表
|
||||
* @return UserPostRes
|
||||
* @description 合集信息返回
|
||||
* @since Beta v0.7.2
|
||||
* @interface InfoResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {InfoRes} data - 返回数据
|
||||
* @return InfoResp
|
||||
*/
|
||||
type UserPostRes = {
|
||||
is_last: boolean;
|
||||
next_offset: string;
|
||||
list: Array<TGApp.BBS.Post.FullData>;
|
||||
type InfoResp = TGApp.BBS.Response.BaseWithData<InfoRes>;
|
||||
|
||||
/**
|
||||
* @description 合集信息数据
|
||||
* @since Beta v0.7.2
|
||||
* @interface InfoRes
|
||||
* @property {Collection} collection_info - 合集信息
|
||||
* @property {User} author_info - 用户信息
|
||||
* @return InfoRes
|
||||
*/
|
||||
type InfoRes = { collection_info: Collection; author_info: User };
|
||||
|
||||
/**
|
||||
* @description 合集信息
|
||||
* @since Beta v0.7.2
|
||||
* @interface Collection
|
||||
* @property {number} id - 合集 ID
|
||||
* @property {string} title - 合集标题
|
||||
* @property {string} cover - 合集封面
|
||||
* @property {number} post_num - 帖子数量
|
||||
* @property {number} view_num - 浏览数量
|
||||
* @property {number} post_updated_at - 最后更新时间(秒级时间戳)
|
||||
* @property {string} desc - 合集描述
|
||||
* @property {boolean} is_delete - 是否删除
|
||||
* @property {boolean} is_following - 是否关注
|
||||
* @property {number} uid - 用户 ID
|
||||
* @property {number} status - 状态
|
||||
* @return Collection
|
||||
*/
|
||||
type Collection = {
|
||||
id: number;
|
||||
title: string;
|
||||
cover: string;
|
||||
post_num: number;
|
||||
view_num: number;
|
||||
post_updated_at: number;
|
||||
desc: string;
|
||||
is_delete: boolean;
|
||||
is_following: boolean;
|
||||
uid: number;
|
||||
status: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 用户信息
|
||||
* @since Beta v0.7.2
|
||||
* @interface User
|
||||
* @property {string} uid - 用户 ID
|
||||
* @property {string} nickname - 用户昵称
|
||||
* @property {string} introduce - 用户介绍
|
||||
* @property {string} avatar - 用户头像
|
||||
* @property {number} gender - 用户性别
|
||||
* @property {TGApp.BBS.User.Certification} certification - 用户认证信息
|
||||
* @property {boolean} is_following - 是否关注
|
||||
* @property {boolean} is_followed - 是否被关注
|
||||
* @property {string} avatar_url - 用户头像 URL
|
||||
* @property {string} pendant - 用户挂件
|
||||
* @return User
|
||||
*/
|
||||
type User = {
|
||||
uid: string;
|
||||
nickname: string;
|
||||
introduce: string;
|
||||
avatar: string;
|
||||
gender: number;
|
||||
certification: TGApp.BBS.User.Certification;
|
||||
is_following: boolean;
|
||||
is_followed: boolean;
|
||||
avatar_url: string;
|
||||
pendant: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,7 +93,8 @@
|
||||
<VpOverlayCollection
|
||||
v-model="showCollection"
|
||||
:collection="postData.collection"
|
||||
v-if="postData?.collection"
|
||||
:gid="postData.post.game_id"
|
||||
v-if="postData?.collection && postData"
|
||||
/>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
|
||||
@@ -66,7 +66,33 @@ async function getOtherUserInfo(
|
||||
return resp.data.user_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取合集信息
|
||||
* @since Beta v0.7.2
|
||||
* @todo invalid request
|
||||
* @param {number} gid - gid
|
||||
* @param {string} cid - 合集 id
|
||||
* @returns {Promise<TGApp.BBS.Collection.InfoRes|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getCollectionDetail(
|
||||
cid: string,
|
||||
gid: number,
|
||||
): Promise<TGApp.BBS.Collection.InfoRes | TGApp.BBS.Response.Base> {
|
||||
const params = { gids: gid, id: cid };
|
||||
const resp = await TGHttp<TGApp.BBS.Collection.InfoResp>(
|
||||
"https://bbs-api.miyoushe.com/collection/wapi/collection/detail",
|
||||
{
|
||||
method: "GET",
|
||||
headers: getRequestHeader({}, "GET", params, "X4", true),
|
||||
query: params,
|
||||
},
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
const BBSApi = {
|
||||
collection: getCollectionDetail,
|
||||
emojis: getEmoticonSet,
|
||||
userInfo: getUserFullInfo,
|
||||
otherUserInfo: getOtherUserInfo,
|
||||
|
||||
Reference in New Issue
Block a user