Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/11145

Vanessa340333e2431f
diff --git a/app/electron/main.js b/app/electron/main.js
index 8676962ae9..aab2095315 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -382,11 +382,15 @@ const initMainWindow = () => {
// 主界面事件监听
currentWindow.once("ready-to-show", () => {
- currentWindow.show();
- if (windowState.isMaximized) {
- currentWindow.maximize();
+ if (workspaces.length === 0 && openAsHidden) {
+ bootWindow.minimize();
} else {
- currentWindow.unmaximize();
+ currentWindow.show();
+ if (windowState.isMaximized) {
+ currentWindow.maximize();
+ } else {
+ currentWindow.unmaximize();
+ }
}
if (bootWindow && !bootWindow.isDestroyed()) {
bootWindow.destroy();
@@ -451,7 +455,11 @@ const initKernel = (workspace, port, lang) => {
bootIndex = path.join(appDir, "electron", "boot.html");
}
bootWindow.loadFile(bootIndex, {query: {v: appVer}});
- bootWindow.show();
+ if (openAsHidden) {
+ bootWindow.minimize();
+ } else {
+ bootWindow.show();
+ }
const kernelName = "win32" === process.platform ? "SiYuan-Kernel.exe" : "SiYuan-Kernel";
const kernelPath = path.join(appDir, "kernel", kernelName);
@@ -625,10 +633,14 @@ 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("--port=") || arg.startsWith("siyuan://")) {
+ if (arg.startsWith("--workspace=") || arg.startsWith("--openAsHidden") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) {
// 跳过内置参数
+ if (arg.startsWith("--openAsHidden")) {
+ openAsHidden = true;
+ }
continue;
}
@@ -1118,7 +1130,10 @@ app.whenReady().then(() => {
});
});
ipcMain.on("siyuan-auto-launch", (event, data) => {
- app.setLoginItemSettings({openAtLogin: data.openAtLogin});
+ app.setLoginItemSettings({
+ openAtLogin: data.openAtLogin,
+ args: data.openAsHidden ? ["--openAsHidden"] : ""
+ });
});
if (firstOpen) {
diff --git a/app/src/config/about.ts b/app/src/config/about.ts
index 8cdaa3ed04..d7e7af5f73 100644
--- a/app/src/config/about.ts
+++ b/app/src/config/about.ts
@@ -7,7 +7,7 @@ import {fetchPost} from "../util/fetch";
import {setAccessAuthCode} from "./util/about";
import {exportLayout} from "../layout/util";
import {exitSiYuan, processSync} from "../dialog/processSystem";
-import {isInAndroid, isInIOS, isIPad, openByMobile, writeText} from "../protyle/util/compatibility";
+import {isInAndroid, isInIOS, isIPad, isMac, openByMobile, writeText} from "../protyle/util/compatibility";
import {showMessage} from "../dialog/message";
import {Dialog} from "../dialog";
import {confirmDialog} from "../dialog/confirmDialog";
@@ -25,7 +25,7 @@ export const about = {
<select class="b3-select fn__flex-center fn__size200" id="autoLaunch">
<option value="0" ${window.siyuan.config.system.autoLaunch2 === 0 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode0}</option>
<option value="1" ${window.siyuan.config.system.autoLaunch2 === 1 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode1}</option>
- <option value="2" ${window.siyuan.config.system.autoLaunch2 === 2 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode2}</option>
+ ${isMac() ? "" : `<option value="2" ${window.siyuan.config.system.autoLaunch2 === 2 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode2}</option>`}
</select>
</div>
<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore || window.siyuan.config.system.container !== "std" ? " fn__none" : ""}">
@@ -355,7 +355,10 @@ export const about = {
const autoLaunchMode = parseInt(autoLaunchElement.value)
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchMode}, () => {
window.siyuan.config.system.autoLaunch2 = autoLaunchMode;
- ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, {openAtLogin: 0 != autoLaunchMode});
+ ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, {
+ openAtLogin: 0 !== autoLaunchMode,
+ openAsHidden: 2 === autoLaunchMode
+ });
});
});
/// #endif