Compare commits

..

21 Commits

Author SHA1 Message Date
muwoo
0991d0ad64 feat: 支持linux 2021-08-26 17:43:56 +08:00
muwoo
e71eed00ad feat: workflow 2021-08-26 17:33:44 +08:00
muwoo
be5bce68dc feat: workflow 2021-08-26 17:20:22 +08:00
muwoo
871beba4bf workflow 2021-08-26 17:19:54 +08:00
muwoo
f0b757c01f feat: linux workflow 2021-08-26 17:05:04 +08:00
muwoo
f480508200 feat: linux workflow 2021-08-26 16:36:25 +08:00
muwoo
247c2b7ab9 feat: linux workflow 2021-08-26 16:18:44 +08:00
木偶
a489a8f130 Merge pull request #34 from SOVLOOKUP/cross-platform
Cross platform Linux 跨平台适配
2021-08-26 16:06:10 +08:00
sovlookup
d38dcab9cc feat: linux version 2021-08-26 12:57:04 +08:00
sovlookup
64541ad651 chore: run at latest version 2021-08-26 12:23:29 +08:00
sovlookup
5b1cef93c8 merge 2021-08-26 11:06:50 +08:00
sovlookup
8dd59720e0 merge 2021-08-26 11:03:52 +08:00
木偶
ee2a23a421 Merge pull request #28 from clouDr-f2e/dev
Dev
2021-08-23 11:16:34 +08:00
muwoo
7dd5407bbe bugfix: 修复超级面板浅拷贝问题 2021-08-23 11:13:25 +08:00
muwoo
b58c37842a feat: 触摸板支持系统监控 2021-08-19 15:53:05 +08:00
muwoo
2d2743cbb1 ref: 优化取色功能 2021-08-19 14:03:50 +08:00
muwoo
efccc2b091 Merge remote-tracking branch 'github/master' 2021-08-18 20:37:28 +08:00
muwoo
c6c57b1e01 bugfix: 修复帮助功能 2021-08-18 20:37:15 +08:00
木偶
a8c1db6ed3 Update README.md 2021-08-18 20:00:59 +08:00
muwoo
4e55f14a69 style: touchbar 颜色调整 2021-08-18 19:48:23 +08:00
sovlookup
bf6e95e370 feat: electron12 2021-08-04 00:52:14 +08:00
22 changed files with 12138 additions and 96 deletions

View File

@@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-2019]
os: [ubuntu-latest, macos-latest, windows-2019]
# create steps
steps:
@@ -40,6 +40,7 @@ jobs:
- name: Install system deps
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install libxtst-dev libpng++-dev
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
# step3: yarn
- name: macos Yarn install
@@ -56,6 +57,13 @@ jobs:
yarn global add xvfb-maybe
npm run rebuild_win
- name: linux Yarn install
if: ${{runner.os == 'Linux'}}
run: |
yarn
yarn global add xvfb-maybe
npm run rebuild_linux
- name: Build & release app
run: |
npm run release

5
.pnpm-debug.log Normal file
View File

@@ -0,0 +1,5 @@
{
"0 debug pnpm:scope": {
"selected": 1
}
}

View File

