mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-07 22:04:06 +08:00
revert: 恢复支持了插件内置的收藏
功能
This commit is contained in:
parent
1b8e664aac
commit
e069f04b5b
@ -21,7 +21,8 @@ const tabs = ref([
|
||||
{ name: '📚 全部', type: 'all' },
|
||||
{ name: '📋 文字', type: 'text' },
|
||||
{ name: '⛺ 图片', type: 'image' },
|
||||
{ name: '📂 文件', type: 'file' }
|
||||
{ name: '📂 文件', type: 'file' },
|
||||
{ name: '⭐ 收藏', type: 'collect' }
|
||||
])
|
||||
const activeTab = ref('all')
|
||||
const emit = defineEmits(['onNavClick'])
|
||||
|
@ -3,6 +3,7 @@
|
||||
{ "id": "view", "title": "查看全部", "icon": "💬" },
|
||||
{ "id": "open-folder", "title": "打开文件夹", "icon": "📁" },
|
||||
{ "id": "collect", "title": "收藏", "icon": "⭐" },
|
||||
{ "id": "un-collect", "title": "移出收藏", "icon": "📤" },
|
||||
{ "id": "remove", "title": "删除", "icon": "❌" },
|
||||
{ "id": "word-break", "title": "分词", "icon": "💣" },
|
||||
{ "id": "save-file", "title": "保存", "icon": "💾" }
|
||||
|
@ -25,7 +25,9 @@ export default function initPlugin() {
|
||||
// 将超过14天的数据删除 排除掉收藏
|
||||
const now = new Date().getTime()
|
||||
const deleteTime = now - setting.database.maxage * 24 * 60 * 60 * 1000 // unicode
|
||||
this.dataBase.data = this.dataBase.data?.filter((item) => item.updateTime > deleteTime)
|
||||
this.dataBase.data = this.dataBase.data?.filter(
|
||||
(item) => item.updateTime > deleteTime || item.collect
|
||||
)
|
||||
this.updateDataBaseLocal()
|
||||
} catch (err) {
|
||||
utools.showNotification('读取剪切板出错: ' + err)
|
||||
@ -59,10 +61,14 @@ export default function initPlugin() {
|
||||
this.updateDataBase()
|
||||
const exceedCount = this.dataBase.data.length - setting.database.maxsize
|
||||
if (exceedCount > 0) {
|
||||
// 达到条数限制 删除超出部分
|
||||
// 达到条数限制 在收藏条数限制内遍历非收藏历史并删除
|
||||
// 所有被移除的 item都存入tempList
|
||||
const tmpList = []
|
||||
for (let i = 0; i < exceedCount; i++) {
|
||||
this.dataBase.data.pop()
|
||||
const item = this.dataBase.data.pop()
|
||||
tmpList.push(item)
|
||||
}
|
||||
tmpList.forEach((item) => !item.collect || this.dataBase.data.push(item)) // 收藏内容 重新入栈
|
||||
}
|
||||
this.updateDataBaseLocal()
|
||||
}
|
||||
|
@ -23,10 +23,11 @@ export default function useClipOperate({ emit }) {
|
||||
const fl = JSON.parse(data)
|
||||
utools.shellShowItemInFolder(fl[0].path) // 取第一个文件的路径打开
|
||||
} else if (id === 'collect') {
|
||||
utools.redirect('添加到「备忘快贴」', {
|
||||
type: typeMap[item.type],
|
||||
data: item.data
|
||||
})
|
||||
item.collect = true
|
||||
window.db.updateDataBaseLocal()
|
||||
} else if (id === 'un-collect') {
|
||||
item.collect = undefined
|
||||
window.db.updateDataBaseLocal()
|
||||
} else if (id === 'word-break') {
|
||||
utools.redirect('超级分词', item.data)
|
||||
} else if (id === 'save-file') {
|
||||
@ -51,12 +52,11 @@ export default function useClipOperate({ emit }) {
|
||||
filterOperate: (operation, item, isFullData) => {
|
||||
const { id } = operation
|
||||
if (!isFullData) {
|
||||
// 在非预览页 只展示配置在shown中的功能按钮 大小为 4
|
||||
for (const sid of setting.operation.shown) {
|
||||
if (id === sid) return true
|
||||
}
|
||||
// 在非预览页 只展示setting.operation.shown中的功能按钮
|
||||
if (!setting.operation.shown.includes(id)) {
|
||||
return false
|
||||
} else {
|
||||
}
|
||||
}
|
||||
if (id === 'copy') {
|
||||
return true
|
||||
} else if (id === 'view') {
|
||||
@ -64,7 +64,9 @@ export default function useClipOperate({ emit }) {
|
||||
} else if (id === 'open-folder') {
|
||||
return item.type === 'file'
|
||||
} else if (id === 'collect') {
|
||||
return item.type !== 'file'
|
||||
return item.type !== 'file' && !item.collect
|
||||
} else if (id === 'un-collect') {
|
||||
return item.type !== 'file' && item.collect
|
||||
} else if (id === 'word-break') {
|
||||
return item.type === 'text' && item.data.length <= 500 && item.data.length >= 2
|
||||
} else if (id === 'save-file') {
|
||||
@ -97,5 +99,4 @@ export default function useClipOperate({ emit }) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,9 @@ const textFilterCallBack = (item) => {
|
||||
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) => textFilterCallBack(item))
|
||||
.slice(0, GAP) // 重新切分懒加载列表
|
||||
|
Loading…
x
Reference in New Issue
Block a user