Chore: show dock icon when dashboard is presenting

Bugfix: fix memory leak in dashboard webview
This commit is contained in:
yicheng 2018-12-21 23:49:38 +08:00
parent 315a342b19
commit 6ecc4ac9f0
2 changed files with 17 additions and 4 deletions

View File

@ -125,8 +125,8 @@ class JsBridgeUtil {
// ping-pong
bridge.registerHandler("ping"){ (anydata, responseCallback) in
bridge.callHandler("pong")
bridge.registerHandler("ping"){ [weak bridge] (anydata, responseCallback) in
bridge?.callHandler("pong")
responseCallback?(true)
}
return bridge

View File

@ -90,21 +90,34 @@ class ClashWebViewContoller: NSViewController {
view.window?.backgroundColor = NSColor.clear
view.window?.styleMask.remove(.resizable)
view.window?.styleMask.remove(.miniaturizable)
if NSApp.activationPolicy() == .accessory {
NSApp.setActivationPolicy(.regular)
}
}
deinit {
NSApp.setActivationPolicy(.accessory)
}
}
extension ClashWebViewContoller {
func registerExtenalJSBridgeFunction(){
self.bridge?.registerHandler("setDragAreaHeight") {(anydata, responseCallback) in
self.bridge?.registerHandler("setDragAreaHeight") {
[weak self] (anydata, responseCallback) in
if let height = anydata as? CGFloat {
self.webview.dragableAreaHeight = height;
self?.webview.dragableAreaHeight = height;
}
responseCallback?(nil)
}
}
}
extension ClashWebViewContoller:WKUIDelegate,WKNavigationDelegate {
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
}