Skip to content

Commit 3c1d220

Browse files
committed
Bugfix: update api is unstabled now.relaunch to update config
1 parent 3deaa4e commit 3c1d220

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ClashX/AppDelegate.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1515
var statusItem: NSStatusItem!
1616
static let StatusItemIconWidth: CGFloat = NSStatusItem.variableLength * 2
1717

18-
1918
@IBOutlet weak var statusMenu: NSMenu!
2019
@IBOutlet weak var proxySettingMenuItem: NSMenuItem!
2120
@IBOutlet weak var autoStartMenuItem: NSMenuItem!
@@ -25,15 +24,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
2524

2625
func applicationDidFinishLaunching(_ aNotification: Notification) {
2726
signal(SIGPIPE, SIG_IGN)
28-
27+
2928
_ = ProxyConfigManager.install()
3029
PFMoveToApplicationsFolderIfNecessary()
30+
self.startProxy()
3131

3232
statusItem = NSStatusBar.system.statusItem(withLength: 57)
3333
let view = StatusItemView.create(statusItem: statusItem,statusMenu: statusMenu)
3434
statusItem.view = view
3535
updateMenuItem()
36-
startProxy()
3736

3837
}
3938

ClashX/General/ApiRequest.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ class ApiRequest{
3030
}
3131

3232
static func requestConfigUpdate(callback:@escaping ((Bool)->())){
33-
request(ConfigManager.apiUrl + "/configs", method: .put).responseJSON{
34-
data in
35-
// response is undocumented yet.
36-
callback(true)
33+
// request(ConfigManager.apiUrl + "/configs", method: .put).responseJSON{
34+
// data in
35+
// // response is undocumented yet.
36+
// callback(true)
37+
// }
38+
if let path = Bundle.main.resourceURL?.deletingLastPathComponent().deletingLastPathComponent().absoluteString {
39+
NSLog("restart \(path)")
40+
_ = Process.launchedProcess(launchPath: "/usr/bin/open", arguments: [path])
41+
NSApp.terminate(self)
3742
}
3843
}
3944
}

0 commit comments

Comments
 (0)