reset traffic api at switch display traffic at menu bar

This commit is contained in:
yicheng 2020-04-10 13:12:08 +08:00
parent 7e06f08aad
commit 204861eb88
3 changed files with 19 additions and 3 deletions

View File

@ -146,6 +146,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
func setupData() {
ConfigManager.shared
.showNetSpeedIndicatorObservable.skip(1)
.bind {
_ in
ApiRequest.shared.resetTrafficStreamApi()
}.disposed(by: disposeBag)
Observable
.merge([ConfigManager.shared.proxyPortAutoSetObservable,
ConfigManager.shared.isProxySetByOtherVariable.asObservable()])

View File

@ -261,11 +261,19 @@ extension ApiRequest {
extension ApiRequest {
func resetStreamApis() {
trafficWebSocketRetryCount = 0
resetLogStreamApi()
resetTrafficStreamApi()
}
func resetLogStreamApi() {
loggingWebSocketRetryCount = 0
requestTrafficInfo()
requestLog()
}
func resetTrafficStreamApi() {
trafficWebSocketRetryCount = 0
requestTrafficInfo()
}
private func requestTrafficInfo() {
trafficWebSocket?.disconnect(forceTimeout: 0, closeCode: 0)

View File

@ -23,7 +23,7 @@ go build -ldflags '-X "github.com/Dreamacro/clash/constant.Version={version}" \
def write_to_info(version):
path = "info.plist"
path = "../info.plist"
with open(path, 'rb') as f:
contents = plistlib.load(f)