An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Unable to start on some Linux desktop distributions https://github.com/siyuan-note/siyuan/issues/9347
Danielc91bdc8fa0c0
diff --git a/app/electron/main.js b/app/electron/main.jsindex e5250671fb..9342d59ee0 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -15,7 +15,7 @@// along with this program. If not, see <https://www.gnu.org/licenses/>.const {- net, app, BrowserWindow, shell, Menu, screen, ipcMain, globalShortcut, Tray, dialog, systemPreferences+ net, app, BrowserWindow, shell, Menu, screen, ipcMain, globalShortcut, Tray, dialog, systemPreferences, powerMonitor} = require("electron");const path = require("path");const fs = require("fs");@@ -633,13 +633,11 @@ app.whenReady().then(() => {const contextMenu = Menu.buildFromTemplate(trayMenuTemplate);tray.setContextMenu(contextMenu);};-const hideWindow = (wnd) => {// 通过 `Alt+M` 最小化后焦点回到先前的窗口 https://github.com/siyuan-note/siyuan/issues/7275wnd.minimize();wnd.hide();};-const showHideWindow = (tray, lang, mainWindow) => {if (!mainWindow.isVisible()) {if (mainWindow.isMinimized()) {@@ -655,6 +653,7 @@ app.whenReady().then(() => {const getWindowByContentId = (id) => {return BrowserWindow.fromId(BrowserWindow.getAllWindows().find((win) => win.webContents.id === id).id)};+ipcMain.on("siyuan-open-folder", (event, filePath) => {shell.showItemInFolder(filePath);});@@ -1066,6 +1065,54 @@ app.whenReady().then(() => {}});}++ // 电源相关事件必须放在 whenReady 里面,否则会导致 Linux 端无法正常启动 Trace/breakpoint trap (core dumped) https://github.com/siyuan-note/siyuan/issues/9347+ powerMonitor.on("suspend", () => {+ writeLog("system suspend");+ });+ powerMonitor.on("resume", async () => {+ // 桌面端系统休眠唤醒后判断网络连通性后再执行数据同步 https://github.com/siyuan-note/siyuan/issues/6687+ writeLog("system resume");++ const isOnline = async () => {+ return net.isOnline();+ };+ let online = false;+ for (let i = 0; i < 7; i++) {+ if (await isOnline()) {+ online = true;+ break;+ }++ writeLog("network is offline");+ await sleep(1000);+ }++ if (!online) {+ writeLog("network is offline, do not sync after system resume");+ return;+ }++ workspaces.forEach(item => {+ const currentURL = new URL(item.browserWindow.getURL());+ const server = getServer(currentURL.port);+ writeLog("sync after system resume [" + server + "/api/sync/performSync" + "]");+ net.fetch(server + "/api/sync/performSync", {method: "POST"});+ });+ });+ powerMonitor.on("shutdown", () => {+ writeLog("system shutdown");+ workspaces.forEach(item => {+ const currentURL = new URL(item.browserWindow.getURL());+ net.fetch(getServer(currentURL.port) + "/api/system/exit", {method: "POST"});+ });+ });+ powerMonitor.on("lock-screen", () => {+ writeLog("system lock-screen");+ BrowserWindow.getAllWindows().forEach(item => {+ item.webContents.send("siyuan-send-windows", {cmd: "lockscreenByMode"});+ });+ });});app.on("open-url", (event, url) => { // for macOS@@ -1152,56 +1199,3 @@ app.on("before-quit", (event) => {}});});--const {powerMonitor} = require("electron");--powerMonitor.on("suspend", () => {- writeLog("system suspend");-});--powerMonitor.on("resume", async () => {- // 桌面端系统休眠唤醒后判断网络连通性后再执行数据同步 https://github.com/siyuan-note/siyuan/issues/6687- writeLog("system resume");-- const isOnline = async () => {- return net.isOnline();- };- let online = false;- for (let i = 0; i < 7; i++) {- if (await isOnline()) {- online = true;- break;- }-- writeLog("network is offline");- await sleep(1000);- }-- if (!online) {- writeLog("network is offline, do not sync after system resume");- return;- }-- workspaces.forEach(item => {- const currentURL = new URL(item.browserWindow.getURL());- const server = getServer(currentURL.port);- writeLog("sync after system resume [" + server + "/api/sync/performSync" + "]");- net.fetch(server + "/api/sync/performSync", {method: "POST"});- });-});--powerMonitor.on("shutdown", () => {- writeLog("system shutdown");- workspaces.forEach(item => {- const currentURL = new URL(item.browserWindow.getURL());- net.fetch(getServer(currentURL.port) + "/api/system/exit", {method: "POST"});- });-});---powerMonitor.on("lock-screen", () => {- writeLog("system lock-screen");- BrowserWindow.getAllWindows().forEach(item => {- item.webContents.send("siyuan-send-windows", {cmd: "lockscreenByMode"});- });-});