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/17212

Vanessab78b19d1c193
diff --git a/app/electron/main.js b/app/electron/main.js
index a50e5125c8..31b1375b16 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -441,22 +441,9 @@ const initMainWindow = () => {
net.fetch(getServer() + "/api/system/getNetwork", {method: "POST"}).then((response) => {
return response.json();
}).then((response) => {
- setProxy(`${response.data.proxy.scheme}://${response.data.proxy.host}:${response.data.proxy.port}`, currentWindow.webContents).then(async () => {
+ setProxy(`${response.data.proxy.scheme}://${response.data.proxy.host}:${response.data.proxy.port}`, currentWindow.webContents).then(() => {
// 加载主界面
- await currentWindow.loadURL(getServer() + "/stage/build/app/?v=" + new Date().getTime());
- if (isOpenAsHidden()) {
- currentWindow.minimize();
- } else {
- currentWindow.show();
- if (windowState.isMaximized) {
- currentWindow.maximize();
- } else {
- currentWindow.unmaximize();
- }
- }
- if (bootWindow && !bootWindow.isDestroyed()) {
- bootWindow.destroy();
- }
+ currentWindow.loadURL(getServer() + "/stage/build/app/?v=" + new Date().getTime());
});
});
@@ -544,6 +531,21 @@ const initMainWindow = () => {
workspaces.push({
browserWindow: currentWindow,
});
+ ipcMain.once("siyuan-ready-to-show", () => {
+ if (isOpenAsHidden()) {
+ currentWindow.minimize();
+ } else {
+ currentWindow.show();
+ if (windowState.isMaximized) {
+ currentWindow.maximize();
+ } else {
+ currentWindow.unmaximize();
+ }
+ }
+ if (bootWindow && !bootWindow.isDestroyed()) {
+ bootWindow.destroy();
+ }
+ });
};
const showWindow = (wnd) => {
@@ -1311,7 +1313,6 @@ app.whenReady().then(() => {
args: data.openAsHidden ? ["--openAsHidden"] : ""
});
});
-
if (firstOpen) {
const firstOpenWindow = new BrowserWindow({
width: Math.floor(screen.getPrimaryDisplay().size.width * 0.6),
@@ -1528,7 +1529,6 @@ app.on("before-quit", (event) => {
});
});
-
function writeLog(out) {
console.log(out);
const logFile = path.join(confDir, "app.log");
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 5b985dcbbb..fe516c81dd 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -42,6 +42,7 @@ export abstract class Constants {
public static readonly SIYUAN_QUIT: string = "siyuan-quit";
public static readonly SIYUAN_HOTKEY: string = "siyuan-hotkey";
public static readonly SIYUAN_INIT: string = "siyuan-init";
+ public static readonly SIYUAN_READY_TO_SHOW: string = "siyuan-ready-to-show";
public static readonly SIYUAN_SEND_WINDOWS: string = "siyuan-send-windows"; // 主窗口和各新窗口之间的通信,{cmd: "closetab"|"lockscreen"|"lockscreenByMode", data: {}})
public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close";
public static readonly SIYUAN_AUTO_LAUNCH: string = "siyuan-auto-launch";
diff --git a/app/src/index.ts b/app/src/index.ts
index 9b615d62e1..763c3b6af8 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -35,6 +35,8 @@ import {reloadEmoji} from "./emoji";
import {processIOSPurchaseResponse} from "./util/iOSPurchase";
/// #if BROWSER
import {setLocalShorthandCount} from "./util/noRelyPCFunction";
+/// #else
+import {ipcRenderer} from "electron";
/// #endif
import {getDockByType} from "./layout/tabUtil";
import {Tag} from "./layout/dock/Tag";
@@ -255,4 +257,6 @@ window.showKeyboardToolbar = () => {
// 防止 Pad 端报错
};
window.processIOSPurchaseResponse = processIOSPurchaseResponse;
+/// #else
+ipcRenderer.send(Constants.SIYUAN_READY_TO_SHOW);
/// #endif