Browse Source

【UI替换】主页 - 最近列表删除警告框添加

lizhe 1 year ago
parent
commit
ab2fe6a12b

+ 0 - 2
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -299,7 +299,6 @@ extension KMHomeViewController {
     }
     
     func historyFileDeleteAction(_ indexPaths: [URL]) -> Void {
-//        NSDocumentController.shared.clearRecentDocuments(nil)
         let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
         NSDocumentController.shared.clearRecentDocuments(nil)
         DispatchQueue.main.asyncAfter(deadline: .now()) { [self] in
@@ -311,7 +310,6 @@ extension KMHomeViewController {
             
             self.homeContentView.historyListView.reloadData()
         }
-//        historyFileViewController.reloadData()
     }
     
     func openHistoryFilePath(url: URL) -> Void {

+ 12 - 2
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -194,8 +194,18 @@ import Cocoa
         }
         
         self.homeContentView.historyRemoveAllFileAction = { [unowned self] view in
-            let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
-            self.historyFileDeleteAction(urls)
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = String(format: "%@?", NSLocalizedString("Clear All Recents", comment: ""))
+            alert.addButton(withTitle: NSLocalizedString("Delete", comment: ""))
+            alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
+
+            alert.beginSheetModal(for: self.view.window!) { response in
+                if response == .alertFirstButtonReturn {
+                    let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
+                    self.historyFileDeleteAction(urls)
+                }
+            }
         }
         
         //quciktools