Przeglądaj źródła

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

niehaoyu 6 miesięcy temu
rodzic
commit
a960b3d037

+ 1 - 2
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.swift

@@ -60,8 +60,7 @@ class KMHomeHistoryListView: KMBaseXibView {
         self.data.removeAll()
         for url in NSDocumentController.shared.recentDocumentURLs {
             if FileManager.default.fileExists(atPath: url.path) {
-                let file = KMFile()
-                file.filePath = url.path
+                let file = KMFileManager.manager.fetchFile(filePath: url.path)
                 self.data.append(file)
             }
         }

+ 16 - 1
PDF Office/PDF Master/Class/KMFileManager/KMFileManager.swift

@@ -8,5 +8,20 @@
 import Cocoa
 
 class KMFileManager: NSObject {
-
+    static let manager = KMFileManager()
+    
+    var files: [KMFile] = []
+    
+    func fetchFile(filePath: String) -> KMFile {
+        for file in files {
+            if file.filePath == filePath {
+                return file
+            }
+        }
+        
+        let file = KMFile()
+        file.filePath = filePath
+        self.files.append(file)
+        return file
+    }
 }