mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-26 12:42:34 +08:00
✨ 支持窗口记忆#216;支持本地启动;支持搜索历史记录
This commit is contained in:
@@ -9,8 +9,6 @@ import {
|
||||
screen,
|
||||
shell,
|
||||
} from 'electron';
|
||||
import { runner, detach } from '../browsers';
|
||||
import DBInstance from './db';
|
||||
import fs from 'fs';
|
||||
import { screenCapture } from '@/core';
|
||||
import plist from 'plist';
|
||||
@@ -20,6 +18,10 @@ import { DECODE_KEY } from '@/common/constans/main';
|
||||
import getCopyFiles from '@/common/utils/getCopyFiles';
|
||||
|
||||
import mainInstance from '../index';
|
||||
import { runner, detach } from '../browsers';
|
||||
import DBInstance from './db';
|
||||
import getWinPosition from './getWinPosition';
|
||||
|
||||
const runnerInstance = runner();
|
||||
const detachInstance = detach();
|
||||
|
||||
@@ -65,6 +67,7 @@ class API extends DBInstance {
|
||||
const originWindow = this.getCurrentWindow(window, e);
|
||||
if (!originWindow) return;
|
||||
originWindow.setBounds({ x: x - mouseX, y: y - mouseY, width, height });
|
||||
getWinPosition.setPosition(x - mouseX, y - mouseY);
|
||||
}
|
||||
|
||||
public loadPlugin({ data: plugin }, window) {
|
||||
|
||||
34
src/main/common/getWinPosition.ts
Normal file
34
src/main/common/getWinPosition.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { screen } from 'electron';
|
||||
|
||||
const winPosition = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
id: -1,
|
||||
getPosition(): { x: number; y: number } {
|
||||
const { x, y } = screen.getCursorScreenPoint();
|
||||
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
|
||||
if (winPosition.id !== currentDisplay.id) {
|
||||
winPosition.id = currentDisplay.id;
|
||||
winPosition.x = parseInt(
|
||||
String(
|
||||
currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400
|
||||
)
|
||||
);
|
||||
winPosition.y = parseInt(
|
||||
String(
|
||||
currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200
|
||||
)
|
||||
);
|
||||
}
|
||||
return {
|
||||
x: winPosition.x,
|
||||
y: winPosition.y,
|
||||
};
|
||||
},
|
||||
setPosition(x: number, y: number): void {
|
||||
winPosition.x = x;
|
||||
winPosition.y = y;
|
||||
},
|
||||
};
|
||||
|
||||
export default winPosition;
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from 'electron';
|
||||
import screenCapture from '@/core/screen-capture';
|
||||
import localConfig from '@/main/common/initLocalConfig';
|
||||
import winPosition from './getWinPosition';
|
||||
|
||||
const registerHotKey = (mainWindow: BrowserWindow): void => {
|
||||
// 设置开机启动
|
||||
@@ -56,20 +57,7 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
|
||||
globalShortcut.register(config.perf.shortCut.showAndHidden, () => {
|
||||
const currentShow = mainWindow.isVisible() && mainWindow.isFocused();
|
||||
if (currentShow) return mainWindow.hide();
|
||||
|
||||
const { x, y } = screen.getCursorScreenPoint();
|
||||
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
|
||||
const wx = parseInt(
|
||||
String(
|
||||
currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400
|
||||
)
|
||||
);
|
||||
const wy = parseInt(
|
||||
String(
|
||||
currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200
|
||||
)
|
||||
);
|
||||
|
||||
const { x: wx, y: wy } = winPosition.getPosition();
|
||||
mainWindow.setAlwaysOnTop(false);
|
||||
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
||||
mainWindow.focus();
|
||||
|
||||
@@ -9,6 +9,7 @@ import { execSync } from 'child_process';
|
||||
import searchManager from './search';
|
||||
import optionsManager from './options';
|
||||
import { PLUGIN_INSTALL_DIR as baseDir } from '@/common/constans/renderer';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
const createPluginManager = (): any => {
|
||||
const pluginInstance = new PluginHandler({
|
||||
@@ -87,7 +88,11 @@ const createPluginManager = (): any => {
|
||||
});
|
||||
}
|
||||
if (plugin.pluginType === 'app') {
|
||||
execSync(plugin.action);
|
||||
try {
|
||||
execSync(plugin.action);
|
||||
} catch (e) {
|
||||
message.error('启动应用出错,请确保启动应用存在!');
|
||||
}
|
||||
}
|
||||
window.initRubick();
|
||||
changePluginHistory({
|
||||
|
||||
Reference in New Issue
Block a user