|
@@ -864,10 +864,18 @@ extension KMMainViewController {
|
|
|
|
|
|
}
|
|
}
|
|
@objc func lookUpAction() {
|
|
@objc func lookUpAction() {
|
|
|
|
+ let label = self.listView?.currentSelection?.string() ?? ""
|
|
|
|
+ self.toolbarController.showFindBar()
|
|
|
|
+ self.toolbarController.findSearchView.searchString(label)
|
|
|
|
+// self.toolbarController.findSearchView.find(Any.self)
|
|
|
|
|
|
}
|
|
}
|
|
@objc func searchBaiduAction() {
|
|
@objc func searchBaiduAction() {
|
|
-
|
|
|
|
|
|
+ let label = self.listView?.currentSelection?.string() ?? ""
|
|
|
|
+ let query = label.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? ""
|
|
|
|
+ if let url = URL(string: "https://www.baidu.com/s?wd=\(query)") {
|
|
|
|
+ NSWorkspace.shared.open(url)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
@objc func showInfoInFinder() {
|
|
@objc func showInfoInFinder() {
|
|
|
|
|
|
@@ -879,7 +887,17 @@ extension KMMainViewController {
|
|
|
|
|
|
}
|
|
}
|
|
@objc func TranslateItemAction() {
|
|
@objc func TranslateItemAction() {
|
|
-
|
|
|
|
|
|
+ // 获取选中的文本
|
|
|
|
+ if let selection = self.listView?.currentSelection?.string() {
|
|
|
|
+ // 进行翻译
|
|
|
|
+ let escapedText = selection.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
|
|
|
|
+ let urlStr = "https://translate.google.com/?sl=auto&tl=zh-CN&text=\(escapedText)"
|
|
|
|
+ if let url = URL(string: urlStr) {
|
|
|
|
+ NSWorkspace.shared.open(url)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ print("No text selected.")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
@objc func AutoScrollItemAction() {
|
|
@objc func AutoScrollItemAction() {
|
|
//增加判断,如果是正在滚动,就停止,否则就开始滚动
|
|
//增加判断,如果是正在滚动,就停止,否则就开始滚动
|