mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-03-01 00:35:19 +08:00
feat: AppKit toolbar
This commit is contained in:
@@ -27,6 +27,8 @@ struct SidebarView: View {
|
||||
ConfigManager.selectLoggingApiLevel = .info
|
||||
}
|
||||
|
||||
sidebarItemChanged(sidebarSelectionName)
|
||||
|
||||
clashApiDatasStorage.resetStreamApi()
|
||||
connsQueue.sync {
|
||||
clashApiDatasStorage.connsStorage.conns
|
||||
@@ -35,9 +37,13 @@ struct SidebarView: View {
|
||||
|
||||
updateConnections()
|
||||
}
|
||||
.onChange(of: sidebarSelectionName) { newValue in
|
||||
sidebarItemChanged(newValue)
|
||||
}
|
||||
.onReceive(timer, perform: { _ in
|
||||
updateConnections()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func updateConnections() {
|
||||
@@ -50,6 +56,13 @@ struct SidebarView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sidebarItemChanged(_ name: String?) {
|
||||
guard let str = name,
|
||||
let item = SidebarItem(rawValue: str) else { return }
|
||||
|
||||
NotificationCenter.default.post(name: .sidebarItemChanged, object: nil, userInfo: ["item": item])
|
||||
}
|
||||
}
|
||||
|
||||
//struct SidebarView_Previews: PreviewProvider {
|
||||
|
||||
Reference in New Issue
Block a user