完善投稿活动类型声明,渲染投稿活动&交互

*PostID:69823686
This commit is contained in:
BTMuli
2025-10-24 19:26:33 +08:00
parent 8c51b79558
commit ee0fc6dbae
4 changed files with 131 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
/**
* @file types/BBS/Forum.d.ts
* @description BBS 版块类型定义
* @since Beta v0.7.1
* @since Beta v0.8.4
*/
declare namespace TGApp.BBS.Forum {
@@ -11,7 +11,6 @@ declare namespace TGApp.BBS.Forum {
* @interface GameForumResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {Array<GameForum>} data.list 所有版块信息
* @return GameForumResp
*/
type GameForumResp = TGApp.BBS.Response.BaseWithData & { data: { list: Array<GameForum> } };
@@ -21,7 +20,6 @@ declare namespace TGApp.BBS.Forum {
* @interface PostForumResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {PostForumRes} data 版块帖子列表
* @return PostForumResp
*/
type PostForumResp = TGApp.BBS.Response.BaseWithData<PostForumRes>;
@@ -31,7 +29,6 @@ declare namespace TGApp.BBS.Forum {
* @interface GameForum
* @property {number} game_id 游戏 ID
* @property {Array<GameForumItem>} forums 版块信息
* @return GameForum
*/
type GameForum = { game_id: number; forums: Array<GameForumItem> };
@@ -66,7 +63,6 @@ declare namespace TGApp.BBS.Forum {
* @property {string} read_me 说明
* @property {Array<ForumCate>} forum_cate_list 分类列表
* @property {Array<ForumCate>} video_cat_list 视频分类列表
* @return GameForumItem
*/
type GameForumItem = {
id: number;
@@ -100,16 +96,15 @@ declare namespace TGApp.BBS.Forum {
/**
* @description 视频分类
* @since Beta v0.6.8
* @since Beta v0.8.4
* @interface ForumCate
* @property {number} id 分类 ID
* @property {string} name 分类名称
* @property {number} forum_id 版块 ID
* @property {string} desc 描述
* @property {string} remark 备注
* @return ForumCate
* @property {string} [desc] 描述
* @property {string} [remark] 备注
*/
type ForumCate = { id: number; name: string; forum_id: number; desc: string; remark: string };
type ForumCate = { id: number; name: string; forum_id: number; desc?: string; remark?: string };
/**
* @description 版块帖子列表
@@ -121,7 +116,6 @@ declare namespace TGApp.BBS.Forum {
* @property {number} page 页码
* @property {unknown} databox 数据盒子
* @property {Array<TGApp.BBS.Post.FullData>} list 帖子列表
* @return PostForumRes
*/
type PostForumRes = {
last_id: string;

View File

@@ -1,7 +1,7 @@
/**
* @file types/BBS/Post.d.ts
* @description 帖子类型定义文件
* @since Beta v0.7.2
* @since Beta v0.8.4
*/
declare namespace TGApp.BBS.Post {
@@ -11,7 +11,6 @@ declare namespace TGApp.BBS.Post {
* @interface FullResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {FullRes} data 帖子数据
* @return FullResp
*/
type FullResp = TGApp.BBS.Response.BaseWithData<FullRes>;
@@ -20,7 +19,6 @@ declare namespace TGApp.BBS.Post {
* @since Beta v0.7.2
* @interface FullRes
* @property {FullData} post 帖子数据
* @return FullRes
*/
type FullRes = { post: FullData };
@@ -30,7 +28,6 @@ declare namespace TGApp.BBS.Post {
* @interface SearchResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {SearchRes} data 返回数据
* @return SearchResp
*/
type SearchResp = TGApp.BBS.Response.BaseWithData<SearchRes>;
@@ -43,7 +40,6 @@ declare namespace TGApp.BBS.Post {
* @property {boolean} is_last 是否最后一页
* @property {Array<string>} token_list token 列表
* @property {Record<string,string>} databox 数据盒
* @return SearchRes
*/
type SearchRes = {
posts: Array<FullData>;
@@ -59,7 +55,6 @@ declare namespace TGApp.BBS.Post {
* @interface NewsResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {NewsRes} data 返回数据
* @return NewsResp
*/
type NewsResp = TGApp.BBS.Response.BaseWithData<NewsRes>;
@@ -70,7 +65,6 @@ declare namespace TGApp.BBS.Post {
* @property {Array<FullData>} list 咨讯列表
* @property {string} last_id 最后 ID
* @property {boolean} is_last 是否最后一页
* @return NewsRes
*/
type NewsRes = { list: Array<FullData>; last_id: string; is_last: boolean };
@@ -80,7 +74,6 @@ declare namespace TGApp.BBS.Post {
* @interface UserPostResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {UserPostRes} data 返回数据
* @return UserPostResp
*/
type UserPostResp = TGApp.BBS.Response.BaseWithData<UserPostRes>;
@@ -91,7 +84,6 @@ declare namespace TGApp.BBS.Post {
* @property {Array<FullData>} list 帖子列表
* @property {boolean} is_last 是否最后一页
* @property {string} next_offset 下一页偏移量
* @return UserPostRes
*/
type UserPostRes = { list: Array<FullData>; is_last: boolean; next_offset: string };
@@ -101,7 +93,6 @@ declare namespace TGApp.BBS.Post {
* @interface FollowPostResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {FollowPostRes} data 返回数据
* @return FollowPostResp
*/
type FollowPostResp = TGApp.BBS.Response.BaseWithData<FollowPostRes>;
@@ -113,7 +104,6 @@ declare namespace TGApp.BBS.Post {
* @property {boolean} is_last 是否最后一页
* @property {Array<FullData>} list 帖子列表
* @property {number} next_offset 下一页偏移量
* @return FollowPostRes
*/
type FollowPostRes = {
has_follow_users: boolean;
@@ -155,12 +145,15 @@ declare namespace TGApp.BBS.Post {
* @property {unknown} challenge 挑战,可能为 null
* @property {Array<unknown>} hot_reply_list 热门回复列表
* @property {Array<unknown>} villa_msg_image_list 未知数据列表
* @property {unknown} contribution_act 未知数据,可能为 null
* @property {ContributionAct|null} contribution_act 投稿活动,可能为 null
* @property {boolean} is_has_vote 是否有投票
* @property {boolean} is_has_lottery 是否有抽奖
* @property {string} release_time_type 发布时间类型
* @property {number} future_release_time 未来发布时间
* @return FullData
* @property {ExternalLink} external_link 外部链接信息
* @property {unknown} post_full_extra_info 帖子完整额外信息,可能为 null
* @property {unknown} post_attachment_info 帖子附件信息,可能为 null
* @property {unknown} feed_attachment_info 动态附件信息,可能为 null
*/
type FullData = {
post: Post;
@@ -192,11 +185,15 @@ declare namespace TGApp.BBS.Post {
challenge: unknown | null;
hot_reply_list: Array<unknown>;
villa_msg_image_list: Array<unknown>;
contribution_act: unknown | null;
contribution_act: ContributionAct | null;
is_has_vote: boolean;
is_has_lottery: boolean;
release_time_type: string;
future_release_time: number;
external_link: ExternalLink;
post_full_extra_info: unknown | null;
post_attachment_info: unknown | null;
feed_attachment_info: unknown | null;
};
/**
@@ -217,7 +214,6 @@ declare namespace TGApp.BBS.Post {
* @property {Array<TGApp.BBS.User.Certification>} certifications 用户认证信息列表
* @property {boolean} is_creator 是否是创作者
* @property {TGApp.BBS.User.AvatarExt} avatar_ext 用户头像扩展信息
* @return User
*/
type User = {
uid: string;
@@ -277,7 +273,10 @@ declare namespace TGApp.BBS.Post {
* @property {number} block_latest_reply_time 是否屏蔽最新回复时间
* @property {number} selected_comment 是否选择评论
* @property {boolean} is_mentor 是否为导师
* @return Post
* @property {PostExtra|null} post_extra 帖子额外信息,可能为 null
* @property {string} ai_content_type AI 内容类型
* @property {string} user_ai_content_choice 用户 AI 内容选择
* @property {PostAigcMeta|null} aigc_meta AI 生成内容元数据,可能为 null
*/
type Post = {
game_id: number;
@@ -317,6 +316,10 @@ declare namespace TGApp.BBS.Post {
block_latest_reply_time: number;
selected_comment: number;
is_mentor: boolean;
post_extra: PostExtra | null;
ai_content_type: string;
user_ai_content_choice: string;
aigc_meta: PostAigcMeta | null;
};
/**
@@ -327,10 +330,35 @@ declare namespace TGApp.BBS.Post {
* @property {boolean} is_good 是否加精
* @property {boolean} is_official 是否官方
* @property {number} post_status 帖子状态
* @return PostStat
*/
type PostStat = { is_top: boolean; is_good: boolean; is_official: boolean; post_status: number };
/**
* @description 帖子额外信息
* @since Beta v0.8.4
* @interface PostExtra
* @property {PostExtraUgc} ugc_master_post_extra UGCMaster 额外信息
*/
type PostExtra = { ugc_master_post_extra: PostExtraUgc };
/**
* @description UGC所有者额外信息
* @since Beta v0.8.4
* @interface PostExtraUgc
* @property {string} game_uid 游戏 UID
* @property {string} game_region 游戏区服
*/
type PostExtraUgc = { game_uid: string; game_region: string };
/**
* @description AI 生成内容元数据
* @since Beta v0.8.4
* @interface PostAigcMeta
* @property {string} ContentPropagator 内容生成器
* @property {string} PropagateID 内容生成 ID
*/
type PostAigcMeta = { ContentPropagator: string; PropagateID: string };
/**
* @description 版块信息
* @since Beta v0.7.2
@@ -340,7 +368,6 @@ declare namespace TGApp.BBS.Post {
* @property {string} icon 版块图标 URL
* @property {number} game_id 游戏 ID // 2 为原神
* @property {TGApp.BBS.Forum.ForumCate|null} forum_cate 版块分类,可能为 null
* @return Forum
*/
type Forum = {
id: number;
@@ -362,7 +389,6 @@ declare namespace TGApp.BBS.Post {
* @property {boolean} is_interactive 是否互动
* @property {number} game_id 游戏 ID
* @property {number} content_type 内容类型
* @return Topic
*/
type Topic = {
id: number;
@@ -386,7 +412,6 @@ declare namespace TGApp.BBS.Post {
* @property {number} forward_num 转发数
* @property {number} original_like_num 原创点赞数
* @property {Array<StatUpvote>} post_upvote_stat 互动信息
* @return Stat
*/
type Stat = {
view_num: number;
@@ -404,7 +429,6 @@ declare namespace TGApp.BBS.Post {
* @interface StatUpvote
* @property {number} upvote_type 互动类型
* @property {number} upvote_cnt 互动数量
* @return StatUpvote
*/
type StatUpvote = { upvote_type: number; upvote_cnt: number };
@@ -423,7 +447,8 @@ declare namespace TGApp.BBS.Post {
* @property {string} entity_type 图片类型 // IMG_ENTITY_POST, IMG_ENTITY_UNKOWN
* @property {string} entity_id 图片 ID
* @property {boolean} is_deleted 是否已删除
* @return Image
* @property {string} aigc_label AI 生成标签
* @property {string} aigc_meta AI 生成元数据 // 序列化后的 JSON 字符串
*/
type Image = {
url: string;
@@ -437,6 +462,8 @@ declare namespace TGApp.BBS.Post {
entity_type: string;
entity_id: string;
is_deleted: boolean;
aigc_label: string;
aigc_meta: string;
};
/**
@@ -448,7 +475,6 @@ declare namespace TGApp.BBS.Post {
* @property {number} w 裁剪宽度
* @property {number} h 裁剪高度
* @property {string} url 裁剪图片 URL
* @return ImageCrop
*/
type ImageCrop = { x: number; y: number; w: number; h: number; url: string };
@@ -459,7 +485,6 @@ declare namespace TGApp.BBS.Post {
* @property {unknown} top_up 置顶, 可能为 null
* @property {Array<unknown>} top_n 置顶, 可能为空
* @property {number} answer_num 回答数
* @return HelpSys
*/
type HelpSys = { top_up: unknown | null; top_n: Array<unknown>; answer_num: number };
@@ -477,7 +502,6 @@ declare namespace TGApp.BBS.Post {
* @property {number} next_post_game_id 下一篇帖子游戏 ID
* @property {number} prev_post_view_type 上一篇帖子浏览类型
* @property {number} next_post_view_type 下一篇帖子浏览类型
* @return Collection
*/
type Collection = {
prev_post_id: string;
@@ -511,7 +535,6 @@ declare namespace TGApp.BBS.Post {
* @property {string} origin_user_nickname 原始用户名
* @property {string} price 价格
* @property {string} title 标题
* @returns LinkCard
*/
type LinkCard = {
link_type: number;
@@ -543,7 +566,6 @@ declare namespace TGApp.BBS.Post {
* @property {number} transcoding_status 转码状态
* @property {number} review_status 审核状态
* @property {string} brief_info 视频简介
* @return Vod
*/
type Vod = {
id: string;
@@ -568,7 +590,6 @@ declare namespace TGApp.BBS.Post {
* @property {string} size 视频大小
* @property {string} format 视频格式
* @property {string} label 视频标签
* @return VodResolution
*/
type VodResolution = {
url: string;
@@ -588,7 +609,6 @@ declare namespace TGApp.BBS.Post {
* @property {number} activity_status 活动状态 // ActivityStatus
* @property {string} start_at_sec 活动开始时间戳,单位秒
* @property {string} end_at_sec 活动结束时间戳,单位秒
* @return NewsMeta
*/
type NewsMeta = { activity_status: number; start_at_sec: string; end_at_sec: string };
@@ -600,7 +620,6 @@ declare namespace TGApp.BBS.Post {
* @property {unknown|null} lottery 抽奖信息,可能为 null
* @property {Array<RecommendTags>} tags 标签
* @property {boolean} is_mentor_rec_block 是否为导师推荐
* @return RecommendReason
*/
type RecommendReason = {
is_following?: boolean;
@@ -616,7 +635,33 @@ declare namespace TGApp.BBS.Post {
* @property {string} text 标签文本
* @property {string} type 标签类型
* @property {string} deep_link 深度链接
* @return RecommendTags
*/
type RecommendTags = { text: string; type: string; deep_link: string };
/**
* @description 投稿活动
* @since Beta v0.8.4
* @interface ContributionAct
* @property {string} act_id 活动 ID
* @property {string} title 活动标题
* @property {string} game_uid 投稿游戏 UID
* @property {string} game_region 投稿游戏区服
* @property {string} game_nickname 投稿游戏昵称
*/
type ContributionAct = {
act_id: string;
title: string;
game_uid: string;
game_region: string;
game_nickname: string;
};
/**
* @description 外部链接信息
* @since Beta v0.8.4
* @interface ExternalLink
* @property {string} external_link 外部链接 URL
* @property {string} external_link_title 外部链接标题
*/
type ExternalLink = { external_link: string; external_link_title: string };
}

View File

@@ -1,3 +1,4 @@
<!-- 公告详情页面,TODO:联动消除红点 -->
<template>
<TSwitchTheme />
<TPinWin />

View File

@@ -33,6 +33,7 @@
<v-icon size="16">mdi-comment</v-icon>
<span>{{ postData?.stat?.reply_num }}</span>
</div>
<!-- TODO: 展示不同种类点赞图标&数量 -->
<div
class="mpm-item"
:title="`点赞数:${postData?.stat?.like_num}`"
@@ -62,6 +63,15 @@
</div>
<!-- 一些附加信息比如 topiccollection -->
<div class="tp-post-extra">
<div
class="tp-post-contribution"
v-if="postData.contribution_act"
:title="`投稿活动:${postData.contribution_act.title}`"
@click="toAct()"
>
<v-icon size="10">mdi-party-popper</v-icon>
<span>{{ postData.contribution_act.title }}</span>
</div>
<div
class="tp-post-collection"
:title="`合集ID${postData.collection.collection_id}`"
@@ -130,6 +140,8 @@ import useBBSStore from "@store/bbs.js";
import useUserStore from "@store/user.js";
import { app, webviewWindow } from "@tauri-apps/api";
import { emit, type Event, listen, type UnlistenFn } from "@tauri-apps/api/event";
import { openUrl } from "@tauri-apps/plugin-opener";
import { parseLink, parsePost } from "@utils/linkParser.js";
import TGClient from "@utils/TGClient.js";
import TGLogger from "@utils/TGLogger.js";
import { createTGWindow } from "@utils/TGWindow.js";
@@ -365,6 +377,23 @@ async function toForum(forum: TGApp.BBS.Post.Forum): Promise<void> {
await emit("active_deep_link", `router?path=/posts/forum/${forum.game_id}/${forum.id}`);
}
async function toAct(): Promise<void> {
if (!postData.value || !postData.value.external_link) return;
const link = postData.value.external_link.external_link;
const isPost = await parsePost(link);
if (isPost !== false) {
location.href = `/post_detail/${isPost}`;
return;
}
const res = await parseLink(link);
if (res === true) return;
if (res === false) {
showSnackbar.error(`未知链接:${link}`, 3000);
return;
}
await openUrl(res);
}
function handleUser(user: TGApp.BBS.Post.User): void {
curUid.value = user.uid;
if (showCollection.value) showCollection.value = false;
@@ -517,6 +546,26 @@ function handleUser(user: TGApp.BBS.Post.User): void {
gap: 8px 4px;
}
.tp-post-contribution {
@include github-styles.github-tag-dark-gen(#e06c75);
display: flex;
height: 20px;
box-sizing: border-box;
align-items: center;
justify-content: center;
padding: 0 6px;
border-radius: 4px;
column-gap: 2px;
cursor: pointer;
font-family: var(--font-title);
font-size: 12px;
&:hover {
@include github-styles.github-tag-dark-gen(#c678dd);
}
}
.tp-post-collection {
@include github-styles.github-tag-dark-gen(#3572a5);