mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve main window position restoration after boot on the Desktop https://github.com/siyuan-note/siyuan/issues/11437
This commit is contained in:
parent
c705f6b189
commit
d68f3c34fd
1 changed files with 11 additions and 13 deletions
|
|
@ -268,8 +268,9 @@ const initMainWindow = () => {
|
||||||
height: defaultHeight,
|
height: defaultHeight,
|
||||||
}, oldWindowState);
|
}, oldWindowState);
|
||||||
|
|
||||||
// writeLog("windowStat [width=" + windowState.width + ", height=" + windowState.height + "], default [width=" + defaultWidth + ", height=" + defaultHeight + "], workArea [width=" + workArea.width + ", height=" + workArea.height + "]");
|
writeLog("windowStat [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + "], default [width=" + defaultWidth + ", height=" + defaultHeight + "], workArea [width=" + workArea.width + ", height=" + workArea.height + "]");
|
||||||
|
|
||||||
|
let resetToCenter = false
|
||||||
let x = windowState.x;
|
let x = windowState.x;
|
||||||
let y = windowState.y;
|
let y = windowState.y;
|
||||||
if (workArea) {
|
if (workArea) {
|
||||||
|
|
@ -278,25 +279,22 @@ const initMainWindow = () => {
|
||||||
windowState.width = Math.min(defaultWidth, workArea.width);
|
windowState.width = Math.min(defaultWidth, workArea.width);
|
||||||
windowState.height = Math.min(defaultHeight, workArea.height);
|
windowState.height = Math.min(defaultHeight, workArea.height);
|
||||||
}
|
}
|
||||||
if (x >= workArea.width * 0.8) {
|
|
||||||
x = 0;
|
if (x >= workArea.width * 0.8 || y >= workArea.height * 0.8) {
|
||||||
}
|
resetToCenter = true;
|
||||||
if (y >= workArea.height * 0.8) {
|
|
||||||
y = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x < 0 || y < 0) {
|
||||||
|
resetToCenter = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (windowState.width < 493) {
|
if (windowState.width < 493) {
|
||||||
windowState.width = 493;
|
windowState.width = 493;
|
||||||
}
|
}
|
||||||
if (windowState.height < 376) {
|
if (windowState.height < 376) {
|
||||||
windowState.height = 376;
|
windowState.height = 376;
|
||||||
}
|
}
|
||||||
if (x < 0) {
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
if (y < 0) {
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建主窗体
|
// 创建主窗体
|
||||||
const currentWindow = new BrowserWindow({
|
const currentWindow = new BrowserWindow({
|
||||||
|
|
@ -321,7 +319,7 @@ const initMainWindow = () => {
|
||||||
});
|
});
|
||||||
remote.enable(currentWindow.webContents);
|
remote.enable(currentWindow.webContents);
|
||||||
|
|
||||||
windowStateInitialized ? currentWindow.setPosition(x, y) : currentWindow.center();
|
resetToCenter ? currentWindow.center() : currentWindow.setPosition(x, y);
|
||||||
currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
|
currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
|
||||||
|
|
||||||
// set proxy
|
// set proxy
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue