check page, keep scrollbar pos
This commit is contained in:
17
src/App.vue
17
src/App.vue
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user