@@ -26,6 +26,7 @@
## 安装包
* [Rubick Mac OS](https://github.com/clouDr-f2e/rubick/releases)
* [Rubick Windows](https://github.com/clouDr-f2e/rubick/releases)
* [Rubick Linux](https://github.com/clouDr-f2e/rubick/releases)
## 支持能力
- [x] 支持远程下载安装插件,支持插件开发者模式
@@ -36,7 +37,7 @@
- [x] 支持搜索本地已安装 app 或 偏好设置
- [x] macos touchBar 唤起插件
- [x] 支持 Windows(目前是 mac 的 alpha 版本,功能尚不全,正在迁移中)
- [ ] 支持 Linux
- [x] 支持 Linux
@@ -50,13 +51,14 @@
## 使用问题
1. 依赖于 `robotjs` dev 环境运行请在 `install` 后执行 `npm run rebuild`
2. windows 版本目前有了一个最基础的可用版,代码在 [feat-win](https://github.com/clouDr-f2e/rubick/tree/feat-win) 分支。完整版正在开发中,敬请期待
3. linux 开发分支 cross-platform 的 iohook 开发模式下可能需要手动下载并放入node_modules, 将在未来修复
## 目前支持能力
### touchBar 唤起插件
macOS 支持 touchbar 快速唤起插件
<img src=https://user-images.githubusercontent.com/21073039/129727195-7dd50152-19f8-4064-9bcc-24393a896a6d.png width=500 />
![2oyn8-wu97m (3)](https://user-images.githubusercontent.com/21073039/129894362-1dbb8436-921c-4138-be9c-072dc2e62549.gif)
### 超级面板

View File

@@ -1,16 +1,17 @@
{
"name": "rubick2",
"version": "0.0.3-beta.4",
"version": "0.0.3-beta.6",
"author": "muwoo <2424880409@qq.com>",
"description": "An electron-vue project",
"license": null,
"main": "./dist/electron/main.js",
"scripts": {
"release": "node .electron-vue/build.js && electron-builder",
"release": "node .electron-vue/build.js && electron-builder --publish always",
"build": "node .electron-vue/build.js && electron-builder",
"dev": "node .electron-vue/dev-runner.js",
"rebuild": " ./node_modules/.bin/electron-rebuild",
"rebuild_win": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85"
"rebuild_win": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85",
"rebuild_linux": "npm rebuild --runtime=electron --target=12.0.15 --disturl=https://atom.io/download/atom-shell --abi=87"
},
"build": {
"asar": true,
@@ -54,7 +55,8 @@
"allowToChangeInstallationDirectory": true
},
"linux": {
"icon": "build/icons"
"icon": "build/icons/",
"publish": ["github"]
}
},
"dependencies": {
@@ -81,6 +83,7 @@
"robotjs": "git+https://github.com/Toinane/robotjs.git",
"semver": "^7.3.5",
"sudo-prompt": "^9.2.1",
"systeminformation": "^5.8.0",
"unzip": "^0.1.11",
"uuid": "^8.3.2",
"vue": "^2.5.16",
@@ -98,6 +101,7 @@
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"cfonts": "^2.1.2",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.5.1",
@@ -105,7 +109,7 @@
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^11.0.2",
"electron": "^12.0.15",
"electron-builder": "22.10.5",
"electron-debug": "^1.5.0",
"electron-devtools-installer": "^2.2.4",
@@ -136,11 +140,12 @@
"iohook": {
"targets": [
"node-83",
"electron-85"
"electron-87"
],
"platforms": [
"darwin",
"win32"
"win32",
"linux"
],
"arches": [
"x64",

11829
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3,4 +3,4 @@ module.exports = () => ({
separator: require("./separate")(),
superPanel: require("./superPanel")(),
main: require("./main")(),
});
})

View File

@@ -1,10 +1,10 @@
const { BrowserWindow, protocol } = require("electron");
const { BrowserWindow, protocol } = require("electron")
module.exports = () => {
let win;
let win
let init = (opts) => {
createWindow(opts);
};
createWindow(opts)
}
let createWindow = (opts) => {
const winURL = process.env.NODE_ENV === 'development'
@@ -23,6 +23,7 @@ module.exports = () => {
webSecurity: false,
enableRemoteModule: true,
backgroundThrottling: false,
contextIsolation: false,
webviewTag: true,
nodeIntegration: true // 在网页中集成Node
}
@@ -31,24 +32,24 @@ module.exports = () => {
win.loadURL(winURL)
protocol.interceptFileProtocol('image', (req, callback) => {
const url = req.url.substr(8);
callback(decodeURI(url));
const url = req.url.substr(8)
callback(decodeURI(url))
}, (error) => {
if (error) {
console.error('Failed to register protocol');
console.error('Failed to register protocol')
}
});
})
win.once('ready-to-show', () => win.show());
win.once('ready-to-show', () => win.show())
win.on("closed", () => {
win = undefined;
});
};
win = undefined
})
}
let getWindow = () => win;
let getWindow = () => win
return {
init: init,
getWindow: getWindow,
};
};
}
}

View File

