feat: 添加从设置中读取operate的逻辑

This commit is contained in:
ZiuChen 2022-09-18 12:14:36 +08:00
parent d65668d4bb
commit f97ee19319

View File

@ -1,4 +1,5 @@
import { ElMessage } from 'element-plus'
import setting from '../global/readSetting'
export default function useClipOperate({ emit }) {
return {
@ -37,13 +38,26 @@ export default function useClipOperate({ emit }) {
window.remove(item)
emit('onDataRemove')
} 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')
},
filterOperate: (operation, item, isFullData) => {
const { id } = operation
if (!isFullData) {
// 在非预览页 只展示配置在shown中的功能按钮 大小为 4
for (const sid of setting.operation.shown) {
if (id === sid) return true
}
return false
} else {
if (id === 'copy') {
return true
} else if (id === 'view') {
@ -59,8 +73,15 @@ export default function useClipOperate({ emit }) {
} 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
}
}
}
}
}