Skip to content

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

:bug: https://github.com/siyuan-note/siyuan/issues/11939

Vanessa9cc9a2862aa7
diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts
index c22eb5640a..8f9912199e 100644
--- a/app/src/boot/onGetConfig.ts
+++ b/app/src/boot/onGetConfig.ts
@@ -230,6 +230,9 @@ export const initWindow = async (app: App) => {
});
}
ipcRenderer.on(Constants.SIYUAN_OPEN_FILE, (event, data) => {
+ if (!data.app) {
+ data.app = app;
+ }
openFile(data);
});
ipcRenderer.on(Constants.SIYUAN_SAVE_CLOSE, (event, close) => {
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index 03e34e2439..eb633fafe5 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -198,8 +198,12 @@ export const openFile = async (options: IOpenFileOptions) => {
// https://github.com/siyuan-note/siyuan/issues/7491
if (!options.position) {
let hasMatch = false;
- const optionsClone = Object.assign({}, options);
- delete optionsClone.app; // 防止 JSON.stringify 时产生递归
+ const optionsClone: IObject = {};
+ Object.keys(options).forEach((key: keyof IOpenFileOptions) => {
+ if (key !== "app" && options[key] && typeof options[key] !== "function") {
+ optionsClone[key] = JSON.parse(JSON.stringify(options[key]));
+ }
+ });
hasMatch = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
cmd: Constants.SIYUAN_OPEN_FILE,
options: JSON.stringify(optionsClone),