mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-02-04 10:02:26 +08:00
feat: reload func
This commit is contained in:
@@ -32,6 +32,10 @@ public class DashboardWindowController: NSWindowController {
|
||||
ConfigManager.shared.overrideApiURL = .init(string: apiURL)
|
||||
ConfigManager.shared.overrideSecret = secret
|
||||
}
|
||||
|
||||
public func reload() {
|
||||
NotificationCenter.default.post(name: .reloadDashboard, object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
extension DashboardWindowController: NSWindowDelegate {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Foundation
|
||||
|
||||
extension NSNotification.Name {
|
||||
static let reloadDashboard = NSNotification.Name("ReloadDashboard")
|
||||
static let sidebarItemChanged = NSNotification.Name("SidebarItemChanged")
|
||||
|
||||
static let toolbarSearchString = NSNotification.Name("ToolbarSearchString")
|
||||
|
||||
@@ -11,6 +11,9 @@ struct SidebarListView: View {
|
||||
|
||||
@Binding var selectionName: SidebarItem?
|
||||
|
||||
@State private var reloadID = UUID().uuidString
|
||||
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
NavigationLink(destination: OverviewView(),
|
||||
@@ -66,6 +69,10 @@ struct SidebarListView: View {
|
||||
}
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
.id(reloadID)
|
||||
.onReceive(NotificationCenter.default.publisher(for: .reloadDashboard)) { _ in
|
||||
reloadID = UUID().uuidString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user