mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-03-01 00:35:19 +08:00
feat: toolbar items
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// SidebarListView.swift
|
||||
// ClashX Dashboard
|
||||
//
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SidebarListView: View {
|
||||
|
||||
@Binding var selectionName: String?
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
|
||||
NavigationLink(destination: OverviewView(),
|
||||
tag: "Overview",
|
||||
selection: $selectionName) {
|
||||
Label("Overview", systemImage: "chart.bar.xaxis")
|
||||
}
|
||||
|
||||
NavigationLink(destination: ProxiesView(),
|
||||
tag: "Proxies",
|
||||
selection: $selectionName) {
|
||||
Label("Proxies", systemImage: "globe.asia.australia")
|
||||
}
|
||||
|
||||
NavigationLink(destination: ProvidersView(),
|
||||
tag: "Providers",
|
||||
selection: $selectionName) {
|
||||
Label("Providers", systemImage: "link.icloud")
|
||||
}
|
||||
|
||||
NavigationLink(destination: RulesView(),
|
||||
tag: "Rules",
|
||||
selection: $selectionName) {
|
||||
Label("Rules", systemImage: "waveform.and.magnifyingglass")
|
||||
}
|
||||
|
||||
NavigationLink(destination: ConnectionsView(),
|
||||
tag: "Conns",
|
||||
selection: $selectionName) {
|
||||
Label("Conns", systemImage: "app.connected.to.app.below.fill")
|
||||
}
|
||||
|
||||
NavigationLink(destination: ConfigView(),
|
||||
tag: "Config",
|
||||
selection: $selectionName) {
|
||||
Label("Config", systemImage: "slider.horizontal.3")
|
||||
}
|
||||
|
||||
NavigationLink(destination: LogsView(),
|
||||
tag: "Logs",
|
||||
selection: $selectionName) {
|
||||
Label("Logs", systemImage: "wand.and.stars.inverse")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
}
|
||||
}
|
||||
|
||||
//struct SidebarListView_Previews: PreviewProvider {
|
||||
// static var previews: some View {
|
||||
// SidebarListView()
|
||||
// }
|
||||
//}
|
||||
@@ -15,50 +15,19 @@ struct SidebarView: View {
|
||||
|
||||
@State private var sidebarSelectionName: String? = "Overview"
|
||||
|
||||
@State private var sidebarItems = [
|
||||
SidebarItem(name: "Overview",
|
||||
icon: "chart.bar.xaxis",
|
||||
view: AnyView(OverviewView())),
|
||||
|
||||
SidebarItem(name: "Proxies",
|
||||
icon: "globe.asia.australia",
|
||||
view: AnyView(ProxiesView())),
|
||||
|
||||
SidebarItem(name: "Providers",
|
||||
icon: "link.icloud",
|
||||
view: AnyView(ProvidersView())),
|
||||
|
||||
SidebarItem(name: "Rules",
|
||||
icon: "waveform.and.magnifyingglass",
|
||||
view: AnyView(RulesView())),
|
||||
|
||||
SidebarItem(name: "Conns",
|
||||
icon: "app.connected.to.app.below.fill",
|
||||
view: AnyView(ConnectionsView())),
|
||||
|
||||
SidebarItem(name: "Config",
|
||||
icon: "slider.horizontal.3",
|
||||
view: AnyView(ConfigView())),
|
||||
|
||||
SidebarItem(name: "Logs",
|
||||
icon: "wand.and.stars.inverse",
|
||||
view: AnyView(LogsView()))
|
||||
]
|
||||
|
||||
var body: some View {
|
||||
ScrollViewReader { scrollViewProxy in
|
||||
List(sidebarItems, id: \.id) { item in
|
||||
SidebarItemView(item: item, selectionName: $sidebarSelectionName)
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
SidebarListView(selectionName: $sidebarSelectionName)
|
||||
}
|
||||
.environmentObject(clashApiDatasStorage.overviewData)
|
||||
.environmentObject(clashApiDatasStorage.logStorage)
|
||||
.environmentObject(clashApiDatasStorage.connsStorage)
|
||||
.onAppear {
|
||||
ConfigManager.selectLoggingApiLevel = .debug
|
||||
clashApiDatasStorage.resetStreamApi()
|
||||
if ConfigManager.selectLoggingApiLevel == .unknow {
|
||||
ConfigManager.selectLoggingApiLevel = .info
|
||||
}
|
||||
|
||||
clashApiDatasStorage.resetStreamApi()
|
||||
connsQueue.sync {
|
||||
clashApiDatasStorage.connsStorage.conns
|
||||
.removeAll()
|
||||
|
||||
Reference in New Issue
Block a user