🐛 修复特定情况下的渲染错误,调整z-index,子回复持久化

This commit is contained in:
目棃
2024-09-04 22:00:59 +08:00
parent c34b9d2416
commit 67f89dd998
4 changed files with 61 additions and 23 deletions

View File

@@ -58,24 +58,22 @@ function getParsedData(data: TGApp.Plugins.Mys.SctPost.Base[]): TGApp.Plugins.My
let check = 0;
for (let i = 0; i < parsedText.length; i++) {
const text = parsedText[i];
child.push(parsedText[i]);
child.push(text);
if (text.insert === "\n") {
if (child.length === 1) {
res.push(child[0]);
child = [];
continue;
}
check += child.length;
cur = {
insert: "",
attributes: text.attributes,
children: child,
};
res.push(cur);
check += child.length;
child = [];
}
}
if (check !== parsedText.length - 1 && child.length > 1) res.push(...child);
if (check !== parsedText.length && check !== 0) {
res.push(...child);
child = [];
}
}
if (res.length === 0 && child.length > 0) res.push(...child);
return res;

View File

@@ -1,5 +1,5 @@
<template>
<TOverlay v-model="visible" hide :to-click="onCancel" blur-val="5px">
<TOverlay v-model="visible" hide :to-click="onCancel" blur-val="0">
<div class="tpr-debug-box">
<div class="tpr-debug-title">
<span>文件</span>

View File

@@ -6,6 +6,7 @@
v-model="showOverlay"
:persistent="true"
:no-click-animation="true"
z-index="40"
>
<template #activator="{ props }">
<v-btn
@@ -21,13 +22,7 @@
<div class="tpr-main-reply">
<!-- 顶部负责显示回复条件&关闭按钮&刷新按钮 -->
<div class="tpr-main-filter">
<v-chip
color="primary"
label
@click="handleDebug"
:style="{ cursor: appStore.devMode ? 'pointer' : 'not-allowed' }"
>回复列表
</v-chip>
<v-chip color="primary" label @click="handleDebug">回复列表</v-chip>
<v-switch
v-model="onlyLz"
color="primary"
@@ -149,15 +144,24 @@ async function loadReply(): Promise<void> {
text: "没有更多了",
color: "info",
});
} else {
showSnackbar({
text: `成功加载${resp.list.length}条回复`,
color: "success",
});
}
}
function handleDebug(): void {
if (!appStore.devMode || showDebug.value) {
showDebug.value = false;
async function handleDebug(): Promise<void> {
if (appStore.devMode) {
showDebug.value = true;
return;
}
showDebug.value = true;
if (showDebug.value) {
showDebug.value = false;
}
// 刷新回复
await reloadReply();
}
</script>
<style lang="css" scoped>

View File

@@ -51,6 +51,7 @@
location="end"
:close-on-content-click="false"
v-model="showSub"
:persistent="true"
>
<v-list class="tpr-reply-sub" width="300px" max-height="400px">
<TprReply
@@ -71,7 +72,7 @@
</div>
</div>
<div class="tpr-extra" :title="`ID:${props.modelValue.reply.reply_id}`">
<span class="tpr-debug" @click="exportData">
<span class="tpr-debug" @click="exportData" title="导出数据">
<v-icon size="small">mdi-file-export</v-icon>
</span>
<span v-if="props.modelValue.r_user" class="tpr-reply-user">
@@ -83,10 +84,11 @@
</div>
</template>
<script lang="ts" setup>
import { path } from "@tauri-apps/api";
import { event, path } from "@tauri-apps/api";
import { UnlistenFn, Event } from "@tauri-apps/api/event";
import { save } from "@tauri-apps/plugin-dialog";
import { writeTextFile } from "@tauri-apps/plugin-fs";
import { toRaw, ref } from "vue";
import { toRaw, ref, watch, onMounted, onUnmounted } from "vue";
import Mys from "../../plugins/Mys/index.js";
import showConfirm from "../func/confirm.js";
@@ -104,9 +106,43 @@ const subReplies = ref<Array<TGApp.Plugins.Mys.Reply.ReplyFull>>([]);
const lastId = ref<string | undefined>(undefined);
const isLast = ref<boolean>(false);
const loading = ref<boolean>(false);
let subListener: UnlistenFn | null = null;
console.log("TprReply", toRaw(props.modelValue));
onMounted(async () => {
if (props.mode === "main") {
subListener = await listenSub();
}
});
onUnmounted(() => {
if (subListener !== null) {
subListener();
subListener = null;
}
});
watch(
() => showSub.value,
async (value) => {
if (value) {
await event.emit("openReplySub", props.modelValue.reply.reply_id);
console.error("emit openReplySub");
}
},
);
async function listenSub(): Promise<UnlistenFn> {
return await event.listen("openReplySub", async (e: Event<string>) => {
if (e.payload !== props.modelValue.reply.reply_id) {
if (showSub.value) {
showSub.value = false;
}
}
});
}
function getTime(): string {
const time = new Date(props.modelValue.reply.created_at * 1000);
const now = new Date();