🐛 修复特定情况下的渲染错误,调整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; let check = 0;
for (let i = 0; i < parsedText.length; i++) { for (let i = 0; i < parsedText.length; i++) {
const text = parsedText[i]; const text = parsedText[i];
child.push(parsedText[i]); child.push(text);
if (text.insert === "\n") { if (text.insert === "\n") {
if (child.length === 1) { check += child.length;
res.push(child[0]);
child = [];
continue;
}
cur = { cur = {
insert: "", insert: "",
attributes: text.attributes, attributes: text.attributes,
children: child, children: child,
}; };
res.push(cur); res.push(cur);
check += child.length;
child = []; 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); if (res.length === 0 && child.length > 0) res.push(...child);
return res; return res;

View File

@@ -1,5 +1,5 @@
<template> <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-box">
<div class="tpr-debug-title"> <div class="tpr-debug-title">
<span>文件</span> <span>文件</span>

View File

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

View File

@@ -51,6 +51,7 @@
location="end" location="end"
:close-on-content-click="false" :close-on-content-click="false"
v-model="showSub" v-model="showSub"
:persistent="true"
> >
<v-list class="tpr-reply-sub" width="300px" max-height="400px"> <v-list class="tpr-reply-sub" width="300px" max-height="400px">
<TprReply <TprReply
@@ -71,7 +72,7 @@
</div> </div>
</div> </div>
<div class="tpr-extra" :title="`ID:${props.modelValue.reply.reply_id}`"> <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> <v-icon size="small">mdi-file-export</v-icon>
</span> </span>
<span v-if="props.modelValue.r_user" class="tpr-reply-user"> <span v-if="props.modelValue.r_user" class="tpr-reply-user">
@@ -83,10 +84,11 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <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 { save } from "@tauri-apps/plugin-dialog";
import { writeTextFile } from "@tauri-apps/plugin-fs"; 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 Mys from "../../plugins/Mys/index.js";
import showConfirm from "../func/confirm.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 lastId = ref<string | undefined>(undefined);
const isLast = ref<boolean>(false); const isLast = ref<boolean>(false);
const loading = ref<boolean>(false); const loading = ref<boolean>(false);
let subListener: UnlistenFn | null = null;
console.log("TprReply", toRaw(props.modelValue)); 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 { function getTime(): string {
const time = new Date(props.modelValue.reply.created_at * 1000); const time = new Date(props.modelValue.reply.created_at * 1000);
const now = new Date(); const now = new Date();