Parcourir la source

【2025】【综合】记录PDFView相关数据

niehaoyu il y a 1 mois
Parent
commit
31a9857c05

+ 23 - 14
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -485,7 +485,20 @@ struct KMNMWCFlags {
         } else if layoutType == .bookModeContinue {
             self.updatePDFViewDisplayMode(isbookMode: true, direction: .vertical)
         }
-         
+        
+        if self.listView.document != nil {
+            if let pageIndex = KMPreferenceManager.shared.getPageNumber(forKey: self.listView.document.documentURL.path) {
+                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) {
+                    self.listView.go(toPageIndex: pageIndex, animated: false)
+                }
+            }
+            if let scale = KMPreferenceManager.shared.getPageScale(forKey: self.listView.document.documentURL.path) {
+                self.listView.scaleFactor = CGFloat(scale)
+            } else {
+                let zoomType = SettingsManager.sharedInstance.zoomType
+                self.refreshPDFViewZoomInfo(zoomType)
+            }
+        }
     }
     
     func refreshPDFViewZoomInfo(_ zoomType: zoomInfoType) {
@@ -546,10 +559,6 @@ struct KMNMWCFlags {
         
         reloadPDFSplitInfo()
         
-        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) {
-            let zoomType = SettingsManager.sharedInstance.zoomType
-            self.refreshPDFViewZoomInfo(zoomType)
-        }
     }
     
     func updatePDFViewAnnotationMode() {
@@ -1607,15 +1616,15 @@ struct KMNMWCFlags {
     }
     
     func savePageNumberIfNeed() {
-       
-            let scaleFactor = self.listView.scaleFactor ?? 0
-            if scaleFactor <= 0 {
-                return
-            }
-            if self.listView.document != nil {
-                KMPreferenceManager.shared.setPageNumber(self.listView.currentPageIndex, forKey: self.listView.document.documentURL.path)
-                KMPreferenceManager.shared.setPageScale(Float(self.listView.scaleFactor), forKey: self.listView.document.documentURL.path)
-            } 
+        
+        let scaleFactor = self.listView.scaleFactor
+        if scaleFactor <= 0 {
+            return
+        }
+        if self.listView.document != nil {
+            KMPreferenceManager.shared.setPageNumber(self.listView.currentPageIndex, forKey: self.listView.document.documentURL.path)
+            KMPreferenceManager.shared.setPageScale(Float(scaleFactor), forKey: self.listView.document.documentURL.path)
+        }
     }
     
     // MARK: - 显示加密弹窗