mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Support minimize the main window after auto launch on Windows https://github.com/siyuan-note/siyuan/issues/11145
This commit is contained in:
parent
b6eff31ba8
commit
5a7097865c
1 changed files with 8 additions and 4 deletions
|
|
@ -230,6 +230,11 @@ const writeLog = (out) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let openAsHidden = false;
|
||||||
|
isOpenAsHidden = function () {
|
||||||
|
return 1 === workspaces.length && openAsHidden;
|
||||||
|
}
|
||||||
|
|
||||||
const initMainWindow = () => {
|
const initMainWindow = () => {
|
||||||
let windowStateInitialized = true;
|
let windowStateInitialized = true;
|
||||||
// 恢复主窗体状态
|
// 恢复主窗体状态
|
||||||
|
|
@ -382,7 +387,7 @@ const initMainWindow = () => {
|
||||||
|
|
||||||
// 主界面事件监听
|
// 主界面事件监听
|
||||||
currentWindow.once("ready-to-show", () => {
|
currentWindow.once("ready-to-show", () => {
|
||||||
if (1 === workspaces.length && openAsHidden) {
|
if (isOpenAsHidden()) {
|
||||||
currentWindow.minimize();
|
currentWindow.minimize();
|
||||||
} else {
|
} else {
|
||||||
currentWindow.show();
|
currentWindow.show();
|
||||||
|
|
@ -449,6 +454,7 @@ const initKernel = (workspace, port, lang) => {
|
||||||
height: Math.floor(screen.getPrimaryDisplay().workAreaSize.height / 2),
|
height: Math.floor(screen.getPrimaryDisplay().workAreaSize.height / 2),
|
||||||
frame: false,
|
frame: false,
|
||||||
backgroundColor: "#1e1e1e",
|
backgroundColor: "#1e1e1e",
|
||||||
|
resizable: false,
|
||||||
icon: path.join(appDir, "stage", "icon-large.png"),
|
icon: path.join(appDir, "stage", "icon-large.png"),
|
||||||
});
|
});
|
||||||
let bootIndex = path.join(appDir, "app", "electron", "boot.html");
|
let bootIndex = path.join(appDir, "app", "electron", "boot.html");
|
||||||
|
|
@ -568,9 +574,7 @@ const initKernel = (workspace, port, lang) => {
|
||||||
try {
|
try {
|
||||||
const apiResult = await net.fetch(getServer() + "/api/system/version");
|
const apiResult = await net.fetch(getServer() + "/api/system/version");
|
||||||
apiData = await apiResult.json();
|
apiData = await apiResult.json();
|
||||||
bootWindow.setResizable(false);
|
|
||||||
bootWindow.loadURL(getServer() + "/appearance/boot/index.html");
|
bootWindow.loadURL(getServer() + "/appearance/boot/index.html");
|
||||||
bootWindow.show();
|
|
||||||
break;
|
break;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
writeLog("get kernel version failed: " + e.message);
|
writeLog("get kernel version failed: " + e.message);
|
||||||
|
|
@ -634,7 +638,7 @@ let argStart = 1;
|
||||||
if (!app.isPackaged) {
|
if (!app.isPackaged) {
|
||||||
argStart = 2;
|
argStart = 2;
|
||||||
}
|
}
|
||||||
let openAsHidden = false;
|
|
||||||
for (let i = argStart; i < process.argv.length; i++) {
|
for (let i = argStart; i < process.argv.length; i++) {
|
||||||
let arg = process.argv[i];
|
let arg = process.argv[i];
|
||||||
if (arg.startsWith("--workspace=") || arg.startsWith("--openAsHidden") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) {
|
if (arg.startsWith("--workspace=") || arg.startsWith("--openAsHidden") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue