Skip to content

Commit

Permalink
🎨 Support minimize the main window after auto launch on Windows #11145
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Apr 28, 2024
1 parent b6eff31 commit 5a70978
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ const writeLog = (out) => {
}
};

let openAsHidden = false;
isOpenAsHidden = function () {
return 1 === workspaces.length && openAsHidden;
}

const initMainWindow = () => {
let windowStateInitialized = true;
// 恢复主窗体状态
Expand Down Expand Up @@ -382,7 +387,7 @@ const initMainWindow = () => {

// 主界面事件监听
currentWindow.once("ready-to-show", () => {
if (1 === workspaces.length && openAsHidden) {
if (isOpenAsHidden()) {
currentWindow.minimize();
} else {
currentWindow.show();
Expand Down Expand Up @@ -449,6 +454,7 @@ const initKernel = (workspace, port, lang) => {
height: Math.floor(screen.getPrimaryDisplay().workAreaSize.height / 2),
frame: false,
backgroundColor: "#1e1e1e",
resizable: false,
icon: path.join(appDir, "stage", "icon-large.png"),
});
let bootIndex = path.join(appDir, "app", "electron", "boot.html");
Expand Down Expand Up @@ -568,9 +574,7 @@ const initKernel = (workspace, port, lang) => {
try {
const apiResult = await net.fetch(getServer() + "/api/system/version");
apiData = await apiResult.json();
bootWindow.setResizable(false);
bootWindow.loadURL(getServer() + "/appearance/boot/index.html");
bootWindow.show();
break;
} catch (e) {
writeLog("get kernel version failed: " + e.message);
Expand Down Expand Up @@ -634,7 +638,7 @@ let argStart = 1;
if (!app.isPackaged) {
argStart = 2;
}
let openAsHidden = false;

for (let i = argStart; i < process.argv.length; i++) {
let arg = process.argv[i];
if (arg.startsWith("--workspace=") || arg.startsWith("--openAsHidden") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) {
Expand Down

0 comments on commit 5a70978

Please sign in to comment.