大概完成渲染方式重构,点击标题切换

#64
This commit is contained in:
BTMuli
2023-12-03 00:34:59 +08:00
parent 885a8b22da
commit cab0c9a9c8
4 changed files with 168 additions and 5 deletions

View File

@@ -0,0 +1,43 @@
<template>
<component v-for="(tp, index) in props.data" :key="index" :is="getTpName(tp)" :data="tp" />
</template>
<script lang="ts" setup>
import TpBackupText from "./tp-backupText.vue";
import TpDivider from "./tp-divider.vue";
import TpImage from "./tp-image.vue";
import TpLinkCard from "./tp-linkCard.vue";
import TpMention from "./tp-mention.vue";
import TpText from "./tp-text.vue";
import TpUnknown from "./tp-unknown.vue";
import TpVillaCard from "./tp-villaCard.vue";
import TpVod from "./tp-vod.vue";
interface TpParserProps {
data: TGApp.Plugins.Mys.SctPost.Base[];
}
const props = defineProps<TpParserProps>();
function getTpName(tp: TGApp.Plugins.Mys.SctPost.Base) {
if (typeof tp.insert === "string") {
return TpText;
} else if ("image" in tp.insert) {
return TpImage;
} else if ("vod" in tp.insert) {
return TpVod;
// } else if ("video" in tp.insert) {
// return TpVideo;
} else if ("backup_text" in tp.insert) {
return TpBackupText;
} else if ("link_card" in tp.insert) {
return TpLinkCard;
} else if ("divider" in tp.insert) {
return TpDivider;
} else if ("mention" in tp.insert) {
return TpMention;
} else if ("villa_card" in tp.insert) {
return TpVillaCard;
}
return TpUnknown;
}
</script>

View File

@@ -0,0 +1,88 @@
<template>
<div class="mys-post-div">
<div class="mys-post-villa-card">
<img
class="mys-post-villa-card-bg"
alt="bg"
:src="props.data.insert.villa_card.villa_cover"
/>
<div class="mys-post-villa-card-bg-before"></div>
<div class="mys-post-villa-card-flex">
<div class="mys-post-villa-card-top">
<img
alt="topIcon"
class="mys-post-villa-card-icon"
:src="props.data.insert.villa_card.villa_avatar_url"
/>
<div class="mys-post-villa-card-content">
<div class="mys-post-villa-card-title">
{{ props.data.insert.villa_card.villa_name }}
</div>
<div class="mys-post-villa-card-desc">
<img
class="mys-post-villa-card-desc-icon"
alt="topDesc"
:src="props.data.insert.villa_card.owner_avatar_url"
/>
<span class="mys-post-villa-card-desc-text">
{{ props.data.insert.villa_card.owner_nickname }} 创建
</span>
</div>
</div>
</div>
<div class="mys-post-villa-card-mid">
<div class="mys-post-villa-card-tag">
{{ props.data.insert.villa_card.villa_member_num }}人在聊
</div>
<div v-if="props.data.insert.villa_card.tag_list">
<div
v-for="(tag, index) in props.data.insert.villa_card.tag_list"
:key="index"
class="mys-post-villa-card-tag"
>
{{ tag }}
</div>
</div>
</div>
<div class="mys-post-villa-card-bottom">
{{ props.data.insert.villa_card.villa_introduce }}
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
interface VillaRoom {
room_id: string;
room_name: string;
sender_avatar_list: string[];
sender_num: string;
}
interface TpVillaCard {
insert: {
villa_card: {
villa_id: string;
villa_name: string;
villa_avatar_url: string;
villa_cover: string;
owner_uid: string;
owner_nickname: string;
owner_avatar_url: string;
villa_introduce: string;
tag_list?: string[];
villa_member_num: string;
is_official: boolean;
is_available: boolean;
hot_member_avatar: string[];
hot_room: VillaRoom;
};
};
}
interface TpVillaCardProps {
data: TpVillaCard;
}
const props = defineProps<TpVillaCardProps>();
</script>