feat(settings): 新增关于菜单和基于正式发布的更新检测
This commit is contained in:
@@ -26,6 +26,7 @@ import Observation
|
||||
private let visibility: (Bool) -> Void
|
||||
private let menuTitle: (String) -> String
|
||||
private let openSettings: () -> Void
|
||||
private let openAbout: () -> Void
|
||||
private var showingStatusMenu = false
|
||||
private var isHiding = false
|
||||
private var preferredContentHeight = PanelLayout.defaultHeight
|
||||
@@ -34,11 +35,13 @@ import Observation
|
||||
visibility: @escaping (Bool) -> Void,
|
||||
menuTitle: @escaping (String) -> String = { $0 },
|
||||
openSettings: @escaping () -> Void = {},
|
||||
openAbout: @escaping () -> Void = {},
|
||||
@ViewBuilder content: @escaping (PanelPresentation) -> Content) {
|
||||
self.readings = readings
|
||||
self.visibility = visibility
|
||||
self.menuTitle = menuTitle
|
||||
self.openSettings = openSettings
|
||||
self.openAbout = openAbout
|
||||
self.content = {
|
||||
let host = NSHostingView(rootView: content($0))
|
||||
// The controller owns the fixed panel frame; content must not negotiate window limits.
|
||||
@@ -127,6 +130,9 @@ import Observation
|
||||
let settings = NSMenuItem(title: menuTitle("settings"), action: #selector(settingsClicked), keyEquivalent: ",")
|
||||
settings.target = self
|
||||
menu.addItem(settings)
|
||||
let about = NSMenuItem(title: menuTitle("about"), action: #selector(aboutClicked), keyEquivalent: "")
|
||||
about.target = self
|
||||
menu.addItem(about)
|
||||
menu.addItem(.separator())
|
||||
let quit = NSMenuItem(title: menuTitle("quit"), action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
||||
quit.target = NSApp
|
||||
@@ -134,6 +140,7 @@ import Observation
|
||||
return menu
|
||||
}
|
||||
|
||||
@objc private func aboutClicked() { hide(); openAbout() }
|
||||
@objc private func settingsClicked() { hide(); openSettings() }
|
||||
|
||||
private func isOverStatusItem(_ screenPoint: NSPoint) -> Bool {
|
||||
|
||||
Reference in New Issue
Block a user