mirror of
https://github.com/rubickCenter/rubick
synced 2025-08-09 05:09:34 +08:00
bugfix: 修复 iohook 卡顿问题
This commit is contained in:
parent
f9b0177c00
commit
eca119a8a9
@ -155,32 +155,13 @@ export default function init(mainWindow) {
|
|||||||
// 拾色器
|
// 拾色器
|
||||||
ipcMain.on('start-picker', () => {
|
ipcMain.on('start-picker', () => {
|
||||||
// 开启输入侦测
|
// 开启输入侦测
|
||||||
ioHook.start(false)
|
ioHook.start(false);
|
||||||
|
ioHook.load();
|
||||||
picker.init();
|
picker.init();
|
||||||
|
|
||||||
picker.getWindow().on('close', () => {
|
picker.getWindow().on('close', () => {
|
||||||
ioHook.stop();
|
ioHook.stop();
|
||||||
});
|
ioHook.unload();
|
||||||
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let pos = robot.getMousePos();
|
let pos = robot.getMousePos();
|
||||||
@ -196,12 +177,33 @@ export default function init(mainWindow) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
ipcMain.on("closePicker", closePicker);
|
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()
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user