mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-29 22:39:45 +08:00
bugfix: os-mouse 在build后无法获取鼠标事件。改为 iohook
This commit is contained in:
@@ -65,42 +65,29 @@ export default function init(mainWindow) {
|
||||
ipcMain.on('optionPlugin', (e, args) => {
|
||||
optionPlugin = args;
|
||||
});
|
||||
const mouseTrack = mouseEvents();
|
||||
let down_time = 0;
|
||||
let isPress = false;
|
||||
mouseTrack.on('right-down', () => {
|
||||
isPress = true;
|
||||
down_time = Date.now();
|
||||
const config = global.opConfig.get();
|
||||
setTimeout(async () => {
|
||||
if (isPress) {
|
||||
const copyResult = await getSelectedText();
|
||||
let win = superPanel.getWindow();
|
||||
ipcMain.on('right-down', async (e) => {
|
||||
const copyResult = await getSelectedText();
|
||||
let win = superPanel.getWindow();
|
||||
|
||||
if (win) {
|
||||
win.webContents.send('trigger-super-panel', {
|
||||
...copyResult,
|
||||
optionPlugin: optionPlugin.plugins,
|
||||
});
|
||||
} else {
|
||||
superPanel.init(mainWindow);
|
||||
win = superPanel.getWindow();
|
||||
if (win) {
|
||||
win.webContents.send('trigger-super-panel', {
|
||||
...copyResult,
|
||||
optionPlugin: optionPlugin.plugins,
|
||||
});
|
||||
} else {
|
||||
superPanel.init(mainWindow);
|
||||
win = superPanel.getWindow();
|
||||
|
||||
win.once('ready-to-show', () => {
|
||||
win.webContents.send('trigger-super-panel', {
|
||||
...copyResult,
|
||||
optionPlugin: optionPlugin.plugins,
|
||||
});
|
||||
});
|
||||
}
|
||||
const pos = robot.getMousePos();
|
||||
win.setPosition(parseInt(pos.x), parseInt(pos.y));
|
||||
win.show();
|
||||
}
|
||||
}, config.superPanel.mouseDownTime);
|
||||
})
|
||||
mouseTrack.on('right-up', () => {
|
||||
isPress = false;
|
||||
win.once('ready-to-show', () => {
|
||||
win.webContents.send('trigger-super-panel', {
|
||||
...copyResult,
|
||||
optionPlugin: optionPlugin.plugins,
|
||||
});
|
||||
});
|
||||
}
|
||||
const pos = robot.getMousePos();
|
||||
win.setPosition(parseInt(pos.x), parseInt(pos.y));
|
||||
win.show();
|
||||
});
|
||||
|
||||
// 注册快捷键
|
||||
|
||||
@@ -26,7 +26,8 @@ let defaultConfig = {
|
||||
appid: '',
|
||||
},
|
||||
mouseDownTime: 500
|
||||
}
|
||||
},
|
||||
global: []
|
||||
}
|
||||
}
|
||||
global.opConfig = {
|
||||
@@ -37,6 +38,11 @@ global.opConfig = {
|
||||
if (!opConfig.config) {
|
||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]));
|
||||
}
|
||||
// 重置
|
||||
if (!opConfig.config.perf || !opConfig.config.superPanel || !opConfig.config.global) {
|
||||
opConfig.config = defaultConfig[platform];
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
|
||||
}
|
||||
return opConfig.config;
|
||||
} catch (e) {
|
||||
opConfig.config = defaultConfig[platform]
|
||||
|
||||
@@ -11,7 +11,8 @@ const {capture} = require("./browsers")();
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
|
||||
// to fix https://github.com/electron/electron/issues/18397
|
||||
app.allowRendererProcessReuse = false;
|
||||
let mainWindow
|
||||
const winURL = process.env.NODE_ENV === 'development'
|
||||
? `http://localhost:9080`
|
||||
|
||||
Reference in New Issue
Block a user