pref: optimize the timing of scrollbar reset

This commit is contained in:
hayden
2024-11-08 12:42:00 +08:00
parent 3a0676b29f
commit 3b25d3e347
2 changed files with 9 additions and 2 deletions

View File

@@ -40,6 +40,7 @@
</div>
<ResponseScroll
ref="responseScroll"
:items="list"
:itemSize="itemSize"
:row-key="(item) => item.map(genModelKey).join(',')"
@@ -80,7 +81,7 @@ import ModelCard from 'components/ModelCard.vue'
import ResponseInput from 'components/ResponseInput.vue'
import ResponseSelect from 'components/ResponseSelect.vue'
import ResponseScroll from 'components/ResponseScroll.vue'
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { chunk } from 'lodash'
import { defineResizeCallback } from 'hooks/resize'
@@ -91,6 +92,8 @@ const { isMobile, cardWidth, gutter, aspect, modelFolders } = useConfig()
const { data } = useModels()
const { t } = useI18n()
const responseScroll = ref()
const searchContent = ref<string>()
const currentType = ref('all')
@@ -120,6 +123,10 @@ const sortOrderOptions = ref(
}),
)
watch([searchContent, currentType], () => {
responseScroll.value.init()
})
const itemSize = computed(() => {
let itemWidth = cardWidth
let itemGutter = gutter

View File

@@ -298,7 +298,6 @@ const startDragThumb = (event: MouseEvent) => {
watch(
() => props.items,
() => {
init()
setSpacerSize()
calculateScrollThumbSize()
calculateLoadItems()
@@ -311,5 +310,6 @@ onUnmounted(() => {
defineExpose({
viewport,
init,
})
</script>