Просмотр исходного кода

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

niehaoyu 1 месяц назад
Родитель
Сommit
6cafcc9278

+ 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)
     }

+ 12 - 8
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableView.swift

@@ -233,6 +233,7 @@ extension KMBatchProcessingTableView: NSTableViewDelegate {
             if (self.data!.count > row) {
                 let model = self.data![row]
                 model.type = self.inputType
+                model.row = row + 1
                 cell!.model = model
             }
         }
@@ -244,7 +245,8 @@ extension KMBatchProcessingTableView: NSTableViewDelegate {
         let tableRowView = KMBatchProcessingTableRowView()
         tableRowView.selectionHighlightStyle = .none
         tableRowView.model = self.data?[row]
-        tableRowView.hoverCallback = { [unowned self] (mouseEntered, mouseBox) in
+        tableRowView.hoverCallback = { [weak self] (mouseEntered, mouseBox) in
+            guard let self = self else { return }
             if data != nil {
                 for i in 0...self.data!.count - 1 {
                     let model = self.data![i]
@@ -277,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)
@@ -474,12 +478,12 @@ extension KMBatchProcessingTableView: NSTableViewDataSource {
             if info.draggingSource as? NSTableView == tableView {
                 
                 //移除物件悬浮状态
-                if data != nil {
-                    let model = self.data![rowIndexes.firstIndex]
-                    model.hover = false
-                    let columnIndex = self.tableView.column(withIdentifier: NSUserInterfaceItemIdentifier(KMBatchProcessingTableViewOptions.delete.rawValue.description))
-                    self.tableView.reloadData(forRowIndexes: rowIndexes as IndexSet, columnIndexes: IndexSet(integer: columnIndex))
-                }
+//                if data != nil {
+//                    let model = self.data![rowIndexes.firstIndex]
+//                    model.hover = false
+//                    let columnIndex = self.tableView.column(withIdentifier: NSUserInterfaceItemIdentifier(KMBatchProcessingTableViewOptions.delete.rawValue.description))
+//                    self.tableView.reloadData(forRowIndexes: rowIndexes as IndexSet, columnIndexes: IndexSet(integer: columnIndex))
+//                }
                 
                 //数据处理
                 self.data!.move(with: IndexSet(rowIndexes), to: row)

+ 1 - 0
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableViewModel/KMBatchProcessingTableViewModel.swift

@@ -58,6 +58,7 @@ class KMBatchProcessingTableViewModel: NSObject {
     var isLock: Bool = false 
     var password: String = ""
     var permissionPassword: String = ""
+    var row: Int = 1
     
     var type: KMBatchCollectionViewType = .convertPDF
     

+ 1 - 1
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/Views/Tableview/Views/KMBatchProcessingNumTableCell.swift

@@ -57,6 +57,6 @@ class KMBatchProcessingNumTableCell: KMBatchProcessingTableCell {
     
     
     override func reloadData() {
-
+        self.titleLabel.stringValue = self.model.row.description
     }
 }