mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: moved WKWebView initialization to the moment when it should be displayed, which prevents the initialization of the web view on app start and silences some system logs
This commit is contained in:
@@ -1603,24 +1603,29 @@ public class PreferencesSwitch: NSStackView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class HelpHUD: NSPanel {
|
public class HelpHUD: NSPanel {
|
||||||
|
private let text: String
|
||||||
|
|
||||||
public init(_ text: String, origin: CGPoint = CGPoint(x: 0, y: 0), size: CGSize = CGSize(width: 420, height: 300)) {
|
public init(_ text: String, origin: CGPoint = CGPoint(x: 0, y: 0), size: CGSize = CGSize(width: 420, height: 300)) {
|
||||||
|
self.text = text
|
||||||
super.init(
|
super.init(
|
||||||
contentRect: NSRect(origin: origin, size: size),
|
contentRect: NSRect(origin: origin, size: size),
|
||||||
styleMask: [.hudWindow, .titled, .closable],
|
styleMask: [.hudWindow, .utilityWindow, .titled, .closable],
|
||||||
backing: .buffered, defer: false
|
backing: .buffered, defer: false
|
||||||
)
|
)
|
||||||
self.isFloatingPanel = true
|
self.isFloatingPanel = true
|
||||||
self.isMovableByWindowBackground = true
|
self.isMovableByWindowBackground = true
|
||||||
self.level = .floating
|
self.level = .floating
|
||||||
self.title = "Help"
|
self.title = "Help"
|
||||||
|
|
||||||
let webView = WKWebView()
|
|
||||||
webView.setValue(false, forKey: "drawsBackground")
|
|
||||||
webView.loadHTMLString("<html><body style='color: #ffffff;margin: 10px;'>\(text)</body></html>", baseURL: nil)
|
|
||||||
self.contentView = webView
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func show() {
|
public func show() {
|
||||||
|
if self.contentView as? WKWebView == nil {
|
||||||
|
let webView = WKWebView()
|
||||||
|
webView.setValue(false, forKey: "drawsBackground")
|
||||||
|
webView.loadHTMLString("<html><body style='color: #ffffff;margin: 10px;'>\(self.text)</body></html>", baseURL: nil)
|
||||||
|
self.contentView = webView
|
||||||
|
}
|
||||||
|
|
||||||
self.makeKeyAndOrderFront(self)
|
self.makeKeyAndOrderFront(self)
|
||||||
self.center()
|
self.center()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2610"
|
LastUpgradeVersion = "2620"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2610"
|
LastUpgradeVersion = "2620"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2610"
|
LastUpgradeVersion = "2620"
|
||||||
wasCreatedForAppExtension = "YES"
|
wasCreatedForAppExtension = "YES"
|
||||||
version = "2.0">
|
version = "2.0">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
|
|||||||
Reference in New Issue
Block a user