mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 04:31:50 +08:00
This commit is contained in:
parent
42dc3712c1
commit
ddfaf6bdba
@ -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;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class Protyle {
|
||||
public static plantumlRender = plantumlRender;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
// 由于 https://github.com/siyuan-note/siyuan/issues/7800,先临时解决一下
|
||||
window.Protyle = Protyle;
|
||||
|
||||
|
10
app/src/types/index.d.ts
vendored
10
app/src/types/index.d.ts
vendored
@ -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) => void
|
||||
dataLayer: any[]
|
||||
siyuan: ISiyuan
|
||||
webkit: any
|
||||
@ -47,6 +45,12 @@ interface Window {
|
||||
getBlockURL(): string
|
||||
}
|
||||
|
||||
newWindow: {
|
||||
positionPDF(pathStr: string, page: string | number): void
|
||||
}
|
||||
|
||||
Protyle: import("../protyle/method").default
|
||||
|
||||
goBack(): void
|
||||
|
||||
showKeyboardToolbar(height: number): void
|
||||
@ -609,7 +613,7 @@ declare interface IBlockTree {
|
||||
}
|
||||
|
||||
declare interface IBlock {
|
||||
riffCardReps? :number // 闪卡复习次数
|
||||
riffCardReps?: number // 闪卡复习次数
|
||||
depth?: number,
|
||||
box?: string;
|
||||
path?: string;
|
||||
|
11
app/src/window/global/positionPDF.ts
Normal file
11
app/src/window/global/positionPDF.ts
Normal file
@ -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);
|
||||
}
|
||||
})
|
||||
}
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user