@@ -1,13 +1,13 @@
const { BrowserWindow, nativeImage } = require("electron");
const { BrowserWindow, nativeImage } = require("electron")
module.exports = () => {
let win;
let win
let init = (x, y) => {
if (win === null || win === undefined) {
createWindow();
createWindow()
}
};
}
let createWindow = () => {
win = new BrowserWindow({
@@ -22,20 +22,21 @@ module.exports = () => {
hasShadow: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
devTools: false,
},
});
})
win.loadURL(`file://${__static}/plugins/picker/index.html`);
win.loadURL(`file://${__static}/plugins/picker/index.html`)
win.on("closed", () => {
win = undefined;
});
};
win = undefined
})
}
let getWindow = () => win;
let getWindow = () => win
return {
init: init,
getWindow: getWindow,
};
};
}
}

View File

@@ -1,11 +1,11 @@
const { BrowserWindow } = require("electron");
const { BrowserWindow } = require("electron")
module.exports = () => {
let win;
let win
let init = (opts) => {
createWindow(opts);
};
createWindow(opts)
}
let createWindow = (opts) => {
const winURL = process.env.NODE_ENV === 'development'
@@ -22,27 +22,28 @@ module.exports = () => {
webSecurity: false,
enableRemoteModule: true,
backgroundThrottling: false,
contextIsolation: false,
webviewTag: true,
nodeIntegration: true // 在网页中集成Node
}
});
})
process.env.NODE_ENV === 'development' ? win.loadURL(winURL) : win.loadFile(winURL, {
hash: `#/plugin`,
});
})
win.webContents.executeJavaScript(`window.setPluginInfo(${opts})`).then(() => {
win.show()
});
})
win.on("closed", () => {
win = undefined;
});
};
win = undefined
})
}
let getWindow = () => win;
let getWindow = () => win
return {
init: init,
getWindow: getWindow,
};
};
}
}

View File

