feat: 收藏功能完整实现

This commit is contained in:
ZiuChen 2022-09-04 13:57:16 +08:00
parent fcca51cd07
commit 5e07f667b7
2 changed files with 12 additions and 2 deletions

View File

@ -49,7 +49,12 @@
</div>
<div class="clip-operate" v-show="activeIndex === index">
<template v-for="{ id, title } of operation">
<div :class="id" :title="title" @click.stop="handleOperateClick({ id, item })">
<div
v-if="id !== 'collect' || (id === 'collect' && item.collect !== true)"
:class="id"
:title="title"
@click.stop="handleOperateClick({ id, item })"
>
{{ title.slice(0, 1) }}
</div>
</template>
@ -101,6 +106,8 @@ const handleOperateClick = ({ id, item }) => {
window.copy(item)
break
case 'collect':
item.collect = true // important
window.db.updateDataBaseLocal(db)
break
case 'remove':
window.remove(item)

View File

@ -39,7 +39,9 @@ const showList = ref([]) // 展示的数据
const updateShowList = (type) => {
//
showList.value = list.value
.filter((item) => (type === 'all' ? item : item.type === type)) // all type
.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) =>
@ -48,6 +50,7 @@ const updateShowList = (type) => {
: item //
)
.slice(0, GAP) //
console.log(showList.value)
window.toTop()
}