check page, keep scrollbar pos

This commit is contained in:
Julian Freeman
2025-12-07 20:47:23 -04:00
parent 7fcc4d343b
commit 05e714ef77

View File

@@ -42,10 +42,25 @@ const currentHistoryKey = ref("");
// Check Data // Check Data
const checkLogs = ref<string[]>([]); const checkLogs = ref<string[]>([]);
const logContainerRef = ref<HTMLElement | null>(null); const logContainerRef = ref<HTMLElement | null>(null);
const checkPageScrollTop = ref(0);
// Lifecycle // Lifecycle
let unlistenDrop: UnlistenFn | null = null; let unlistenDrop: UnlistenFn | null = null;
const handleLogScroll = (e: Event) => {
const target = e.target as HTMLElement;
checkPageScrollTop.value = target.scrollTop;
}
watch(activeMenu, async (newVal) => {
if (newVal === 'check') {
await nextTick();
if (logContainerRef.value) {
logContainerRef.value.scrollTop = checkPageScrollTop.value;
}
}
});
onMounted(async () => { onMounted(async () => {
// Theme init // Theme init
const savedTheme = localStorage.getItem('theme'); const savedTheme = localStorage.getItem('theme');
@@ -563,7 +578,7 @@ watch(currentDir, (newPath) => {
<div class="log-container"> <div class="log-container">
<div class="log-header">日志输出</div> <div class="log-header">日志输出</div>
<div class="log-content" ref="logContainerRef"> <div class="log-content" ref="logContainerRef" @scroll="handleLogScroll">
<div v-for="(log, index) in checkLogs" :key="index" class="log-item"> <div v-for="(log, index) in checkLogs" :key="index" class="log-item">
{{ log }} {{ log }}
</div> </div>