mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-19 10:35:30 +08:00
Merge branch 'dev'
This commit is contained in:
commit
7b1242885a
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rubick2",
|
"name": "rubick2",
|
||||||
"version": "0.0.3-beta.3",
|
"version": "0.0.3-beta.4",
|
||||||
"author": "muwoo <2424880409@qq.com>",
|
"author": "muwoo <2424880409@qq.com>",
|
||||||
"description": "An electron-vue project",
|
"description": "An electron-vue project",
|
||||||
"license": null,
|
"license": null,
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import {app, BrowserWindow, clipboard, globalShortcut, ipcMain, Notification, screen} from "electron";
|
import {app, nativeImage, BrowserWindow, clipboard, globalShortcut, ipcMain, Notification, screen, TouchBar} from "electron";
|
||||||
import {exec, spawn} from "child_process";
|
import {exec, spawn} from "child_process";
|
||||||
import robot from "robotjs";
|
import robot from "robotjs";
|
||||||
import Api from "./api";
|
import Api from "./api";
|
||||||
import ioHook from 'iohook';
|
import ioHook from 'iohook';
|
||||||
import {throttle, commonConst} from './utils';
|
import {throttle, commonConst} from './utils';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
const browsers = require("../browsers")();
|
const browsers = require("../browsers")();
|
||||||
const {picker, separator, superPanel} = browsers;
|
const {picker, separator, superPanel} = browsers;
|
||||||
@ -102,6 +104,7 @@ class Listener {
|
|||||||
this.lockScreen();
|
this.lockScreen();
|
||||||
this.separate();
|
this.separate();
|
||||||
this.initCapture();
|
this.initCapture();
|
||||||
|
this.initTouchBar(mainWindow);
|
||||||
this.superPanel(mainWindow);
|
this.superPanel(mainWindow);
|
||||||
this.reRegisterShortCut(mainWindow);
|
this.reRegisterShortCut(mainWindow);
|
||||||
this.changeSize(mainWindow);
|
this.changeSize(mainWindow);
|
||||||
@ -183,6 +186,62 @@ class Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initTouchBar(mainWindow) {
|
||||||
|
const { TouchBarButton, TouchBarGroup, TouchBarPopover } = TouchBar;
|
||||||
|
let items = [];
|
||||||
|
let system = [];
|
||||||
|
ipcMain.on('pluginInit', (e, args) => {
|
||||||
|
this.optionPlugin = args;
|
||||||
|
items = args.plugins.map((item) => {
|
||||||
|
const iconPath = path.join(item.sourceFile, '../', item.logo);
|
||||||
|
if (!fs.existsSync(iconPath)) return false;
|
||||||
|
const icon = nativeImage.createFromPath(iconPath).resize({width: 20, height: 20});
|
||||||
|
|
||||||
|
return new TouchBarButton({
|
||||||
|
icon,
|
||||||
|
backgroundColor: '#ff9fb4',
|
||||||
|
click() {
|
||||||
|
mainWindow.webContents.send('superPanel-openPlugin', {
|
||||||
|
cmd: item.features[0].cmds.filter(cmd => typeof cmd === 'string')[0],
|
||||||
|
plugin: item,
|
||||||
|
feature: item.features[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).filter(Boolean);
|
||||||
|
|
||||||
|
system = args.plugins.map((item) => {
|
||||||
|
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],
|
||||||
|
plugin: item,
|
||||||
|
feature: item.features[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).filter(Boolean);
|
||||||
|
|
||||||
|
const plugin = new TouchBarPopover({
|
||||||
|
items: new TouchBar({
|
||||||
|
items,
|
||||||
|
}),
|
||||||
|
label: '已安装插件',
|
||||||
|
showCloseButton: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const touchBar = new TouchBar({
|
||||||
|
items: [plugin, ...system]
|
||||||
|
});
|
||||||
|
mainWindow.setTouchBar(touchBar);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
initPlugin() {
|
initPlugin() {
|
||||||
ipcMain.on('optionPlugin', (e, args) => {
|
ipcMain.on('optionPlugin', (e, args) => {
|
||||||
this.optionPlugin = args;
|
this.optionPlugin = args;
|
||||||
|
@ -130,7 +130,10 @@ function mergePlugins(plugins) {
|
|||||||
return hasOption;
|
return hasOption;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
ipcRenderer &&
|
||||||
|
ipcRenderer.send('pluginInit', {
|
||||||
|
plugins: target
|
||||||
|
});
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user