Browse Source

:rotating_light:

Vanessa 2 năm trước cách đây
mục cha
commit
9531bdd01c
1 tập tin đã thay đổi với 15 bổ sung12 xóa
  1. 15 12
      app/src/asset/renderAssets.ts

+ 15 - 12
app/src/asset/renderAssets.ts

@@ -19,21 +19,24 @@ export const renderAssetsPreview = (pathString: string) => {
 };
 
 export const pdfResize = () => {
-    getAllModels().asset.find(item => {
-        const pdfInstance = item.pdfObject
-        const {pdfDocument, pdfViewer} = pdfInstance
+    getAllModels().asset.forEach(item => {
+        const pdfInstance = item.pdfObject;
+        if (!pdfInstance) {
+            return;
+        }
+        const {pdfDocument, pdfViewer} = pdfInstance;
         if (!pdfDocument) {
-            return
+            return;
         }
-        const currentScaleValue = pdfViewer.currentScaleValue
+        const currentScaleValue = pdfViewer.currentScaleValue;
         if (
-            currentScaleValue === 'auto' ||
-            currentScaleValue === 'page-fit' ||
-            currentScaleValue === 'page-width'
+            currentScaleValue === "auto" ||
+            currentScaleValue === "page-fit" ||
+            currentScaleValue === "page-width"
         ) {
             // Note: the scale is constant for 'page-actual'.
-            pdfViewer.currentScaleValue = currentScaleValue
+            pdfViewer.currentScaleValue = currentScaleValue;
         }
-        pdfViewer.update()
-    })
-}
+        pdfViewer.update();
+    });
+};