@@ -1,9 +1,9 @@
import path from "path";
import fs from 'fs';
import {getlocalDataFile} from "./utils";
import os from 'os';
import path from "path"
import fs from 'fs'
import { getlocalDataFile } from "./utils"
import os from 'os'
const configPath = path.join(getlocalDataFile(), './rubick-config.json');
const configPath = path.join(getlocalDataFile(), './rubick-config.json')
let defaultConfig = {
Darwin: {
@@ -55,30 +55,55 @@ let defaultConfig = {
mouseDownTime: 500
},
global: []
},
Linux: {
version: 1,
perf: {
shortCut: {
showAndHidden: 'Option+R',
separate: 'Ctrl+D',
quit: 'Shift+Escape'
},
common: {
start: true,
space: true,
},
local: {
search: true,
}
},
superPanel: {
baiduAPI: {
key: '',
appid: '',
},
mouseDownTime: 500
},
global: []
}
}
global.opConfig = {
config: null,
get() {
const platform = os.type();
const platform = os.type()
try {
if (!opConfig.config) {
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]));
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]))
}
// 重置
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
opConfig.config = defaultConfig[platform];
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
opConfig.config = defaultConfig[platform]
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
}
return opConfig.config;
return opConfig.config
} catch (e) {
opConfig.config = defaultConfig[platform]
return opConfig.config;
return opConfig.config
}
},
set(key, value) {
opConfig.config[key] = value;
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
opConfig.config[key] = value
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -6,6 +6,7 @@ import ioHook from 'iohook';
import {throttle, commonConst} from './utils';
import path from 'path';
import fs from "fs";
import mito from './monitor';
const browsers = require("../browsers")();
const {picker, separator, superPanel} = browsers;
@@ -85,7 +86,13 @@ class Listener {
init(mainWindow) {
this.fn = throttle(({x, y}, picker) => {
const img = robot.screen.capture(parseInt(x) - 5, parseInt(y) - 5, 9, 9);
const { scaleFactor } = screen.getDisplayNearestPoint({x, y});
const img = robot.screen.capture(
x - parseInt(5 / scaleFactor),
y - parseInt(5 / scaleFactor),
10,
10
);
const colors = {}
@@ -199,7 +206,6 @@ class Listener {
return new TouchBarButton({
icon,
backgroundColor: '#ff9fb4',
click() {
mainWindow.webContents.send('superPanel-openPlugin', {
cmd: item.features[0].cmds.filter(cmd => typeof cmd === 'string')[0],
@@ -214,7 +220,6 @@ class Listener {
if(item.type === 'system') {
return new TouchBarButton({
icon: nativeImage.createFromDataURL(item.logo).resize({width: 20, height: 20}),
backgroundColor: '#ff9fb4',
click() {
mainWindow.webContents.send('superPanel-openPlugin', {
cmd: item.features[0].cmds.filter(cmd => typeof cmd === 'string')[0],
@@ -235,10 +240,21 @@ class Listener {
showCloseButton: true
});
const monitor = new TouchBarPopover({
items: mito.touchBar,
label: '系统监控',
showCloseButton: true
});
const touchBar = new TouchBar({
items: [plugin, ...system]
items: [
plugin,
monitor,
...system
]
});
mainWindow.setTouchBar(touchBar);
mito.start(mainWindow);
});
}

124
src/main/common/monitor.js Normal file
View File

@@ -0,0 +1,124 @@
const {TouchBar} = require('electron')
const path = require('path')
const si = require('systeminformation');
const spawn = require('child_process').spawn;
const {TouchBarButton, TouchBarSpacer} = TouchBar;
const LOAD_NORMAL = "#2ecc71";
const LOAD_MEDIUM = "#f1c40f";
const LOAD_HIGH = "#d35400";
const LOAD_SEVERE = "#e74c3c";
const cpu = new TouchBarButton({
label: '',
backgroundColor: "#bdc3c7",
icon: path.join(__dirname, 'icons/chip.png'),
iconPosition: "left",
click: () => {
spawn("/System/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity\ Monitor", []);
}
});
const memory = new TouchBarButton({
label: '',
backgroundColor: "#bdc3c7",
icon: path.join(__dirname, 'icons/ram.png'),
iconPosition: "left"
});
const network = new TouchBarButton({
label: '',
backgroundColor: '#3498db',
icon: path.join(__dirname, 'icons/internet.png'),
iconPosition: "left"
});
const battery = new TouchBarButton({
label: '',
backgroundColor: "#bdc3c7",
icon: path.join(__dirname, 'icons/power.png'),
iconPosition: "left"
});
const updateData = () => {
si.currentLoad(function(data) {
if (typeof data !== 'undefined' && data){
const load = data.currentLoad.toFixed(0)
cpu.label = load+"%"
if (load <= 20) cpu.backgroundColor = LOAD_NORMAL;
else if (load > 20 && load <= 40) cpu.backgroundColor = LOAD_MEDIUM;
else if (load > 40 && load <= 80) cpu.backgroundColor = LOAD_HIGH;
else if (load > 80 && load <= 100) cpu.backgroundColor = LOAD_SEVERE;
}
})
si.mem(function(data) {
if (typeof data !== 'undefined' && data){
const load = ((100* data.active ) / data.total).toFixed(0)
memory.label = load+"%"
if (load <= 20) memory.backgroundColor = LOAD_NORMAL;
else if (load > 20 && load <= 40) memory.backgroundColor = LOAD_MEDIUM;
else if (load > 40 && load <= 80) memory.backgroundColor = LOAD_HIGH;
else if (load > 80 && load <= 100) memory.backgroundColor = LOAD_SEVERE;
}
})
si.networkStats("", function(data) {
if (typeof data !== 'undefined' && data){
const kbtx = (data[0].tx_sec * 0.001).toFixed(0)
const kbrx = (data[0].rx_sec * 0.001).toFixed(0)
const l = (kbtx+kbrx).toString().length
network.label = "⇡"+ (kbtx*0.001).toFixed(2)
+" ⇣"+ (kbrx*0.001).toFixed(2) +" MB/s"
}
})
si.battery( function(data) {
if (typeof data !== 'undefined' && data){
if (data.ischarging){
battery.icon = path.join(__dirname, 'icons/charger.png')
}else{
battery.icon = path.join(__dirname, 'icons/power.png')
}
const load = data.percent.toFixed(0)
battery.label = load+"%"
if (load <= 20) battery.backgroundColor = LOAD_SEVERE;
else if (load > 20 && load <= 40) battery.backgroundColor = LOAD_HIGH;
else if (load > 40 && load <= 80) battery.backgroundColor = LOAD_MEDIUM;
else if (load > 80 && load <= 100) battery.backgroundColor = LOAD_NORMAL
}
})
}
const touchBar = new TouchBar({
items: [
cpu,
new TouchBarSpacer({size: 'small'}),
memory,
new TouchBarSpacer({size: 'small'}),
network,
new TouchBarSpacer({size: 'small'}),
battery,
]
})
let intervalObj;
const start = (window) => {
window.on('blur', () => {
clearInterval(intervalObj);
});
window.on('focus', () => {
intervalObj = setInterval(() => {
updateData();
}, 1000);
});
updateData();
}
export default {
start,
touchBar,
}

View File

@@ -1,18 +1,18 @@
import { app, globalShortcut } from 'electron'
import '../renderer/store'
import init from './common/common';
import {autoUpdate} from './common/autoUpdate';
import createTray from './tray';
import {commonConst} from './common/utils';
import pkg from '../../package.json';
import init from './common/common'
import { autoUpdate } from './common/autoUpdate'
import createTray from './tray'
import { commonConst } from './common/utils'
import pkg from '../../package.json'
const {main} = require("./browsers")();
const { main } = require("./browsers")()
if (commonConst.production()) {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}
// to fix https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = false;
app.allowRendererProcessReuse = false
class initApp {
launchApp() {
@@ -28,28 +28,28 @@ class initApp {
}
createWindow() {
main.init();
init(main.getWindow());
main.init()
init(main.getWindow())
}
beforeReady() {
// 系统托盘
if (commonConst.macOS()) {
if (commonConst.production() && !app.isInApplicationsFolder()) {
app.moveToApplicationsFolder();
app.moveToApplicationsFolder()
} else {
app.dock.hide();
app.dock.hide()
}
}else {
app.disableHardwareAcceleration();
} else {
app.disableHardwareAcceleration()
}
}
onReady() {
const readyFunction = () => {
this.createWindow();
createTray(main.getWindow());
autoUpdate();
this.createWindow()
createTray(main.getWindow())
autoUpdate()
}
if (!app.isReady()) {
app.on('ready', readyFunction)
@@ -61,25 +61,25 @@ class initApp {
onRunning() {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
const win = main.getWindow();
const win = main.getWindow()
if (win) {
if (win.isMinimized()) {
win.restore();
win.restore()
}
win.focus();
win.focus()
}
});
})
app.on('activate', () => {
if (!main.getWindow()) {
this.createWindow();
this.createWindow()
}
});
})
if (commonConst.windows()) {
app.setAppUserModelId(pkg.build.appId);
app.setAppUserModelId(pkg.build.appId)
}
}
onQuit () {
onQuit() {
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
@@ -106,4 +106,4 @@ class initApp {
}
}
(new initApp()).launchApp();
(new initApp()).launchApp()

View File

@@ -2,7 +2,7 @@ import {shell, ipcRenderer} from 'electron';
export default {
'rubick-help': {
help() {
shell.openExternal('https://u.tools/docs/guide/about-uTools.html')
shell.openExternal('https://cloudr-f2e.github.io/rubick/')
}
},
'rubick-color': {

View File

@@ -4,6 +4,7 @@ const path = require('path');
const fs = require('fs');
const { spawn } = require ('child_process');
const mineType = require("mime-types");
const {extend} = require('../../utils');
new Vue({
el: '#app',
@@ -116,7 +117,8 @@ new Vue({
this.targetOptions = this.options.common;
} else {
// 有文件选择
this.targetOptions = JSON.parse(JSON.stringify(this.options.selected));
this.targetOptions = [];
extend(this.targetOptions, this.options.selected, true);
// 检测上传
(this.selectData.optionPlugin || []).forEach(plugin => {
plugin.features.forEach(fe => {

View File

@@ -20,8 +20,31 @@ function getData(path, defaultValue) {
}
}
const isArray = Array.isArray ||
function(object){ return object instanceof Array }
function isPlainObject(obj) {
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype
}
function isObject(obj) { return typeof obj == "object" }
function extend(target, source, deep) {
for (let key in source)
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
if (isPlainObject(source[key]) && !isPlainObject(target[key]))
target[key] = {}
if (isArray(source[key]) && !isArray(target[key]))
target[key] = []
extend(target[key], source[key], deep)
}
else if (source[key] !== undefined) target[key] = source[key]
}
module.exports = {
getlocalDataFile,
saveData,
getData
getData,
extend
}