feat: reload func

This commit is contained in:
mrFq1
2023-06-05 22:43:15 +08:00
parent 1a4cd5c7f6
commit 064b7ace97
3 changed files with 12 additions and 0 deletions

View File

@@ -32,6 +32,10 @@ public class DashboardWindowController: NSWindowController {
ConfigManager.shared.overrideApiURL = .init(string: apiURL) ConfigManager.shared.overrideApiURL = .init(string: apiURL)
ConfigManager.shared.overrideSecret = secret ConfigManager.shared.overrideSecret = secret
} }
public func reload() {
NotificationCenter.default.post(name: .reloadDashboard, object: nil)
}
} }
extension DashboardWindowController: NSWindowDelegate { extension DashboardWindowController: NSWindowDelegate {

View File

@@ -7,6 +7,7 @@
import Foundation import Foundation
extension NSNotification.Name { extension NSNotification.Name {
static let reloadDashboard = NSNotification.Name("ReloadDashboard")
static let sidebarItemChanged = NSNotification.Name("SidebarItemChanged") static let sidebarItemChanged = NSNotification.Name("SidebarItemChanged")
static let toolbarSearchString = NSNotification.Name("ToolbarSearchString") static let toolbarSearchString = NSNotification.Name("ToolbarSearchString")

View File

@@ -11,6 +11,9 @@ struct SidebarListView: View {
@Binding var selectionName: SidebarItem? @Binding var selectionName: SidebarItem?
@State private var reloadID = UUID().uuidString
var body: some View { var body: some View {
List { List {
NavigationLink(destination: OverviewView(), NavigationLink(destination: OverviewView(),
@@ -66,6 +69,10 @@ struct SidebarListView: View {
} }
} }
.listStyle(.sidebar) .listStyle(.sidebar)
.id(reloadID)
.onReceive(NotificationCenter.default.publisher(for: .reloadDashboard)) { _ in
reloadID = UUID().uuidString
}
} }
} }