Refactor apply config.

This commit is contained in:
Qiu Yuzhou
2017-03-17 23:18:44 +08:00
parent f865395062
commit e507a41a6d

View File

@ -176,7 +176,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
ProxyConfHelper.install() ProxyConfHelper.install()
ProxyConfHelper.startMonitorPAC() ProxyConfHelper.startMonitorPAC()
SyncSSLocal()
applyConfig() applyConfig()
// Register global hotkey // Register global hotkey
@ -192,14 +191,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
} }
func applyConfig() { func applyConfig() {
SyncSSLocal()
let defaults = UserDefaults.standard let defaults = UserDefaults.standard
let isOn = defaults.bool(forKey: "ShadowsocksOn") let isOn = defaults.bool(forKey: "ShadowsocksOn")
let mode = defaults.string(forKey: "ShadowsocksRunningMode") let mode = defaults.string(forKey: "ShadowsocksRunningMode")
if isOn { if isOn {
StartSSLocal()
StartKcptun()
StartPrivoxy()
if mode == "auto" { if mode == "auto" {
ProxyConfHelper.enablePACProxy() ProxyConfHelper.enablePACProxy()
} else if mode == "global" { } else if mode == "global" {
@ -208,9 +206,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
ProxyConfHelper.disableProxy() ProxyConfHelper.disableProxy()
} }
} else { } else {
StopSSLocal()
StopKcptun()
StopPrivoxy()
ProxyConfHelper.disableProxy() ProxyConfHelper.disableProxy()
} }
} }