fix: 删除某条历史记录时不再回到顶部

This commit is contained in:
ZiuChen
2022-09-24 17:14:28 +08:00
parent 73be7b47df
commit 7893bbea48
2 changed files with 5 additions and 15 deletions

View File

@@ -4,7 +4,7 @@
<template v-for="tab of tabs">
<div
:class="{ 'clip-switch-item': true, active: activeTab === tab.type }"
@click="onNavClick(tab.type)"
@click="toggleNav(tab.type)"
>
<component :is="tab.icon"></component>
{{ tab.name }}
@@ -27,12 +27,7 @@ const tabs = [
{ name: '收藏', type: 'collect', icon: Collection }
]
const activeTab = ref('all')
const emit = defineEmits(['onNavClick'])
const toggleNav = (type) => (activeTab.value = type)
const onNavClick = (type) => {
toggleNav(type)
emit('onNavClick', type)
}
defineExpose({
tabs,
activeTab,

View File

@@ -7,7 +7,7 @@
@onDataRemove="handleDataRemove"
@onOverlayClick="toggleFullData({ type: 'text', data: '' })"
></ClipFullData>
<ClipSwitch ref="ClipSwitchRef" @onNavClick="handleNavClick">
<ClipSwitch ref="ClipSwitchRef">
<template #SidePanel>
<div class="clip-switch-btn-list" v-show="!isSearchPanelExpand">
<span class="clip-switch-btn clip-select-count" v-show="isMultiple">
@@ -153,7 +153,7 @@ const textFilterCallBack = (item) => {
}
}
const updateShowList = (type) => {
const updateShowList = (type, toTop = true) => {
// 更新显示列表
showList.value = list.value
.filter((item) =>
@@ -162,7 +162,7 @@ const updateShowList = (type) => {
.filter((item) => (filterText.value ? item.type !== 'image' : item)) // 有过滤词 排除掉图片 DataURL
.filter((item) => textFilterCallBack(item))
.slice(0, GAP) // 重新切分懒加载列表
window.toTop()
toTop && window.toTop()
}
const restoreDataBase = () => {
@@ -179,11 +179,6 @@ const restoreDataBase = () => {
.catch(() => {})
}
const handleNavClick = (type) => {
updateShowList(type)
offset.value = 0 // 重置懒加载偏移量
}
const fullData = ref({ type: 'text', data: '' })
const fullDataShow = ref(false)
const toggleFullData = (item) => {
@@ -197,7 +192,7 @@ const ClipSwitchRef = ref()
const handleDataRemove = () => {
// 此函数须在挂载后执行
list.value = window.db.dataBase.data
updateShowList(ClipSwitchRef.value.activeTab)
updateShowList(ClipSwitchRef.value.activeTab, false)
}
const emit = defineEmits(['showSetting'])