Add effectView as background to dashboard
This commit is contained in:
parent
134fd365ba
commit
518f22efaa
@ -325,11 +325,25 @@
|
||||
<view key="view" id="2Hi-rP-ejJ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<visualEffectView autoresizesSubviews="NO" appearanceType="vibrantLight" blendingMode="behindWindow" material="light" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="AjH-Gz-iJd">
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
|
||||
</visualEffectView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="AjH-Gz-iJd" firstAttribute="leading" secondItem="2Hi-rP-ejJ" secondAttribute="leading" id="GTJ-nR-JVc"/>
|
||||
<constraint firstAttribute="trailing" secondItem="AjH-Gz-iJd" secondAttribute="trailing" id="P2d-gI-Wak"/>
|
||||
<constraint firstItem="AjH-Gz-iJd" firstAttribute="top" secondItem="2Hi-rP-ejJ" secondAttribute="top" id="gvR-vd-iBK"/>
|
||||
<constraint firstAttribute="bottom" secondItem="AjH-Gz-iJd" secondAttribute="bottom" id="hFJ-mj-rKr"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="effectView" destination="AjH-Gz-iJd" id="P99-CL-v8l"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<customObject id="dTN-vP-Bji" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="544" y="-121"/>
|
||||
<point key="canvasLocation" x="959" y="-1"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
@ -17,16 +17,25 @@ class ClashWebViewContoller: NSViewController {
|
||||
var bridge:WebViewJavascriptBridge?
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
@IBOutlet weak var effectView: NSVisualEffectView!
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
webview.uiDelegate = self
|
||||
webview.navigationDelegate = self
|
||||
view.addSubview(webview)
|
||||
|
||||
if NSAppKitVersion.current.rawValue > 1500 {
|
||||
webview.setValue(false, forKey: "drawsBackground")
|
||||
}
|
||||
else {
|
||||
webview.setValue(true, forKey: "drawsTransparentBackground")
|
||||
}
|
||||
view.addSubview(webview)
|
||||
|
||||
|
||||
webview.translatesAutoresizingMaskIntoConstraints = false
|
||||
let attributes:[NSLayoutConstraint.Attribute] = [.top,.left,.bottom,.right,.top]
|
||||
for attribute in attributes {
|
||||
|
||||
|
||||
let constraint = NSLayoutConstraint(item: webview,
|
||||
attribute: attribute,
|
||||
relatedBy: .equal,
|
||||
@ -36,16 +45,16 @@ class ClashWebViewContoller: NSViewController {
|
||||
constraint.priority = NSLayoutConstraint.Priority(rawValue: 100);
|
||||
view.addConstraint(constraint)
|
||||
}
|
||||
|
||||
|
||||
bridge = JsBridgeHelper.initJSbridge(webview: webview, delegate: self)
|
||||
|
||||
|
||||
webview.configuration.preferences.setValue(true, forKey: "developerExtrasEnabled")
|
||||
|
||||
|
||||
NotificationCenter.default.rx.notification(kConfigFileChange).bind {
|
||||
[weak self] (note) in
|
||||
self?.bridge?.callHandler("onConfigChange")
|
||||
}.disposed(by: disposeBag)
|
||||
|
||||
|
||||
// defaults write com.west2online.ClashX webviewUrl "your url"
|
||||
let url = UserDefaults.standard.string(forKey: "webviewUrl") ?? "http://127.0.0.1:8080"
|
||||
self.webview.load(URLRequest(url: URL(string: url)!))
|
||||
@ -60,6 +69,9 @@ class ClashWebViewContoller: NSViewController {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
self.view.window?.makeKeyAndOrderFront(self)
|
||||
|
||||
self.view.window?.isOpaque = false
|
||||
self.view.window?.backgroundColor = NSColor.clear
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user