chore: allow mutilple clashx running
This commit is contained in:
parent
d3bde38343
commit
e5080ee5b4
|
@ -61,7 +61,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
signal(SIGPIPE, SIG_IGN)
|
||||
checkOnlyOneClashX()
|
||||
// crash recorder
|
||||
failLaunchProtect()
|
||||
registCrashLogger()
|
||||
|
@ -286,6 +285,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
PrivilegedHelperManager.shared.isHelperCheckFinished
|
||||
.filter({$0})
|
||||
.take(1)
|
||||
.observeOn(MainScheduler.instance)
|
||||
.subscribe { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.proxySettingMenuItem.target = self
|
||||
|
@ -293,15 +293,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func checkOnlyOneClashX() {
|
||||
let runningCount = NSRunningApplication.runningApplications(withBundleIdentifier: Bundle.main.bundleIdentifier ?? "").count
|
||||
if runningCount > 1 {
|
||||
Logger.log("running count => \(runningCount), exit")
|
||||
assertionFailure()
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
}
|
||||
|
||||
func setupNetworkNotifier() {
|
||||
NetworkChangeNotifier.start()
|
||||
|
||||
|
|
|
@ -19,11 +19,14 @@ class ClashStatusTool {
|
|||
alert.informativeText = NSLocalizedString("Ports Open Fail, Please try to restart ClashX", comment: "")
|
||||
alert.addButton(withTitle: NSLocalizedString("Quit", comment: ""))
|
||||
alert.addButton(withTitle: "Edit Config")
|
||||
let ret = alert.runModal()
|
||||
if ret == .alertSecondButtonReturn {
|
||||
NSWorkspace.shared.openFile(Paths.localConfigPath(for: "config"))
|
||||
DispatchQueue.main.async {
|
||||
let ret = alert.runModal()
|
||||
if ret == .alertSecondButtonReturn {
|
||||
NSWorkspace.shared.openFile(Paths.localConfigPath(for: "config"))
|
||||
}
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
NSApp.terminate(nil)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,9 @@ class NetworkChangeNotifier {
|
|||
let (http, https, socks) = NetworkChangeNotifier.currentSystemProxySetting()
|
||||
let currentPort = ConfigManager.shared.currentConfig?.usedHttpPort ?? 0
|
||||
let currentSocks = ConfigManager.shared.currentConfig?.usedSocksPort ?? 0
|
||||
|
||||
if currentPort == currentSocks, currentPort == 0 {
|
||||
return false
|
||||
}
|
||||
if looser {
|
||||
return http == currentPort || https == currentPort || socks == currentSocks
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue