Explorar el Código

【fix】【搜索】Search 搜索无结果时,不会有提示(替换窗口有提示)

tangchao hace 6 meses
padre
commit
38ab26123e

+ 23 - 7
PDF Office/PDF Master/Class/Tools/Search/Window/KMSearchReplaceWindowController.swift

@@ -196,7 +196,8 @@ class KMSearchReplaceWindowController: NSWindowController {
                     let alert = NSAlert()
                     alert.messageText = NSLocalizedString("No related content found, please change keyword.", comment: "")
                     alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                    alert.runModal()
+//                    alert.runModal()
+                    alert.beginSheetModal(for: (self.window)!)
                 }
             } else {
                 if self.finding_ {
@@ -216,7 +217,8 @@ class KMSearchReplaceWindowController: NSWindowController {
                             let alert = NSAlert()
                             alert.messageText = NSLocalizedString("No related content found, please change keyword.", comment: "")
                             alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                            alert.runModal()
+//                            alert.runModal()
+                            alert.beginSheetModal(for: (self.window)!)
                             return
                         }
                         self.currentSel = sel
@@ -244,7 +246,8 @@ class KMSearchReplaceWindowController: NSWindowController {
                     let alert = NSAlert()
                     alert.messageText = NSLocalizedString("No related content found, please change keyword.", comment: "")
                     alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                    alert.runModal()
+//                    alert.runModal()
+                    alert.beginSheetModal(for: (self.window)!)
                 }
             } else {
                 if self.finding_ {
@@ -265,7 +268,8 @@ class KMSearchReplaceWindowController: NSWindowController {
                             let alert = NSAlert()
                             alert.messageText = NSLocalizedString("No related content found, please change keyword.", comment: "")
                             alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                            alert.runModal()
+//                            alert.runModal()
+                            alert.beginSheetModal(for: (self.window)!)
                             return
                         }
                         self.currentSel = sel
@@ -321,7 +325,8 @@ class KMSearchReplaceWindowController: NSWindowController {
                         let alert = NSAlert()
                         alert.messageText = NSLocalizedString("No related content found, please change keyword.", comment: "")
                         alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                        alert.runModal()
+//                        alert.runModal()
+                        alert.beginSheetModal(for: (self.window)!)
                         return
                     }
                     self.currentSel = sel
@@ -344,7 +349,8 @@ class KMSearchReplaceWindowController: NSWindowController {
             alert.informativeText = NSLocalizedString("No related content found, please change keyword.", comment: "")
             alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
 //            alert.beginSheetModal(for: NSApp.mainWindow!)
-            alert.runModal()
+//            alert.runModal()
+            alert.beginSheetModal(for: (self.window)!)
             return
         }
         
@@ -549,6 +555,15 @@ extension KMSearchReplaceWindowController: NSTextFieldDelegate {
                         self._beginLoading()
                         self.handdler.search(keyword: self.searchInputView.stringValue, isCase: isCase, isWholeWord: isWholeWord, callback: { [weak self] datas in
                             self?._endLoading()
+
+                            guard let sels = datas, sels.isEmpty == false else {
+                                let alert = NSAlert()
+                                alert.informativeText = NSLocalizedString("No related content found, please change keyword.", comment: "")
+                                alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
+//                                alert.runModal()
+                                alert.beginSheetModal(for: (self?.window)!)
+                                return
+                            }
                             if let sel = datas?.first?.selection {
                                 self?.handdler.showIdx = 0
                                 self?.handdler.showSelection(sel)
@@ -567,7 +582,8 @@ extension KMSearchReplaceWindowController: NSTextFieldDelegate {
                                     alert.informativeText = NSLocalizedString("No related content found, please change keyword.", comment: "")
                                     alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
 //                                    alert.beginSheetModal(for: NSApp.mainWindow!)
-                                    alert.runModal()
+//                                    alert.runModal()
+                                    alert.beginSheetModal(for: (self.window)!)
                                     return
                                 }
                                 self.currentSel = datas.first?.first