diff --git a/ClashX/AppDelegate.swift b/ClashX/AppDelegate.swift index 3a4cd38..4a264ff 100644 --- a/ClashX/AppDelegate.swift +++ b/ClashX/AppDelegate.swift @@ -50,7 +50,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { var disposeBag = DisposeBag() var statusItemView: StatusItemView! var isSpeedTesting = false - var isMenuOptionEnter = false func applicationDidFinishLaunching(_ notification: Notification) { signal(SIGPIPE, SIG_IGN) @@ -418,14 +417,15 @@ extension AppDelegate { } } - @IBAction func actionCopyExportCommand(_ sender: Any) { + @IBAction func actionCopyExportCommand(_ sender: NSMenuItem) { let pasteboard = NSPasteboard.general pasteboard.clearContents() let port = ConfigManager.shared.currentConfig?.port ?? 0 let socksport = ConfigManager.shared.currentConfig?.socketPort ?? 0 let localhost = "127.0.0.1" - - let ip = isMenuOptionEnter ? NetworkChangeNotifier.getPrimaryIPAddress() ?? localhost : localhost + let isLocalhostCopy = sender == copyExportCommandMenuItem + let ip = isLocalhostCopy ? localhost : + NetworkChangeNotifier.getPrimaryIPAddress() ?? localhost pasteboard.setString("export https_proxy=http://\(ip):\(port) http_proxy=http://\(ip):\(port) all_proxy=socks5://\(ip):\(socksport)", forType: .string) } @@ -619,11 +619,6 @@ extension AppDelegate { self?.syncConfig() } } - - func updateCopyProxyItem() { - isMenuOptionEnter = NSEvent.modifierFlags == [.option] - copyExportCommandMenuItem.title = isMenuOptionEnter ? NSLocalizedString("Copy Shell Export Command with External IP", comment: "") : NSLocalizedString("Copy Shell Export Command", comment: "") - } } // MARK: NSMenuDelegate @@ -634,7 +629,6 @@ extension AppDelegate: NSMenuDelegate { func menuNeedsUpdate(_ menu: NSMenu) { syncConfig() updateConfigFiles() - updateCopyProxyItem() } } diff --git a/ClashX/Base.lproj/Main.storyboard b/ClashX/Base.lproj/Main.storyboard index 3624c51..e2d258b 100644 --- a/ClashX/Base.lproj/Main.storyboard +++ b/ClashX/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -231,11 +231,17 @@ - + + + + + + + @@ -613,7 +619,7 @@ - + @@ -638,7 +644,7 @@ - + @@ -678,7 +684,7 @@ - + @@ -718,7 +724,7 @@ - + diff --git a/ClashX/Support Files/en.lproj/Localizable.strings b/ClashX/Support Files/en.lproj/Localizable.strings index 35df940..db8dde8 100644 --- a/ClashX/Support Files/en.lproj/Localizable.strings +++ b/ClashX/Support Files/en.lproj/Localizable.strings @@ -38,12 +38,6 @@ /* No comment provided by engineer. */ "Config loading Fail!" = "Config loading Fail!"; -/* No comment provided by engineer. */ -"Copy Shell Export Command" = "Copy Shell Export Command"; - -/* No comment provided by engineer. */ -"Copy Shell Export Command with External IP" = "Copy Shell Export Command with External IP"; - /* No comment provided by engineer. */ "Direct" = "Direct"; diff --git a/ClashX/Support Files/zh-Hans.lproj/Localizable.strings b/ClashX/Support Files/zh-Hans.lproj/Localizable.strings index bfb64a5..2dedcb1 100644 --- a/ClashX/Support Files/zh-Hans.lproj/Localizable.strings +++ b/ClashX/Support Files/zh-Hans.lproj/Localizable.strings @@ -38,12 +38,6 @@ /* No comment provided by engineer. */ "Config loading Fail!" = "配置文件加载失败"; -/* No comment provided by engineer. */ -"Copy Shell Export Command" = "复制终端代理命令"; - -/* No comment provided by engineer. */ -"Copy Shell Export Command with External IP" = "复制终端代理命令(外部IP)"; - /* No comment provided by engineer. */ "Direct" = "直连"; diff --git a/ClashX/zh-Hans.lproj/Main.strings b/ClashX/zh-Hans.lproj/Main.strings index 7dc4919..29f20e3 100644 --- a/ClashX/zh-Hans.lproj/Main.strings +++ b/ClashX/zh-Hans.lproj/Main.strings @@ -74,7 +74,7 @@ /* Class = "NSMenuItem"; title = "API Connect Error"; ObjectID = "jGT-1M-xJu"; */ "jGT-1M-xJu.title" = "API Connect Error"; -/* Class = "NSMenuItem"; title = "Copy export command"; ObjectID = "Jmb-PK-rMW"; */ +/* Class = "NSMenuItem"; title = "Copy shell command"; ObjectID = "Jmb-PK-rMW"; */ "Jmb-PK-rMW.title" = "复制终端代理命令"; /* Class = "NSMenuItem"; title = "Config"; ObjectID = "JMV-Dy-CI0"; */ @@ -157,3 +157,6 @@ /* Class = "NSTextFieldCell"; title = "Core Version"; ObjectID = "zwo-q5-k5N"; */ "zwo-q5-k5N.title" = "内核版本"; + +/* Class = "NSMenuItem"; title = "Copy shell command (External IP)"; ObjectID = "7wl-vK-5JO"; */ +"7wl-vK-5JO.title" = "复制终端代理命令(外部IP)";