Merge remote-tracking branch 'origin/master' into meta-dev

# Conflicts:
#	.github/workflows/main.yml
#	ClashX/AppDelegate.swift
#	ClashX/Base.lproj/Main.storyboard
#	ClashX/General/ApiRequest.swift
#	ClashX/Models/ClashProxy.swift
#	ClashX/ViewControllers/Settings/GeneralSettingViewController.swift
#	ClashX/goClash/go.mod
#	ClashX/goClash/go.sum
#	ClashX/goClash/main.go
#	Podfile
#	Podfile.lock
This commit is contained in:
mrFq1 2023-03-31 12:15:26 +08:00
commit 2589b28eed
4 changed files with 22 additions and 9 deletions

View File

@ -73,8 +73,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var dashboardWindowController: ClashWebViewWindowController? var dashboardWindowController: ClashWebViewWindowController?
func applicationWillFinishLaunching(_ notification: Notification) { func applicationWillFinishLaunching(_ notification: Notification) {
Logger.log("applicationWillFinishLaunching")
signal(SIGPIPE, SIG_IGN) signal(SIGPIPE, SIG_IGN)
// crash recorder
failLaunchProtect() failLaunchProtect()
NSAppleEventManager.shared() NSAppleEventManager.shared()
.setEventHandler(self, .setEventHandler(self,
@ -103,13 +103,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
statusItemView.updateSize(width: statusItemLengthWithSpeed) statusItemView.updateSize(width: statusItemLengthWithSpeed)
statusMenu.delegate = self statusMenu.delegate = self
registCrashLogger()
DispatchQueue.main.async { DispatchQueue.main.async {
self.postFinishLaunching() self.postFinishLaunching()
} }
} }
func postFinishLaunching() { func postFinishLaunching() {
Logger.log("postFinishLaunching")
defer { defer {
statusItem.menu = statusMenu statusItem.menu = statusMenu
DispatchQueue.main.asyncAfter(deadline: .now()+1) { DispatchQueue.main.asyncAfter(deadline: .now()+1) {
@ -144,6 +144,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
RemoteConfigManager.shared.autoUpdateCheck() RemoteConfigManager.shared.autoUpdateCheck()
setupNetworkNotifier() setupNetworkNotifier()
registCrashLogger()
} }
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply { func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
@ -1420,7 +1421,8 @@ extension AppDelegate {
#else #else
DispatchQueue.main.asyncAfter(deadline: .now() + 5) { DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
AppCenter.start(withAppSecret: "dce6e9a3-b6e3-4fd2-9f2d-35c767a99663", services: [ AppCenter.start(withAppSecret: "dce6e9a3-b6e3-4fd2-9f2d-35c767a99663", services: [
Analytics.self Analytics.self,
Crashes.self
]) ])
} }

View File

@ -460,7 +460,7 @@ extension ApiRequest {
private func requestTrafficInfo() { private func requestTrafficInfo() {
trafficWebSocketRetryTimer?.invalidate() trafficWebSocketRetryTimer?.invalidate()
trafficWebSocketRetryTimer = nil trafficWebSocketRetryTimer = nil
trafficWebSocket?.disconnect(forceTimeout: 0, closeCode: 0) trafficWebSocket?.disconnect(forceTimeout: 0.5)
let socket = WebSocket(url: URL(string: ConfigManager.apiUrl.appending("/traffic"))!) let socket = WebSocket(url: URL(string: ConfigManager.apiUrl.appending("/traffic"))!)
@ -475,7 +475,7 @@ extension ApiRequest {
private func requestLog() { private func requestLog() {
loggingWebSocketRetryTimer?.invalidate() loggingWebSocketRetryTimer?.invalidate()
loggingWebSocketRetryTimer = nil loggingWebSocketRetryTimer = nil
loggingWebSocket?.disconnect() loggingWebSocket?.disconnect(forceTimeout: 1)
let uriString = "/logs?level=".appending(ConfigManager.selectLoggingApiLevel.rawValue) let uriString = "/logs?level=".appending(ConfigManager.selectLoggingApiLevel.rawValue)
let socket = WebSocket(url: URL(string: ConfigManager.apiUrl.appending(uriString))!) let socket = WebSocket(url: URL(string: ConfigManager.apiUrl.appending(uriString))!)

View File

@ -26,7 +26,7 @@ extension ClashProxyMode {
enum ClashLogLevel: String, Codable { enum ClashLogLevel: String, Codable {
case info case info
case warning = "warn" case warning
case error case error
case debug case debug
case silent case silent

View File

@ -216,12 +216,23 @@ class CustomWKWebView: WKWebView {
var dragableAreaHeight: CGFloat = 30 var dragableAreaHeight: CGFloat = 30
let alwaysDragableLeftAreaWidth: CGFloat = 150 let alwaysDragableLeftAreaWidth: CGFloat = 150
override func mouseDown(with event: NSEvent) { private func isInDargArea(with event:NSEvent?) -> Bool {
super.mouseDown(with: event) guard let event = event else { return false }
let x = event.locationInWindow.x let x = event.locationInWindow.x
let y = (window?.frame.size.height ?? 0) - event.locationInWindow.y let y = (window?.frame.size.height ?? 0) - event.locationInWindow.y
return x < alwaysDragableLeftAreaWidth || y < dragableAreaHeight
}
if x < alwaysDragableLeftAreaWidth || y < dragableAreaHeight { override func acceptsFirstMouse(for event: NSEvent?) -> Bool {
if isInDargArea(with: event) {
return true
}
return super.acceptsFirstMouse(for: event)
}
override func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
if isInDargArea(with: event) {
window?.performDrag(with: event) window?.performDrag(with: event)
} }
} }