♻️ 公告解析重构完成

This commit is contained in:
目棃
2024-08-17 18:49:18 +08:00
parent 9e9ba53d99
commit 6bfa1b3cb4
9 changed files with 234 additions and 228 deletions

View File

@@ -14,6 +14,8 @@ import TpText from "../post/tp-text.vue";
import TpTexts from "../post/tp-texts.vue";
import TpUnknown from "../post/tp-unknown.vue";
import TaTable from "./ta-table.vue";
interface TaParserProps {
data: TGApp.BBS.Announcement.ContentItem;
}
@@ -25,6 +27,7 @@ function getTaName(ta: TGApp.Plugins.Mys.SctPost.Base) {
if (typeof ta.insert === "string") return TpText;
if ("image" in ta.insert) return TpImage;
if ("backup_text" in ta.insert) return TpBackupText;
if ("table" in ta.insert) return TaTable;
return TpUnknown;
}
</script>

View File

@@ -0,0 +1,16 @@
<template>
<div v-html="props.data.insert.table"></div>
</template>
<script lang="ts" setup>
interface TaTableType {
insert: {
table: string;
};
}
interface TaTableProps {
data: TaTableType;
}
const props = defineProps<TaTableProps>();
</script>

View File

@@ -47,7 +47,6 @@ const props = defineProps<TpTextProps>();
const mode = ref<string>("text");
const localEmojis = ref(localStorage.getItem("emojis"));
const emojis = ref<TpText[]>([]);
const router = useRouter();
console.log("tpText", JSON.stringify(props.data.insert), toRaw(props.data)?.attributes);
@@ -100,7 +99,7 @@ async function toLink() {
const link = props.data.attributes.link;
const isPost = await parsePost(link);
if (isPost !== false) {
await router.push({
await useRouter().push({
name: "帖子详情",
params: {
post_id: isPost,

View File

@@ -12,6 +12,7 @@
import { StyleValue } from "vue";
import type { Component } from "vue";
import TpImage from "./tp-image.vue";
import TpMention, { type TpMention as TpMentionType } from "./tp-mention.vue";
import TpText, { type TpText as TpTextType } from "./tp-text.vue";
@@ -29,6 +30,9 @@ function getComp(text: TpTextType | TpMentionType): Component {
if (typeof text.insert === "string") {
return TpText;
}
if ("image" in text.insert) {
return TpImage;
}
return TpMention;
}