diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 46dad49..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/rubick.iml b/.idea/rubick.iml deleted file mode 100644 index 0c8867d..0000000 --- a/.idea/rubick.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 30c742e..2e64f06 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -15,6 +15,7 @@ @choosePlugin="choosePlugin" @focus="searchFocus" @clearClipbord="clearClipboardFile" + @readClipboardContent="readClipboardContent" />
{{ currentPlugin.cmd }}
-
- +
+ {{ clipboardFile[0].name }}
{ @@ -101,9 +102,15 @@ const keydownEvent = (e, index) => { }; const checkNeedInit = (e) => { + const { ctrlKey, metaKey } = e; + if (e.target.value === "" && e.keyCode === 8) { closeTag(); } + // 手动粘贴 + if ((ctrlKey || metaKey) && e.key === "v") { + emit("readClipboardContent"); + } }; const targetSearch = ({ value }) => { @@ -166,6 +173,11 @@ const changeHideOnBlur = () => { config.value = cfg; }; +const getIcon = () => { + if (props.clipboardFile[0].dataUrl) return props.clipboardFile[0].dataUrl; + return props.clipboardFile[0].isFile ? require("../assets/file.png") : require("../assets/folder.png") +} + const newWindow = () => { // todo }; @@ -259,5 +271,18 @@ const newWindow = () => { margin-right: 6px; } } + .clipboard-img { + white-space: pre; + user-select: none; + font-size: 16px; + height: 32px; + position: relative; + align-items: center; + display: flex; + img { + width: 32px; + height: 32px; + } + } } diff --git a/src/renderer/plugins-manager/clipboardWatch.ts b/src/renderer/plugins-manager/clipboardWatch.ts index 77a7c15..588dc99 100644 --- a/src/renderer/plugins-manager/clipboardWatch.ts +++ b/src/renderer/plugins-manager/clipboardWatch.ts @@ -128,10 +128,63 @@ export default ({ clipboardFile.value = []; optionsRef.value = []; }; + // 触发 ctrl + v 主动粘贴时 + const readClipboardContent = () => { + // read image + const img = clipboard.readImage(); + const dataUrl = img.toDataURL(); + if (!dataUrl.replace("data:image/png;base64,", "")) return; + clipboardFile.value = [ + { + isFile: true, + isDirectory: false, + path: null, + dataUrl, + } + ]; + const localPlugins = remote.getGlobal("LOCAL_PLUGINS").getLocalPlugins(); + const options: any = []; + // 再正则插件 + localPlugins.forEach((plugin) => { + const feature = plugin.features; + // 系统插件无 features 的情况,不需要再搜索 + if (!feature) return; + feature.forEach((fe) => { + fe.cmds.forEach((cmd) => { + if (cmd.type === "img") { + options.push({ + name: cmd.label, + value: "plugin", + icon: plugin.logo, + desc: fe.explain, + type: plugin.pluginType, + click: () => { + pluginClickEvent({ + plugin, + fe, + cmd, + ext: { + code: fe.code, + type: cmd.type || "text", + payload: dataUrl, + }, + openPlugin, + }); + clearClipboardFile(); + }, + }); + } + }); + }); + + setOptionsRef(options); + }); + }; return { searchFocus, clipboardFile, clearClipboardFile, + readClipboardContent, }; }; diff --git a/src/renderer/plugins-manager/index.ts b/src/renderer/plugins-manager/index.ts index 7f7a265..363b5af 100644 --- a/src/renderer/plugins-manager/index.ts +++ b/src/renderer/plugins-manager/index.ts @@ -56,7 +56,7 @@ const createPluginManager = (): any => { const { searchValue, onSearch, setSearchValue, placeholder } = searchManager(); - const { options, searchFocus, clipboardFile, clearClipboardFile } = + const { options, searchFocus, clipboardFile, clearClipboardFile, readClipboardContent } = optionsManager({ searchValue, appList, @@ -124,6 +124,7 @@ const createPluginManager = (): any => { searchFocus, clipboardFile, clearClipboardFile, + readClipboardContent, }; }; diff --git a/src/renderer/plugins-manager/options.ts b/src/renderer/plugins-manager/options.ts index 42fd706..0c7a32f 100644 --- a/src/renderer/plugins-manager/options.ts +++ b/src/renderer/plugins-manager/options.ts @@ -116,7 +116,7 @@ const optionsManager = ({ optionsRef.value = options; }; - const { searchFocus, clipboardFile, clearClipboardFile } = useFocus({ + const { searchFocus, clipboardFile, clearClipboardFile, readClipboardContent } = useFocus({ currentPlugin, optionsRef, openPlugin, @@ -128,6 +128,7 @@ const optionsManager = ({ searchFocus, clipboardFile, clearClipboardFile, + readClipboardContent, }; };