From 8f2b28210f1cd0465eb943d23e0346a1d3ca345f Mon Sep 17 00:00:00 2001
From: muwoo <2424880409@qq.com>
Date: Mon, 5 Jul 2021 20:23:06 +0800
Subject: [PATCH] =?UTF-8?q?bugfix:=20os-mouse=20=E5=9C=A8build=E5=90=8E?=
=?UTF-8?q?=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E9=BC=A0=E6=A0=87=E4=BA=8B?=
=?UTF-8?q?=E4=BB=B6=E3=80=82=E6=94=B9=E4=B8=BA=20iohook?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 18 ++-
src/main/common/common.js | 55 ++++----
src/main/common/config.js | 8 +-
src/main/index.js | 3 +-
src/renderer/main.js | 29 ++++-
.../pages/search/subpages/settings.vue | 119 ++++++++++++++++++
static/plugins/superPanel/index.html | 7 +-
static/plugins/superPanel/vue.min.js | 6 +
8 files changed, 203 insertions(+), 42 deletions(-)
create mode 100644 static/plugins/superPanel/vue.min.js
diff --git a/package.json b/package.json
index 2c47471..913d9ad 100644
--- a/package.json
+++ b/package.json
@@ -62,16 +62,18 @@
"download": "^8.0.0",
"download-git-repo": "^3.0.2",
"electron-store": "^8.0.0",
+ "iohook": "^0.9.3",
"is-chinese": "^1.4.2",
"keycode": "^2.2.0",
"marked": "^2.0.7",
"md5": "^2.3.0",
"mime-types": "^2.1.31",
"node-fetch": "^2.6.1",
- "osx-mouse": "git+https://github.com/Toinane/osx-mouse.git",
+ "osx-mouse": "^2.0.0",
"puppeteer-core": "^10.0.0",
"puppeteer-in-electron": "^3.0.3",
"query-string": "^7.0.0",
+ "request": "^2.88.2",
"request-promise": "^4.2.6",
"robotjs": "git+ssh://git@github.com/Toinane/robotjs.git",
"semver": "^7.3.5",
@@ -112,6 +114,7 @@
"listr": "^0.14.3",
"mini-css-extract-plugin": "0.4.0",
"multispinner": "^0.2.1",
+ "node-abi": "^2.30.0",
"node-loader": "^0.6.0",
"react": "^17.0.2",
"style-loader": "^0.21.0",
@@ -125,5 +128,18 @@
"webpack-dev-server": "^3.1.4",
"webpack-hot-middleware": "^2.22.2",
"webpack-merge": "^4.1.3"
+ },
+ "iohook": {
+ "targets": [
+ "node-83",
+ "electron-85"
+ ],
+ "platforms": [
+ "darwin"
+ ],
+ "arches": [
+ "x64",
+ "ia32"
+ ]
}
}
diff --git a/src/main/common/common.js b/src/main/common/common.js
index 9266ea2..0e7d332 100644
--- a/src/main/common/common.js
+++ b/src/main/common/common.js
@@ -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();
});
// 注册快捷键
diff --git a/src/main/common/config.js b/src/main/common/config.js
index 028ad1b..b574e47 100644
--- a/src/main/common/config.js
+++ b/src/main/common/config.js
@@ -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]
diff --git a/src/main/index.js b/src/main/index.js
index a25a265..8ed5722 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -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`
diff --git a/src/renderer/main.js b/src/renderer/main.js
index bb3136b..15c1555 100644
--- a/src/renderer/main.js
+++ b/src/renderer/main.js
@@ -1,6 +1,7 @@
import Vue from 'vue'
import axios from 'axios'
-
+import ioHook from 'iohook';
+import {ipcRenderer, remote} from 'electron';
import App from './App'
import router from './router'
import store from './store'
@@ -8,9 +9,11 @@ import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
+const opConfig = remote.getGlobal('opConfig');
+
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.http = Vue.prototype.$http = axios
-Vue.config.productionTip = false
+Vue.config.productionTip = false;
Vue.use(Antd);
@@ -20,4 +23,24 @@ new Vue({
router,
store,
template: '