Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/7491

Vanessa5c2cc2778544
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index 41319684fd..0ba6023b52 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -14,6 +14,7 @@ import {focusBlock, focusByRange} from "../protyle/util/selection";
import {onGet} from "../protyle/util/onGet";
/// #if !BROWSER
import {shell} from "electron";
+import {BrowserWindow} from "@electron/remote";
/// #endif
import {pushBack} from "../util/backForward";
import {Asset} from "../asset";
@@ -23,6 +24,7 @@ import {setTitle} from "../dialog/processSystem";
import {zoomOut} from "../menus/protyle";
import {countBlockWord, countSelectWord} from "../layout/status";
import {showMessage} from "../dialog/message";
+import {getSearch} from "../util/functions";
export const openFileById = (options: {
id: string,
@@ -112,6 +114,26 @@ const openFile = (options: IOpenFileOptions) => {
}
}
+ let hasOpen = false;
+ /// #if !BROWSER
+ // https://github.com/siyuan-note/siyuan/issues/7491
+ BrowserWindow.getAllWindows().find((item) => {
+ const json = getSearch("json", new URL(item.webContents.getURL()).search)
+ if (json) {
+ const jsonObj = JSON.parse(json);
+ if ((jsonObj.children.rootId && jsonObj.children.rootId === options.rootID) ||
+ (jsonObj.children.path && jsonObj.children.path === options.assetPath)) {
+ item.focus();
+ hasOpen = true;
+ return true;
+ }
+ }
+ });
+ /// #endif
+ if (hasOpen) {
+ return;
+ }
+
let wnd: Wnd = undefined;
// 获取光标所在 tab
const element = document.querySelector(".layout__wnd--active");