♻️ 公告解析重构完成

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

@@ -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;
}