Ver código fonte

【2025】【Tools】批量处理,转档,每转档成功一个文档,就会自动弹出来一个Finder文件夹 - 修复

lizhe 1 mês atrás
pai
commit
79e64a83a1

+ 12 - 9
PDF Office/PDF Master/KMClass/NewBatch/Manager/KMBatchManager.swift

@@ -21,6 +21,8 @@ class KMBatchManager: NSObject {
     public static let manager = KMBatchManager()
     fileprivate(set) var state: KMBatchManagerSate = .unknow
     
+    var outputFolderPath: String = ""
+    
     var filesData: [KMBatchProcessingTableViewModel] = []
     var batchFilesData: [KMBatchProcessingTableViewModel] {
         get {
@@ -45,8 +47,10 @@ class KMBatchManager: NSObject {
             }
             
             let outputFolderPath = (panel.url?.path)!
+            self.outputFolderPath = outputFolderPath
             //
             self.batchUnkown()
+            self.batchProgress()
             switch type {
             case .convertPDF:
                 self.convertPDFExport(data: data, outputFolderPath: outputFolderPath)
@@ -131,9 +135,6 @@ extension KMBatchManager {
                 self.itemProgress(item: item, processValue: progress)
             }, completion: { [unowned self] finished, error in
                 if finished {
-                    if FileManager.default.fileExists(atPath: outputFolderPath) {
-                        NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: outputFolderPath)])
-                    }
                     self.itemSuccess(item: item)
                 } else {
                     self.itemFailure(item: item, error: error! as NSError)
@@ -387,7 +388,6 @@ extension KMBatchManager {
                     
                     if i == filesData.count - 1 {
                         self.batchSuccess()
-                        NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: outputFolderPath)])
                     }
                 }
             }
@@ -438,7 +438,6 @@ extension KMBatchManager {
                 if i == filesData.count - 1 {
                     self.batchSuccess()
                 }
-                NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
             }
         }
     }
@@ -490,7 +489,6 @@ extension KMBatchManager {
                 if i == filesData.count - 1 {
                     self.batchSuccess()
                 }
-                NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
             }
         }
     }
@@ -539,7 +537,6 @@ extension KMBatchManager {
                 if i == filesData.count - 1 {
                     self.batchSuccess()
                 }
-                NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
             }
         }
     }
@@ -588,7 +585,6 @@ extension KMBatchManager {
                 if i == filesData.count - 1 {
                     self.batchSuccess()
                 }
-                NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
             }
         }
     }
@@ -652,7 +648,6 @@ extension KMBatchManager {
                         if i == filesData.count - 1 {
                             self.batchSuccess()
                         }
-                        NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: outputFolderPath)])
                     }
 //                }
             }
@@ -934,11 +929,19 @@ extension KMBatchManager {
     }
     
     func batchSuccess() {
+        if FileManager.default.fileExists(atPath: self.outputFolderPath) {
+            NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: self.outputFolderPath)])
+        }
+        
         self.state = .complete
         NotificationCenter.default.post(name: NSNotification.Name(kBacthProcessNotification), object: nil)
     }
     
     func batchFailure() {
+        if FileManager.default.fileExists(atPath: self.outputFolderPath) {
+            NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: self.outputFolderPath)])
+        }
+        
         self.state = .error
         NotificationCenter.default.post(name: NSNotification.Name(kBacthProcessNotification), object: nil)
     }

+ 3 - 1
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableView.swift

@@ -279,7 +279,9 @@ extension KMBatchProcessingTableView: NSTableViewDelegate {
         }
 
         tableRowView.rightMouseCallback = { [unowned self] (view, event) in
-//            self.didSelectItem(shouldSelectRow: row)
+            if self.selectModels.count <= 1 {
+                self.didSelectItem(shouldSelectRow: row)
+            }
             DispatchQueue.main.async {
                 if self.tableView.rowView(atRow: row, makeIfNecessary: false) != nil {
                     let rowView = self.tableView.rowView(atRow: row, makeIfNecessary: false)