|
@@ -140,6 +140,11 @@ import Cocoa
|
|
|
self.updateUI()
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(homeFileRectChange(_:)), name: Notification.Name("KMHomeFileRectChange"), object: nil)
|
|
|
+
|
|
|
+ setAppearance(isDarkMode: KMAdvertisementConfig.isDarkModel())
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(appearanceChanged), name: NSNotification.Name(NSApplication.didUpdateNotification.rawValue), object: nil)
|
|
|
+// NotificationCenter.default.addObserver(self, selector: #selector(appearanceChanged), name: NSNotification.Name(NSWindow.didBecomeMainNotification.rawValue), object: nil)
|
|
|
+// NotificationCenter.default.addObserver(self, selector: #selector(appearanceChanged), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
|
|
|
}
|
|
|
|
|
|
override func viewDidAppear() {
|
|
@@ -370,6 +375,7 @@ import Cocoa
|
|
|
|
|
|
func updateUI() {
|
|
|
self.leftBox.fillColor = KMAppearance.Layout.l0Color()
|
|
|
+ self.homeSplitView.backgroundColor(KMAppearance.Layout.l0Color())
|
|
|
}
|
|
|
|
|
|
// MARK: Public Methods
|
|
@@ -727,3 +733,27 @@ extension KMHomeViewController {
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+extension KMHomeViewController {
|
|
|
+ // 监听系统外观模式变化的方法
|
|
|
+ @objc func appearanceChanged() {
|
|
|
+ // 根据当前的外观模式更新应用程序的外观
|
|
|
+ print("appearanceChanged\(String(describing: self.view.appearance))")
|
|
|
+ if KMAdvertisementConfig.isDarkModel() && self.view.appearance == NSAppearance(named: .aqua) ||
|
|
|
+ (!KMAdvertisementConfig.isDarkModel() && self.view.appearance == NSAppearance(named: .darkAqua)) {
|
|
|
+ setAppearance(isDarkMode: KMAdvertisementConfig.isDarkModel())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据系统外观模式设置应用程序的外观
|
|
|
+ func setAppearance(isDarkMode: Bool) {
|
|
|
+ if isDarkMode {
|
|
|
+ self.view.appearance = NSAppearance(named: .darkAqua)
|
|
|
+// NSApp.appearance = NSAppearance(named: .darkAqua)
|
|
|
+ } else {
|
|
|
+ self.view.appearance = NSAppearance(named: .aqua)
|
|
|
+// NSApp.appearance = NSAppearance(named: .aqua)
|
|
|
+ }
|
|
|
+// self.homeContentView?.qucikToolsView.updateUI()
|
|
|
+ }
|
|
|
+}
|