chore(menu):add disableRestoreProxy experiment menu item

This commit is contained in:
yicheng 2020-02-22 11:59:52 +08:00
parent ee04d9a826
commit 43c1e8bfdd
5 changed files with 26 additions and 7 deletions

View File

@ -216,7 +216,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
guard NetworkChangeNotifier.getPrimaryInterface() != nil else { return }
let proxySetted = NetworkChangeNotifier.isCurrentSystemSetToClash()
ConfigManager.shared.isProxySetByOtherVariable.accept(!proxySetted)
if !proxySetted {
if !proxySetted && ConfigManager.shared.proxyPortAutoSet {
let proxiesSetting = NetworkChangeNotifier.getRawProxySetting()
Logger.log("Proxy changed by other process!, current:\(proxiesSetting)", level: .warning)
}
@ -366,6 +366,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
AutoUpgardeManager.shared.setup()
AutoUpgardeManager.shared.addChanelMenuItem(&experimentalMenu)
ClashResourceManager.addUpdateMMDBMenuItem(&experimentalMenu)
SystemProxyManager.shared.addDisableRestoreProxyMenuItem(&experimentalMenu)
if WebPortalManager.hasWebProtal {
WebPortalManager.shared.addWebProtalMenuItem(&statusMenu)
}

View File

@ -112,6 +112,24 @@ class SystemProxyManager: NSObject {
})
}
// MARK: - Expriment Menu Items
func addDisableRestoreProxyMenuItem(_ menu: inout NSMenu) {
let item = NSMenuItem(title: NSLocalizedString("Disable Restore Proxy Setting", comment: ""), action: #selector(optionMenuItemTap(sender:)), keyEquivalent: "")
item.target = self
menu.addItem(item)
updateMenuItemStatus(item)
}
func updateMenuItemStatus(_ item: NSMenuItem) {
item.state = disableRestoreProxy ? .on : .off
}
@objc func optionMenuItemTap(sender: NSMenuItem) {
disableRestoreProxy = !disableRestoreProxy
updateMenuItemStatus(sender)
}
// MARK: - Private
private func initAuthorizationRef() {

View File

@ -41,6 +41,9 @@
/* No comment provided by engineer. */
"Direct" = "Direct";
/* No comment provided by engineer. */
"Disable Restore Proxy Setting" = "Disable Restore Proxy Setting";
/* No comment provided by engineer. */
"Download fail" = "Download fail";

View File

@ -41,6 +41,9 @@
/* No comment provided by engineer. */
"Direct" = "直连";
/* No comment provided by engineer. */
"Disable Restore Proxy Setting" = "关闭自动还原之前代理";
/* No comment provided by engineer. */
"Download fail" = "下载失败";

View File

@ -50,12 +50,6 @@ Checkout [Clash](https://github.com/Dreamacro/clash) or [SS-Rule-Snippet for Cla
Place your icon file in the `~/.config/clash/menuImage.png` then restart ClashX
### Disable auto restore proxy setting.
```
defaults write com.west2online.ClashX kDisableRestoreProxy -bool true
```
### Change default system ignore list.
- Download sample plist in the [Here](proxyIgnoreList.plist) and place in the