mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🐛 修复 mention 类型渲染异常
This commit is contained in:
@@ -11,7 +11,7 @@ import TGClient from "../../utils/TGClient";
|
||||
import showConfirm from "../func/confirm";
|
||||
import showSnackbar from "../func/snackbar";
|
||||
|
||||
interface TpMention {
|
||||
export interface TpMention {
|
||||
insert: {
|
||||
mention: {
|
||||
uid: string;
|
||||
|
||||
@@ -31,6 +31,11 @@ function getParsedData(data: TGApp.Plugins.Mys.SctPost.Base[]): TGApp.Plugins.My
|
||||
let cur: TGApp.Plugins.Mys.SctPost.Base | undefined;
|
||||
for (const tp of data) {
|
||||
const tpName = getTpName(tp);
|
||||
// 单独处理 TpMention
|
||||
if (tpName === TpMention) {
|
||||
child.push(tp);
|
||||
continue;
|
||||
}
|
||||
if (tpName !== TpText) {
|
||||
cur = tp;
|
||||
child = [];
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
<template>
|
||||
<div :style="getLineStyle()" class="tp-texts">
|
||||
<TpText v-for="(text, index) in props.data.children" :data="text" :key="index" />
|
||||
<component
|
||||
:is="getComp(text)"
|
||||
v-for="(text, index) in props.data.children"
|
||||
:data="text"
|
||||
:key="index"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { StyleValue } from "vue";
|
||||
|
||||
import TpMention, { type TpMention as TpMentionType } from "./tp-mention.vue";
|
||||
import TpText, { type TpText as TpTextType } from "./tp-text.vue";
|
||||
|
||||
interface TpTexts extends TpTextType {
|
||||
children: TpTextType[];
|
||||
children: (TpTextType | TpMentionType)[];
|
||||
}
|
||||
|
||||
interface TpTextsProps {
|
||||
@@ -18,6 +24,13 @@ interface TpTextsProps {
|
||||
|
||||
const props = defineProps<TpTextsProps>();
|
||||
|
||||
function getComp(text: TpTextType | TpMentionType): string {
|
||||
if (typeof text.insert === "string") {
|
||||
return TpText;
|
||||
}
|
||||
return TpMention;
|
||||
}
|
||||
|
||||
function getLineStyle(): StyleValue {
|
||||
const style = <Array<StyleValue>>[];
|
||||
if (props.data.attributes === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user