diff --git a/ClashX/General/Managers/RemoteConfigManager.swift b/ClashX/General/Managers/RemoteConfigManager.swift index 19d2c09..cb8d7a4 100644 --- a/ClashX/General/Managers/RemoteConfigManager.swift +++ b/ClashX/General/Managers/RemoteConfigManager.swift @@ -145,6 +145,7 @@ class RemoteConfigManager: NSObject { } else { self.alert(with: "Update Success!") } + self.didUpdateConfig() } catch let err { if let complete = complete { complete(err.localizedDescription) @@ -155,6 +156,15 @@ class RemoteConfigManager: NSObject { } } + static func didUpdateConfig() { + guard let hook = UserDefaults.standard.string(forKey: "kDidUpdateRemoteConfigHook") else {return} + DispatchQueue.global().async { + let appleScriptStr = "do shell script \"\(hook)\"" + let appleScript = NSAppleScript(source: appleScriptStr) + _ = appleScript?.executeAndReturnError(nil) + } + } + static func alert(with text:String) { let alert = NSAlert() alert.messageText = text