mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
e7a1902d60
commit
340333e243
2 changed files with 28 additions and 10 deletions
|
|
@ -382,11 +382,15 @@ const initMainWindow = () => {
|
||||||
|
|
||||||
// 主界面事件监听
|
// 主界面事件监听
|
||||||
currentWindow.once("ready-to-show", () => {
|
currentWindow.once("ready-to-show", () => {
|
||||||
currentWindow.show();
|
if (workspaces.length === 0 && openAsHidden) {
|
||||||
if (windowState.isMaximized) {
|
bootWindow.minimize();
|
||||||
currentWindow.maximize();
|
|
||||||
} else {
|
} else {
|
||||||
currentWindow.unmaximize();
|
currentWindow.show();
|
||||||
|
if (windowState.isMaximized) {
|
||||||
|
currentWindow.maximize();
|
||||||
|
} else {
|
||||||
|
currentWindow.unmaximize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bootWindow && !bootWindow.isDestroyed()) {
|
if (bootWindow && !bootWindow.isDestroyed()) {
|
||||||
bootWindow.destroy();
|
bootWindow.destroy();
|
||||||
|
|
@ -451,7 +455,11 @@ const initKernel = (workspace, port, lang) => {
|
||||||
bootIndex = path.join(appDir, "electron", "boot.html");
|
bootIndex = path.join(appDir, "electron", "boot.html");
|
||||||
}
|
}
|
||||||
bootWindow.loadFile(bootIndex, {query: {v: appVer}});
|
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 kernelName = "win32" === process.platform ? "SiYuan-Kernel.exe" : "SiYuan-Kernel";
|
||||||
const kernelPath = path.join(appDir, "kernel", kernelName);
|
const kernelPath = path.join(appDir, "kernel", kernelName);
|
||||||
|
|
@ -625,10 +633,14 @@ 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("--port=") || arg.startsWith("siyuan://")) {
|
if (arg.startsWith("--workspace=") || arg.startsWith("--openAsHidden") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) {
|
||||||
// 跳过内置参数
|
// 跳过内置参数
|
||||||
|
if (arg.startsWith("--openAsHidden")) {
|
||||||
|
openAsHidden = true;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1118,7 +1130,10 @@ app.whenReady().then(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ipcMain.on("siyuan-auto-launch", (event, data) => {
|
ipcMain.on("siyuan-auto-launch", (event, data) => {
|
||||||
app.setLoginItemSettings({openAtLogin: data.openAtLogin});
|
app.setLoginItemSettings({
|
||||||
|
openAtLogin: data.openAtLogin,
|
||||||
|
args: data.openAsHidden ? ["--openAsHidden"] : ""
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (firstOpen) {
|
if (firstOpen) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {fetchPost} from "../util/fetch";
|
||||||
import {setAccessAuthCode} from "./util/about";
|
import {setAccessAuthCode} from "./util/about";
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
import {exitSiYuan, processSync} from "../dialog/processSystem";
|
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 {showMessage} from "../dialog/message";
|
||||||
import {Dialog} from "../dialog";
|
import {Dialog} from "../dialog";
|
||||||
import {confirmDialog} from "../dialog/confirmDialog";
|
import {confirmDialog} from "../dialog/confirmDialog";
|
||||||
|
|
@ -25,7 +25,7 @@ export const about = {
|
||||||
<select class="b3-select fn__flex-center fn__size200" id="autoLaunch">
|
<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="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="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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore || window.siyuan.config.system.container !== "std" ? " fn__none" : ""}">
|
<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)
|
const autoLaunchMode = parseInt(autoLaunchElement.value)
|
||||||
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchMode}, () => {
|
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchMode}, () => {
|
||||||
window.siyuan.config.system.autoLaunch2 = 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
|
/// #endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue