Browse Source

综合 - 历史文件列表注释掉根据最后修改日期筛选的逻辑

wanjun 1 year ago
parent
commit
71a94648eb

+ 19 - 18
PDF Office/PDF Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift

@@ -444,24 +444,25 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
             }
         }
         
-        if self.files.count > 0 {
-            var dateArray: [Int: URL] = [:]
-            for index in 0..<self.files.count {
-                let url = self.files[index]
-                let attrib = try? FileManager.default.attributesOfItem(atPath: url.path) as? Dictionary<FileAttributeKey , Any>
-                let fileDate: Date = attrib![FileAttributeKey(rawValue: "NSFileModificationDate")] as! Date
-                let timeInterval = fileDate.timeIntervalSince1970
-                dateArray.updateValue(url, forKey: Int(timeInterval))
-            }
-
-            let sortedKeys = dateArray.keys.sorted(by: >)
-
-            files.removeAll()
-            for key in sortedKeys {
-                files.append(dateArray[key]!)
-                print("\(key): \(dateArray[key]!)")
-            }
-        }
+        //考虑多个文件时如果筛选最后修改时间,那刚开启的文件可能在列表其他的位置
+//        if self.files.count > 0 {
+//            var dateArray: [Int: URL] = [:]
+//            for index in 0..<self.files.count {
+//                let url = self.files[index]
+//                let attrib = try? FileManager.default.attributesOfItem(atPath: url.path) as? Dictionary<FileAttributeKey , Any>
+//                let fileDate: Date = attrib![FileAttributeKey(rawValue: "NSFileModificationDate")] as! Date
+//                let timeInterval = fileDate.timeIntervalSince1970
+//                dateArray.updateValue(url, forKey: Int(timeInterval))
+//            }
+//
+//            let sortedKeys = dateArray.keys.sorted(by: >)
+//
+//            files.removeAll()
+//            for key in sortedKeys {
+//                files.append(dateArray[key]!)
+//                print("\(key): \(dateArray[key]!)")
+//            }
+//        }
         
         let fileNumber = KMPreferenceManager.shared.getData(forKey: KMPreference.documentMaximunDisplayNumberKey) as? Int ?? 10
         if fileNumber <= files.count {