Skip to content

Commit

Permalink
chore(menu):add disableRestoreProxy experiment menu item
Browse files Browse the repository at this point in the history
yichengchen committed Feb 22, 2020
1 parent ee04d9a commit 43c1e8b
Showing 5 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ClashX/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -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)
}
18 changes: 18 additions & 0 deletions ClashX/General/Managers/SystemProxyManager.swift
Original file line number Diff line number Diff line change
@@ -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() {
3 changes: 3 additions & 0 deletions ClashX/Support Files/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -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";

3 changes: 3 additions & 0 deletions ClashX/Support Files/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -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" = "下载失败";

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 43c1e8b

Please sign in to comment.