mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-07 22:04:06 +08:00
fix: 修复了检索时展示了未过滤数据的问题
This commit is contained in:
parent
cfd6585828
commit
f748b56e3b
@ -37,14 +37,8 @@ const filterText = ref('') // 搜索框绑定值
|
||||
const list = ref([]) // 全部数据
|
||||
const showList = ref([]) // 展示的数据
|
||||
|
||||
const updateShowList = (type) => {
|
||||
// 更新显示列表
|
||||
showList.value = list.value
|
||||
.filter((item) =>
|
||||
type === 'collect' ? item.collect === true : type === 'all' ? item : item.type === type
|
||||
) // 是 collect则返回所有收藏 否则按照 type返回
|
||||
.filter((item) => (filterText.value ? item.type !== 'image' : item)) // 有过滤词 排除掉图片 DataURL
|
||||
.filter((item) => {
|
||||
const textFilterCallBack = (item) => {
|
||||
// filterText & item
|
||||
if (filterText.value.trim()) {
|
||||
if (filterText.value.trim().indexOf(' ') !== -1) {
|
||||
// 有过滤词 有空格
|
||||
@ -62,7 +56,16 @@ const updateShowList = (type) => {
|
||||
// 无过滤词 返回全部
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const updateShowList = (type) => {
|
||||
// 更新显示列表
|
||||
showList.value = list.value
|
||||
.filter((item) =>
|
||||
type === 'collect' ? item.collect === true : type === 'all' ? item : item.type === type
|
||||
) // 是 collect则返回所有收藏 否则按照 type返回
|
||||
.filter((item) => (filterText.value ? item.type !== 'image' : item)) // 有过滤词 排除掉图片 DataURL
|
||||
.filter((item) => textFilterCallBack(item))
|
||||
.slice(0, GAP) // 重新切分懒加载列表
|
||||
window.toTop()
|
||||
}
|
||||
@ -125,9 +128,11 @@ onMounted(() => {
|
||||
offset.value += GAP
|
||||
let addition = []
|
||||
if (activeTab.value !== 'all') {
|
||||
addition = list.value.filter((item) => item.type === activeTab.value)
|
||||
} else {
|
||||
addition = list.value
|
||||
.filter((item) => item.type === activeTab.value)
|
||||
.filter((item) => textFilterCallBack(item))
|
||||
} else {
|
||||
addition = list.value.filter((item) => textFilterCallBack(item))
|
||||
}
|
||||
addition = addition.slice(offset.value, offset.value + GAP)
|
||||
if (addition.length) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user