An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/7803
Vanessaddfaf6bdba85
diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex b4ac3a577d..f9e4c503b7 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -124,6 +124,9 @@ const openFile = (options: IOpenFileOptions) => {if ((jsonObj.children.rootId && jsonObj.children.rootId === options.rootID) ||(jsonObj.children.path && jsonObj.children.path === options.assetPath)) {item.focus();+ if (options.assetPath) {+ item.webContents.executeJavaScript(`window.newWindow.positionPDF("${options.assetPath}", ${typeof options.page === "number" ? options.page : `"${options.page}"`})`);+ }hasOpen = true;return true;}diff --git a/app/src/protyle/method.ts b/app/src/protyle/method.tsindex 8bc7d77168..92a5b949dc 100644--- a/app/src/protyle/method.ts+++ b/app/src/protyle/method.ts@@ -31,7 +31,6 @@ class Protyle {public static plantumlRender = plantumlRender;}-// @ts-ignore// 由于 https://github.com/siyuan-note/siyuan/issues/7800,先临时解决一下window.Protyle = Protyle;diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex ff82c981d0..d038c73f32 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -31,8 +31,6 @@ type TBazaarType = "templates" | "icons" | "widgets" | "themes"declare module "blueimp-md5"interface Window {- __localStorage__removeItem: (key: string) => void- __localStorage__setItem: (key: string, value: string) => voiddataLayer: any[]siyuan: ISiyuanwebkit: any@@ -47,6 +45,12 @@ interface Window {getBlockURL(): string}+ newWindow: {+ positionPDF(pathStr: string, page: string | number): void+ }++ Protyle: import("../protyle/method").default+goBack(): voidshowKeyboardToolbar(height: number): void@@ -609,7 +613,7 @@ declare interface IBlockTree {}declare interface IBlock {- riffCardReps? :number // 闪卡复习次数+ riffCardReps?: number // 闪卡复习次数depth?: number,box?: string;path?: string;diff --git a/app/src/window/global/positionPDF.ts b/app/src/window/global/positionPDF.tsnew file mode 100644index 0000000000..8b4cd5f482--- /dev/null+++ b/app/src/window/global/positionPDF.ts@@ -0,0 +1,11 @@+import {getAllTabs} from "../../layout/getAll";+import {Asset} from "../../asset";++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);+ }+ })+}diff --git a/app/src/window/index.ts b/app/src/window/index.tsindex 3ff7275f52..3144265cbe 100644--- a/app/src/window/index.ts+++ b/app/src/window/index.ts@@ -20,6 +20,7 @@ import {initMessage} from "../dialog/message";import {getAllTabs} from "../layout/getAll";import {getLocalStorage} from "../protyle/util/compatibility";import {init} from "../window/init";+import {positionPDF} from "./global/positionPDF";class App {constructor() {@@ -141,3 +142,8 @@ class App {}new App();++// 再次点击新窗口已打开的 PDF 时,需进行定位+window.newWindow = {+ positionPDF: positionPDF+}