Browse Source

fix: 内容编辑后修复无法预览bug

liutian 2 weeks ago
parent
commit
a572a4ee6a

+ 1 - 2
packages/core/src/index.js

@@ -553,7 +553,7 @@ class ComPDFKitViewer {
     // }
 
     // 处理传入的PDF
-    return await loadingTask.promise.then(
+    return loadingTask.promise.then(
       async pdfDocument => {
         // 上传pdf
         await pdfDocument.getData().then(async (binaryData) => {
@@ -3696,7 +3696,6 @@ class ComPDFKitViewer {
 
       const newUrl = URL.createObjectURL(blobData)
       if (this.saveAction === 'set' && this.#oldPwd !== this.#pwd) this.#oldPwd = this.#pwd
-      await this.loadDocument(newUrl, { filename, notUpdatePwd: true })
       await clearDocument()
       return newUrl
     }

+ 1 - 1
packages/core/src/pdf_viewer.js

@@ -1173,7 +1173,7 @@ class PDFViewer {
     allowNegativeOffset = false,
     ignoreDestinationZoom = false,
   }) {
-    if (!this.pdfDocument) {
+    if (!this.pdfDocument || (this._pages && !this._pages.length)) {
       return;
     }
     const pageView =

+ 5 - 2
packages/webview/src/components/DocumentEditorHeader/DocumentEditorHeader.vue

@@ -45,8 +45,11 @@ const save = async () => {
   useViewer.setUploadLoading(true)
   const oldScale = useViewer.getScale
 
-  const { newUrl } = await core.saveDocumentEdit()
-  
+  const newUrl = await core.saveDocumentEdit()
+  const pwd = useDocument.getPassword
+  await core.loadDocument(newUrl, {
+    password: pwd
+  })
   useDocument.setCurrentPdfData(newUrl)
   const totalPages = core.getPagesCount()
   useDocument.setTotalPages(totalPages)