mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-20 19:22:43 +08:00
bugfix: os-mouse 在build后无法获取鼠标事件。改为 iohook
This commit is contained in:
parent
9ab64bfa44
commit
8f2b28210f
18
package.json
18
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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -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`
|
||||
|
@ -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: '<App/>'
|
||||
}).$mount('#app')
|
||||
}).$mount('#app');
|
||||
|
||||
ioHook.start(false);
|
||||
|
||||
let down_time = 0;
|
||||
let isPress = false;
|
||||
ioHook.on('mousedown', (e) => {
|
||||
if (e.button === 1) return;
|
||||
isPress = true;
|
||||
down_time = Date.now();
|
||||
const config = opConfig.get();
|
||||
setTimeout(async () => {
|
||||
if (isPress) {
|
||||
ipcRenderer.send('right-down');
|
||||
}
|
||||
}, config.superPanel.mouseDownTime);
|
||||
})
|
||||
ioHook.on('mouseup', (e) => {
|
||||
if(e.button === 1) return;
|
||||
isPress = false;
|
||||
});
|
||||
|
@ -8,6 +8,9 @@
|
||||
<a-menu-item :key="1">
|
||||
超级面板
|
||||
</a-menu-item>
|
||||
<a-menu-item :key="2">
|
||||
全局快捷键
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
<div class="settings-detail">
|
||||
<div v-if="currentSelect[0] === 0">
|
||||
@ -65,6 +68,54 @@
|
||||
</div>
|
||||
<img width="100%" src="https://static.91jkys.com/upload/202107/02/fa4a5c614234409fb32ddda70cb900aa.jpg" />
|
||||
</div>
|
||||
<div v-if="currentSelect[0] === 2">
|
||||
<a-collapse>
|
||||
<a-collapse-panel key="1" header="说明及示例">
|
||||
<div>按下快捷键,自动搜索对应关键字,当关键字结果完全匹配,且结果唯一时,会直接指向该功能。</div>
|
||||
<h3 style="margin-top: 10px;">示例</h3>
|
||||
<a-divider style="margin: 5px 0;" />
|
||||
<a-list item-layout="horizontal" :data-source="examples">
|
||||
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||
<a-list-item-meta
|
||||
:description="item.desc"
|
||||
>
|
||||
<div slot="title">{{ item.title }}</div>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
</a-collapse-panel>
|
||||
</a-collapse>
|
||||
<div class="feature-container">
|
||||
<div class="keywords item">
|
||||
<div>快捷键</div>
|
||||
<a-tooltip placement="top" trigger="click">
|
||||
<template slot="title">
|
||||
<span>先按功能键(Ctrl、Shift、Alt、Option、Command),再按其他普通键。或按 F1-F12 单键</span>
|
||||
</template>
|
||||
<div
|
||||
v-for="(index, item) in config.global"
|
||||
class="value"
|
||||
tabIndex=-1
|
||||
@keydown="(e) => changeGlobalKey(e, index)"
|
||||
>
|
||||
{{ item.key }}
|
||||
</div>
|
||||
</a-tooltip>
|
||||
|
||||
</div>
|
||||
<div class="short-cut item">
|
||||
<div>功能关键字</div>
|
||||
<a-input
|
||||
:value="item.value"
|
||||
v-for="(index, item) in config.global"
|
||||
class="value"
|
||||
:disabled="!item.key"
|
||||
@change="(e) => changeGlobalValue(index, e.target.value)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div @click="addConfig" class="add-global"> + 新增全局快捷功能</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -82,6 +133,16 @@ export default {
|
||||
return {
|
||||
currentSelect: [0],
|
||||
config: JSON.parse(JSON.stringify(opConfig.get())),
|
||||
examples: [
|
||||
{
|
||||
title: '快捷键 「 Alt + W」 关键字 「 微信」',
|
||||
desc: '按下Alt + W 直接打开本地微信应用'
|
||||
},
|
||||
{
|
||||
title: '快捷键 「 Alt + Q」 关键字 「 取色」',
|
||||
desc: '按下Alt + Q 直接打开屏幕取色功能'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -107,6 +168,34 @@ export default {
|
||||
this.config.perf.shortCut[key] = compose;
|
||||
change = true;
|
||||
}
|
||||
},
|
||||
addConfig() {
|
||||
this.config.global.push({
|
||||
key: '',
|
||||
value: ''
|
||||
});
|
||||
},
|
||||
|
||||
changeGlobalKey(e, index) {
|
||||
let compose;
|
||||
if(e.altKey && e.keyCode !== 18){
|
||||
compose = `Option+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
}
|
||||
if(e.ctrlKey && e.keyCode !== 17){
|
||||
compose = `Ctrl+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
}
|
||||
if(e.shiftKey && e.keyCode !== 16){
|
||||
compose = `Shift+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
}
|
||||
if(e.metaKey && e.keyCode !== 93){
|
||||
compose = `Command+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
}
|
||||
if (compose) {
|
||||
this.$set(this.config.global[index], 'key', compose);
|
||||
}
|
||||
},
|
||||
changeGlobalValue(index, value) {
|
||||
this.$set(this.config.global[index], 'value', value);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -170,5 +259,35 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
.feature-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
font-size: 14px;
|
||||
.item {
|
||||
flex: 1;
|
||||
|
||||
}
|
||||
.short-cut {
|
||||
margin-left: 20px;
|
||||
}
|
||||
.value {
|
||||
text-align: center;
|
||||
border: 1px solid #ddd;
|
||||
color: #6C9FE2;
|
||||
font-size: 14px;
|
||||
height: 24px;
|
||||
font-weight: lighter;
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
.add-global {
|
||||
color: #6C9FE2;
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -4,12 +4,15 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<script crossorigin="anonymous" src="https://lib.baomitu.com/vue/2.6.12/vue.min.js"></script>
|
||||
<script src="./vue.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
[v-cloak]{
|
||||
display: none;
|
||||
}
|
||||
#app {
|
||||
-webkit-app-region: drag;
|
||||
width: 100%;
|
||||
@ -79,7 +82,7 @@
|
||||
</style>
|
||||
<script src="./index.js" type="module"></script>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div id="app" v-cloak>
|
||||
<div class="top" @click="openMainWindow">
|
||||
<span class="img"><img src="./assets/logo.png" /></span>
|
||||
<span class="text" v-if="selectData.text && selectData.text.length">选择的文本 {{selectData.text.length}} 个</span>
|
||||
|
6
static/plugins/superPanel/vue.min.js
vendored
Normal file
6
static/plugins/superPanel/vue.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user