mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-01 06:39:45 +08:00
♻️ 公告解析重构完成
This commit is contained in:
@@ -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>
|
||||
|
||||
16
src/components/anno/ta-table.vue
Normal file
16
src/components/anno/ta-table.vue
Normal 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>
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user