Skip to content

Commit 9e80ce7

Browse files
committed
refactor: 增加保持文档参数
1 parent 75a9372 commit 9e80ce7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/BootstrapBlazor.EmbedPDF/EmbedPDF.razor.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,25 @@ export async function init(id, invoke, options) {
6262
}
6363
}
6464

65-
export async function setUrl(id, url) {
65+
export async function setUrl(id, url, keepCurrentDoc) {
6666
const pdf = Data.get(id);
6767
const { viewer } = pdf;
6868

6969
if (viewer) {
7070
const registry = await viewer.registry;
7171
const docManager = registry.getPlugin('document-manager').provides();
72+
if (!keepCurrentDoc) {
73+
const doc = docManager.getActiveDocument();
74+
if (doc) {
75+
docManager.closeDocument(doc.id).toPromise();
76+
}
77+
}
7278
const name = getFileName(url);
7379
docManager.openDocumentUrl({
7480
url,
7581
name,
76-
documentId: name,
7782
autoActivate: true
78-
});
83+
}).toPromise();
7984
}
8085
}
8186

0 commit comments

Comments
 (0)