perf: adjust scroll parameters

This commit is contained in:
Lykin 2024-01-12 15:55:51 +08:00
parent ba8d19a121
commit 0a26ac6300
2 changed files with 8 additions and 5 deletions

View File

@ -107,7 +107,8 @@ const loadHistory = async () => {
data.history = list || []
} finally {
data.loading = false
tableRef.value?.scrollTo({ top: 999999 })
await nextTick()
tableRef.value?.scrollTo({ position: 'bottom' })
}
}
@ -118,7 +119,8 @@ const cleanHistory = async () => {
const success = await browserStore.cleanCmdHistory()
if (success) {
data.history = []
tableRef.value?.scrollTo({ top: 0 })
await nextTick()
tableRef.value?.scrollTo({ position: 'top' })
$message.success(i18n.t('dialogue.handle_succ'))
}
} finally {

View File

@ -1,5 +1,5 @@
<script setup>
import { computed, h, onMounted, onUnmounted, reactive, ref } from 'vue'
import { computed, h, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'
import Refresh from '@/components/icons/Refresh.vue'
import { debounce, isEmpty, map, size, split } from 'lodash'
import { useI18n } from 'vue-i18n'
@ -125,9 +125,10 @@ const _loadSlowLog = () => {
.then((list) => {
data.list = list || []
})
.finally(() => {
.finally(async () => {
data.loading = false
tableRef.value?.scrollTo({ top: data.sortOrder === 'ascend' ? 999999 : 0 })
await nextTick()
tableRef.value?.scrollTo({ position: data.sortOrder === 'ascend' ? 'bottom' : 'top' })
})
}
const loadSlowLog = debounce(_loadSlowLog, 1000, { leading: true, trailing: true })