mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-08 06:16:18 +08:00
feat: 添加从设置中读取operate的逻辑
This commit is contained in:
parent
d65668d4bb
commit
f97ee19319
@ -1,4 +1,5 @@
|
|||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
import setting from '../global/readSetting'
|
||||||
|
|
||||||
export default function useClipOperate({ emit }) {
|
export default function useClipOperate({ emit }) {
|
||||||
return {
|
return {
|
||||||
@ -37,29 +38,49 @@ export default function useClipOperate({ emit }) {
|
|||||||
window.remove(item)
|
window.remove(item)
|
||||||
emit('onDataRemove')
|
emit('onDataRemove')
|
||||||
} else if (id.indexOf('custom') !== -1) {
|
} else if (id.indexOf('custom') !== -1) {
|
||||||
console.log('custom')
|
const a = operation.command.split(':')
|
||||||
|
if (a[0] === 'redirect') {
|
||||||
|
utools.redirect(a[1], {
|
||||||
|
type: typeMap[item.type],
|
||||||
|
data: item.data
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emit('onOperateExecute')
|
emit('onOperateExecute')
|
||||||
},
|
},
|
||||||
|
|
||||||
filterOperate: (operation, item, isFullData) => {
|
filterOperate: (operation, item, isFullData) => {
|
||||||
const { id } = operation
|
const { id } = operation
|
||||||
if (id === 'copy') {
|
if (!isFullData) {
|
||||||
return true
|
// 在非预览页 只展示配置在shown中的功能按钮 大小为 4
|
||||||
} else if (id === 'view') {
|
for (const sid of setting.operation.shown) {
|
||||||
return !isFullData
|
if (id === sid) return true
|
||||||
} else if (id === 'open-folder') {
|
}
|
||||||
return item.type === 'file'
|
return false
|
||||||
} else if (id === 'collect') {
|
} else {
|
||||||
return item.type !== 'file'
|
if (id === 'copy') {
|
||||||
} else if (id === 'word-break') {
|
return true
|
||||||
return item.type === 'text' && item.data.length <= 500 && item.data.length >= 2
|
} else if (id === 'view') {
|
||||||
} else if (id === 'save-file') {
|
return !isFullData
|
||||||
return item.type === 'file'
|
} else if (id === 'open-folder') {
|
||||||
} else if (id === 'remove') {
|
return item.type === 'file'
|
||||||
return true
|
} else if (id === 'collect') {
|
||||||
} else if (id.indexOf('custom') !== -1) {
|
return item.type !== 'file'
|
||||||
return true
|
} else if (id === 'word-break') {
|
||||||
|
return item.type === 'text' && item.data.length <= 500 && item.data.length >= 2
|
||||||
|
} else if (id === 'save-file') {
|
||||||
|
return item.type === 'file'
|
||||||
|
} else if (id === 'remove') {
|
||||||
|
return true
|
||||||
|
} else if (id.indexOf('custom') !== -1) {
|
||||||
|
// 如果匹配到了自定义的操作 则展示
|
||||||
|
for (const m of operation.match) {
|
||||||
|
if (item.type === m) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user