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

Vanessa233b64e85d95
diff --git a/app/electron/main.js b/app/electron/main.js
index da49292df8..d9fb18dcd4 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -667,8 +667,19 @@ app.whenReady().then(() => {
ipcMain.on("siyuan-show", (event) => {
showWindow(getWindowByContentId(event.sender.id));
});
- ipcMain.on("siyuan-hide", (event) => {
- getWindowByContentId(event.sender.id).hide();
+ ipcMain.on("siyuan-cmd", (event, cmd) => {
+ console.log(cmd)
+ switch (cmd) {
+ case "hide":
+ getWindowByContentId(event.sender.id).hide();
+ break;
+ case "redo":
+ event.sender.redo();
+ break;
+ case "undo":
+ event.sender.undo();
+ break;
+ }
});
ipcMain.on("siyuan-config-tray", (event, data) => {
workspaces.find(item => {
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 75bef5730d..2186ce79a5 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -25,7 +25,7 @@ export abstract class Constants {
// 渲染进程调主进程
public static readonly SIYUAN_SHOW: string = "siyuan-show";
- public static readonly SIYUAN_HIDE: string = "siyuan-hide";
+ public static readonly SIYUAN_CMD: string = "siyuan-cmd";
public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";
public static readonly SIYUAN_QUIT: string = "siyuan-quit";
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 5581732c96..09e93a16fa 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -199,7 +199,7 @@ export const exitSiYuan = () => {
// 桌面端退出拉起更新安装时有时需要重启两次 https://github.com/siyuan-note/siyuan/issues/6544
// 这里先将主界面隐藏
setTimeout(() => {
- ipcRenderer.send(Constants.SIYUAN_HIDE);
+ ipcRenderer.send(Constants.SIYUAN_CMD, "hide");
}, 2000);
// 然后等待一段时间后再退出,避免界面主进程退出以后内核子进程被杀死
setTimeout(() => {
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index de901758d0..f3d5ce62e8 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -10,7 +10,7 @@ import {
openFileAttr,
} from "../../menus/commonMenuItem";
/// #if !BROWSER
-import {getCurrentWindow} from "@electron/remote";
+import { ipcRenderer } from "electron";
/// #endif
import {Constants} from "../../constants";
import {matchHotKey} from "../util/hotKey";
@@ -99,13 +99,13 @@ export class Title {
}
/// #if !BROWSER
if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {
- getCurrentWindow().webContents.undo();
+ ipcRenderer.send(Constants.SIYUAN_CMD, "undo");
event.preventDefault();
event.stopPropagation();
return;
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {
- getCurrentWindow().webContents.redo();
+ ipcRenderer.send(Constants.SIYUAN_CMD, "redo");
event.preventDefault();
event.stopPropagation();
return;