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

View File

@ -7,7 +7,7 @@
@onDataRemove="handleDataRemove" @onDataRemove="handleDataRemove"
@onOverlayClick="toggleFullData({ type: 'text', data: '' })" @onOverlayClick="toggleFullData({ type: 'text', data: '' })"
></ClipFullData> ></ClipFullData>
<ClipSwitch ref="ClipSwitchRef" @onNavClick="handleNavClick"> <ClipSwitch ref="ClipSwitchRef">
<template #SidePanel> <template #SidePanel>
<div class="clip-switch-btn-list" v-show="!isSearchPanelExpand"> <div class="clip-switch-btn-list" v-show="!isSearchPanelExpand">
<span class="clip-switch-btn clip-select-count" v-show="isMultiple"> <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 showList.value = list.value
.filter((item) => .filter((item) =>
@ -162,7 +162,7 @@ const updateShowList = (type) => {
.filter((item) => (filterText.value ? item.type !== 'image' : item)) // DataURL .filter((item) => (filterText.value ? item.type !== 'image' : item)) // DataURL
.filter((item) => textFilterCallBack(item)) .filter((item) => textFilterCallBack(item))
.slice(0, GAP) // .slice(0, GAP) //
window.toTop() toTop && window.toTop()
} }
const restoreDataBase = () => { const restoreDataBase = () => {
@ -179,11 +179,6 @@ const restoreDataBase = () => {
.catch(() => {}) .catch(() => {})
} }
const handleNavClick = (type) => {
updateShowList(type)
offset.value = 0 //
}
const fullData = ref({ type: 'text', data: '' }) const fullData = ref({ type: 'text', data: '' })
const fullDataShow = ref(false) const fullDataShow = ref(false)
const toggleFullData = (item) => { const toggleFullData = (item) => {
@ -197,7 +192,7 @@ const ClipSwitchRef = ref()
const handleDataRemove = () => { const handleDataRemove = () => {
// //
list.value = window.db.dataBase.data list.value = window.db.dataBase.data
updateShowList(ClipSwitchRef.value.activeTab) updateShowList(ClipSwitchRef.value.activeTab, false)
} }
const emit = defineEmits(['showSetting']) const emit = defineEmits(['showSetting'])