From ee993e6cf7f670401b4aa540bbd128675087c350 Mon Sep 17 00:00:00 2001 From: yicheng Date: Mon, 10 Sep 2018 20:58:18 +0800 Subject: [PATCH] Add useragent and fix mouse event in webview --- ClashX/ViewControllers/ClashWebViewContoller.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ClashX/ViewControllers/ClashWebViewContoller.swift b/ClashX/ViewControllers/ClashWebViewContoller.swift index 9f59fa3..fb001f2 100644 --- a/ClashX/ViewControllers/ClashWebViewContoller.swift +++ b/ClashX/ViewControllers/ClashWebViewContoller.swift @@ -22,7 +22,11 @@ class ClashWebViewContoller: NSViewController { super.viewDidLoad() webview.uiDelegate = self webview.navigationDelegate = self - + if #available(OSX 10.11, *) { + webview.customUserAgent = "ClashX Runtime" + } else { +// Fallback on earlier versions + } if NSAppKitVersion.current.rawValue > 1500 { webview.setValue(false, forKey: "drawsBackground") } @@ -107,6 +111,7 @@ extension ClashWebViewContoller:WKUIDelegate,WKNavigationDelegate { class CustomWKWebView: WKWebView { override func mouseDown(with event: NSEvent) { + super.mouseDown(with: event) if #available(OSX 10.11, *) { self.window?.performDrag(with: event) }