diff --git a/README.md b/README.md index c916a2d..361aecb 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ 之所以做这个工具箱一方面是 utools 本身并未开源,但是公司内部的工具库又无法发布到 utools 插件中,所以为了既要享受 utools 生态又要有定制化需求,我们自己参考 utools 设计,做了 Rubick ## 安装包 -* [Rubick Mac OS V0.0.1](https://github.com/clouDr-f2e/rubick/releases/download/v0.0.1-beta/rubick2-0.0.1.pkg) +* [Rubick Mac OS V0.0.1](https://github.com/clouDr-f2e/rubick/releases/tag/v0.0.1-beta.2) ## 支持能力 diff --git a/src/main/common/common.js b/src/main/common/common.js index 702a209..c1e246f 100644 --- a/src/main/common/common.js +++ b/src/main/common/common.js @@ -155,32 +155,13 @@ export default function init(mainWindow) { // 拾色器 ipcMain.on('start-picker', () => { // 开启输入侦测 - ioHook.start(false) + ioHook.start(false); + ioHook.load(); picker.init(); picker.getWindow().on('close', () => { ioHook.stop(); - }); - - - ioHook.on('mousemove', e => { - let x = e.x - let y = e.y - if (!picker.getWindow()) return; - let color = "#" + robot.getPixelColor(parseInt(x), parseInt(y)); - picker.getWindow().setPosition(parseInt(x) - 50, parseInt(y) - 50); - picker.getWindow().webContents.send("updatePicker", color); - }) - - ioHook.on('mouseup', e => { - if (e.button === 1) { - let x = e.x - let y = e.y - const color = "#" + robot.getPixelColor(parseInt(x), parseInt(y)); - clipboard.writeText("#" + robot.getPixelColor(parseInt(x), parseInt(y))); - new Notification({ title: 'Rubick 通知', body: `${color} 已保存到剪切板` }).show(); - closePicker(); - } + ioHook.unload(); }); let pos = robot.getMousePos(); @@ -196,12 +177,33 @@ export default function init(mainWindow) { ); ipcMain.on("closePicker", closePicker); - ioHook.on('mouseup', e => { - if (e.button === 3) { - closePicker() - } - }); + }); + + ioHook.on('mousemove', e => { + let x = e.x + let y = e.y + if (!picker.getWindow()) return; + let color = "#" + robot.getPixelColor(parseInt(x), parseInt(y)); + picker.getWindow().setPosition(parseInt(x) - 50, parseInt(y) - 50); + picker.getWindow().webContents.send("updatePicker", color); }) + + ioHook.on('mouseup', e => { + if (e.button === 1) { + let x = e.x + let y = e.y + const color = "#" + robot.getPixelColor(parseInt(x), parseInt(y)); + clipboard.writeText("#" + robot.getPixelColor(parseInt(x), parseInt(y))); + new Notification({ title: 'Rubick 通知', body: `${color} 已保存到剪切板` }).show(); + closePicker(); + } + }); + + ioHook.on('mouseup', e => { + if (e.button === 3) { + closePicker() + } + }); }