🚸 完善类型,添加交互

This commit is contained in:
BTMuli
2025-10-25 12:51:44 +08:00
parent 2a2a190f5f
commit b6ed9668ac
3 changed files with 38 additions and 15 deletions

View File

@@ -1,7 +1,12 @@
<!-- UGC关卡组件 TODO:UI调整-->
<template>
<div class="tul-card-box" @click="console.log(props.data)">
<TMiImg class="tul-cover" :src="props.data.insert.level.cover.url" alt="cover" />
<TMiImg
@click="toLevel()"
class="tul-cover"
:src="props.data.insert.level.cover.url"
alt="cover"
/>
<div class="tul-content">
<div class="tul-top">
<div class="tul-title">{{ props.data.insert.level.level_name }}</div>
@@ -37,11 +42,20 @@
</template>
<script lang="ts" setup>
import TMiImg from "@comp/app/t-mi-img.vue";
import { openUrl } from "@tauri-apps/plugin-opener";
type TpUgcLevel = { insert: { level: TGApp.BBS.UGC.Level } };
type TpUgcLevelProps = { data: TpUgcLevel };
const props = defineProps<TpUgcLevelProps>();
async function toLevel(): Promise<void> {
let url = `https://act.miyoushe.com/ys/ugc_community/mx/#/pages/level-detail/index?`;
url = `${url}id=${props.data.insert.level.level_id}&region=${props.data.insert.level.region}`;
// TODO: 存在BUG
// await TGClient.open("web_act_thin", url.toString());
await openUrl(url);
}
</script>
<style lang="scss" scoped>
.tul-card-box {

View File

@@ -46,16 +46,17 @@ declare namespace TGApp.BBS.SctPost {
* @description 帖子结构化数据-viewType为7
* @since Beta v0.8.4
* @description 下面详细结构参见相关组件
* @todo 为简便起见所有字段可能为null,但是目前没遇到text&level为null的情况
* @property {Array<Base>} text - 文字内容
* @property {Array<UgcImage>} images - 图片内容
* @property {Array<UgcVod>} vods - 视频内容
* @property {Array<UgcLevel>} levels - 等级内容
*/
type Ugc = {
text: Array<Base>;
images: Array<UgcImage>;
vods: Array<UgcVod>;
levels: Array<UgcLevel>;
text: Array<Base> | null;
images: Array<UgcImage> | null;
vods: Array<UgcVod> | null;
levels: Array<UgcLevel> | null;
};
/**

View File

@@ -346,19 +346,27 @@ async function parsePostPic(
function parsePostUgc(post: TGApp.BBS.Post.Post): Array<TGApp.BBS.SctPost.Base> {
const data: TGApp.BBS.SctPost.Ugc = JSON.parse(post.structured_content);
const result: Array<TGApp.BBS.SctPost.Base> = [];
for (const text of data.text) {
result.push(text);
if (Array.isArray(data.text)) {
for (const text of data.text) {
result.push(text);
}
// 手动添加换行以对齐解析逻辑
if (data.text.length > 0) result.push({ insert: "\n" });
}
// 手动添加换行以对齐解析逻辑
if (data.text.length > 0) result.push({ insert: "\n" });
for (const image of data.images) {
result.push({ insert: { image: image.image } });
if (Array.isArray(data.images)) {
for (const image of data.images) {
result.push({ insert: { image: image.image } });
}
}
for (const vod of data.vods) {
result.push({ insert: { vod: vod.vod } });
if (Array.isArray(data.vods)) {
for (const vod of data.vods) {
result.push({ insert: { vod: vod.vod } });
}
}
for (const level of data.levels) {
result.push({ insert: { level: level.level } });
if (Array.isArray(data.levels)) {
for (const level of data.levels) {
result.push({ insert: { level: level.level } });
}
}
return result;
}