|
|
|
@ -7,6 +7,7 @@ import {
|
|
|
|
|
dialog,
|
|
|
|
|
globalShortcut,
|
|
|
|
|
nativeTheme,
|
|
|
|
|
screen,
|
|
|
|
|
} from 'electron';
|
|
|
|
|
import {
|
|
|
|
|
isWindows,
|
|
|
|
@ -201,8 +202,42 @@ class Background {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (this.store.get('window.x') && this.store.get('window.y')) {
|
|
|
|
|
options.x = this.store.get('window.x');
|
|
|
|
|
options.y = this.store.get('window.y');
|
|
|
|
|
let x = this.store.get('window.x');
|
|
|
|
|
let y = this.store.get('window.y');
|
|
|
|
|
|
|
|
|
|
let displays = screen.getAllDisplays();
|
|
|
|
|
let isResetWindiw = false;
|
|
|
|
|
if (displays.length === 1) {
|
|
|
|
|
let { bounds } = displays[0];
|
|
|
|
|
if (
|
|
|
|
|
x < bounds.x ||
|
|
|
|
|
x > bounds.x + bounds.width - 50 ||
|
|
|
|
|
y < bounds.y ||
|
|
|
|
|
y > bounds.y + bounds.height - 50
|
|
|
|
|
) {
|
|
|
|
|
isResetWindiw = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isResetWindiw = true;
|
|
|
|
|
for (let i = 0; i < displays.length; i++) {
|
|
|
|
|
let { bounds } = displays[i];
|
|
|
|
|
if (
|
|
|
|
|
x > bounds.x &&
|
|
|
|
|
x < bounds.x + bounds.width &&
|
|
|
|
|
y > bounds.y &&
|
|
|
|
|
y < bounds.y - bounds.height
|
|
|
|
|
) {
|
|
|
|
|
// 检测到APP窗口当前处于一个可用的屏幕里,break
|
|
|
|
|
isResetWindiw = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isResetWindiw) {
|
|
|
|
|
options.x = x;
|
|
|
|
|
options.y = y;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.window = new BrowserWindow(options);
|
|
|
|
@ -261,6 +296,7 @@ class Background {
|
|
|
|
|
this.window.once('ready-to-show', () => {
|
|
|
|
|
log('window ready-to-show event');
|
|
|
|
|
this.window.show();
|
|
|
|
|
this.store.set('window', this.window.getBounds());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.window.on('close', e => {
|
|
|
|
|