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: fix https://github.com/siyuan-note/siyuan/issues/9149
Vanessa7e8e6167ffb7
diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 0db465187c..c20f3673c2 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -180,12 +180,10 @@ export const openFile = (options: IOpenFileOptions) => {}const ids = decodeURIComponent(new URL(item.webContents.getURL()).hash.substring(1)).split(Constants.ZWSP);if (ids.includes(options.rootID) || ids.includes(options.assetPath)) {- let execJS = `window.newWindow.switchTabById("${options.rootID || options.assetPath}");`;- if (options.assetPath) {- execJS += `window.newWindow.positionPDF("${options.assetPath}", ${typeof options.page === "number" ? options.page : `"${options.page}"`})`;- }item.focus();- item.webContents.executeJavaScript(execJS);+ const optionsClone = Object.assign({}, options);+ delete optionsClone.app+ item.webContents.executeJavaScript(`window.newWindow.openFile(${JSON.stringify(optionsClone)});`);if (options.afterOpen) {options.afterOpen();}diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 7d815287f5..bf7dfc9ba5 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -95,8 +95,7 @@ interface Window {}newWindow: {- positionPDF(pathStr: string, page: string | number): void- switchTabById(id: string): void+ openFile(options: IOpenFileOptions): void}Protyle: import("../protyle/method").defaultdiff --git a/app/src/window/global/function.ts b/app/src/window/global/function.tsdeleted file mode 100644index da57d9ee05..0000000000--- a/app/src/window/global/function.ts+++ /dev/null@@ -1,37 +0,0 @@-import {getAllTabs} from "../../layout/getAll";-import {Asset} from "../../asset";-import {Editor} from "../../editor";--export const positionPDF = (pathStr: string, page: string | number) => {- getAllTabs().forEach((tab) => {- if (tab.model instanceof Asset && tab.model.pdfObject && tab.model.path === pathStr) {- tab.parent.switchTab(tab.headElement);- tab.model.goToPage(page);- }- });-};--export const switchTabById = (id: string) => {- getAllTabs().find((tab) => {- if (!tab.model) {- const initTab = tab.headElement.getAttribute("data-initdata");- if (initTab) {- const initTabData = JSON.parse(initTab);- if (initTabData.instance === "Editor" && initTabData.rootId === id) {- tab.parent.switchTab(tab.headElement);- return true;- }- }- } else if (tab.model instanceof Editor) {- if (tab.model.editor.protyle.block.rootID === id) {- tab.parent.switchTab(tab.headElement);- return true;- }- } else if (tab.model instanceof Asset) {- if (tab.model.path === id) {- tab.parent.switchTab(tab.headElement);- return true;- }- }- });-};diff --git a/app/src/window/index.ts b/app/src/window/index.tsindex e153c97c1a..c9fd8f451e 100644--- a/app/src/window/index.ts+++ b/app/src/window/index.ts@@ -7,7 +7,7 @@ import {addScript, addScriptSync} from "../protyle/util/addScript";import {genUUID} from "../util/genID";import {fetchGet, fetchPost} from "../util/fetch";import {addBaseURL, setNoteBook} from "../util/pathName";-import {openFileById} from "../editor/util";+import {openFile, openFileById} from "../editor/util";import {processSync, progressBackgroundTask,progressLoading,@@ -19,7 +19,6 @@ import {initMessage} from "../dialog/message";import {getAllTabs} from "../layout/getAll";import {getLocalStorage} from "../protyle/util/compatibility";import {init} from "../window/init";-import {positionPDF, switchTabById} from "./global/function";import {loadPlugins} from "../plugin/loader";class App {@@ -152,6 +151,5 @@ new App();// 再次点击新窗口已打开的 PDF 时,需进行定位window.newWindow = {- positionPDF: positionPDF,- switchTabById: switchTabById+ openFile: openFile,};