From f97ee19319af2c69fa6fca6457fcd3f0ce29329b Mon Sep 17 00:00:00 2001 From: ZiuChen <457353192@qq.com> Date: Sun, 18 Sep 2022 12:14:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BB=8E=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=AD=E8=AF=BB=E5=8F=96operate=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useClipOperate.js | 55 +++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/hooks/useClipOperate.js b/src/hooks/useClipOperate.js index 5b8db2e..a216f98 100644 --- a/src/hooks/useClipOperate.js +++ b/src/hooks/useClipOperate.js @@ -1,4 +1,5 @@ import { ElMessage } from 'element-plus' +import setting from '../global/readSetting' export default function useClipOperate({ emit }) { return { @@ -37,29 +38,49 @@ 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 (id === 'copy') { - return true - } else if (id === 'view') { - return !isFullData - } else if (id === 'open-folder') { - return item.type === 'file' - } else if (id === 'collect') { - return item.type !== 'file' - } 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) { - return true + 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') { + return !isFullData + } else if (id === 'open-folder') { + return item.type === 'file' + } else if (id === 'collect') { + return item.type !== 'file' + } 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 + } } } }