Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 17, 2024
2 parents 50c6c93 + d68f3c3 commit ca6833b
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ const initMainWindow = () => {
height: defaultHeight,
}, 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 y = windowState.y;
if (workArea) {
Expand All @@ -278,25 +279,22 @@ const initMainWindow = () => {
windowState.width = Math.min(defaultWidth, workArea.width);
windowState.height = Math.min(defaultHeight, workArea.height);
}
if (x >= workArea.width * 0.8) {
x = 0;
}
if (y >= workArea.height * 0.8) {
y = 0;

if (x >= workArea.width * 0.8 || y >= workArea.height * 0.8) {
resetToCenter = true;
}
}

if (x < 0 || y < 0) {
resetToCenter = true;
}

if (windowState.width < 493) {
windowState.width = 493;
}
if (windowState.height < 376) {
windowState.height = 376;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}

// 创建主窗体
const currentWindow = new BrowserWindow({
Expand All @@ -321,7 +319,7 @@ const initMainWindow = () => {
});
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;

// set proxy
Expand Down

0 comments on commit ca6833b

Please sign in to comment.