ref: 支持主窗口多desktop在应用上唤起

This commit is contained in:
muwoo 2021-07-15 11:50:53 +08:00
parent b51da4835d
commit c31290ee0d
4 changed files with 18 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "rubick2", "name": "rubick2",
"version": "0.0.1", "version": "0.0.2",
"author": "muwoo <2424880409@qq.com>", "author": "muwoo <2424880409@qq.com>",
"description": "An electron-vue project", "description": "An electron-vue project",
"license": null, "license": null,

View File

@ -35,7 +35,6 @@ module.exports = () => {
}, },
}); });
win.loadURL(`file://${__static}/plugins/superPanel/index.html`); win.loadURL(`file://${__static}/plugins/superPanel/index.html`);
win.once('ready-to-show', () => win.show());
win.on("closed", () => { win.on("closed", () => {
win = undefined; win = undefined;
}); });

View File

@ -5,6 +5,7 @@ import {
clipboard, clipboard,
Notification, Notification,
app, app,
screen,
} from 'electron'; } from 'electron';
import Api from './api'; import Api from './api';
import robot from 'robotjs'; import robot from 'robotjs';
@ -28,6 +29,14 @@ function registerShortCut(mainWindow) {
globalShortcut.unregisterAll(); globalShortcut.unregisterAll();
// 注册偏好快捷键 // 注册偏好快捷键
globalShortcut.register(config.perf.shortCut.showAndHidden, () => { globalShortcut.register(config.perf.shortCut.showAndHidden, () => {
const {x, y} = screen.getCursorScreenPoint();
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
const wx = parseInt(currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400);
const wy = parseInt(currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200);
mainWindow.setVisibleOnAllWorkspaces(true);
mainWindow.focus();
mainWindow.setVisibleOnAllWorkspaces(false);
mainWindow.setPosition(wx, wy);
mainWindow.show(); mainWindow.show();
}); });

View File

@ -26,6 +26,7 @@
<a-list-item-meta <a-list-item-meta
@click="showPannel(item)"
:description="item.description" :description="item.description"
> >
<div slot="title">{{ item.pluginName }}</div> <div slot="title">{{ item.pluginName }}</div>
@ -48,7 +49,9 @@ export default {
return { return {
pluginList: [], pluginList: [],
loading: {}, loading: {},
bannerList: [] bannerList: [],
show: false,
currentSelect: {}
} }
}, },
async created() { async created() {
@ -75,6 +78,10 @@ export default {
showButton(item) { showButton(item) {
return !this.devPlugins.filter(plugin => (plugin.name === item.name && plugin.type === 'prod')).length; return !this.devPlugins.filter(plugin => (plugin.name === item.name && plugin.type === 'prod')).length;
}, },
showPannel(item) {
this.show = true;
this.currentSelect = item;
},
...mapActions('main', ['downloadPlugin']) ...mapActions('main', ['downloadPlugin'])
}, },
computed: { computed: {