diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index e131de8..11018ac 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -201,7 +201,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele applyConfig() SyncSSLocal() - if defaults.bool(forKey: "ConnectAtLaunch") { + if defaults.bool(forKey: "ConnectAtLaunch") && ServerProfileManager.instance.getActiveProfileId() != "" { toggleRunning(toggleRunningMenuItem) } diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 09a7fbb..6865815 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -133,6 +133,9 @@ class PreferencesWindowController: NSWindowController self.profilesTableView.scrollRowToVisible(index-1) self.profilesTableView.selectRowIndexes(IndexSet(integer: index-1), byExtendingSelection: false) updateProfileBoxVisible() + if profileMgr.profiles.count == 0 { + (NSApplication.shared().delegate as! AppDelegate).toggleRunning((NSApplication.shared().delegate as! AppDelegate).toggleRunningMenuItem) + } } @IBAction func ok(_ sender: NSButton) {