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:
@@ -18,10 +18,15 @@ struct ConnectionsView: View {
|
||||
filterString: searchString)
|
||||
.background(Color(nsColor: .textBackgroundColor))
|
||||
.searchable(text: $searchString)
|
||||
|
||||
|
||||
|
||||
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
ApiRequest.closeAllConnection()
|
||||
} label: {
|
||||
Image(systemName: "stop.circle.fill")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ struct LogsView: View {
|
||||
@EnvironmentObject var logStorage: ClashLogStorage
|
||||
|
||||
@State var searchString: String = ""
|
||||
@State var logLevel = ConfigManager.selectLoggingApiLevel
|
||||
|
||||
var logs: [ClashLogStorage.ClashLog] {
|
||||
let logs: [ClashLogStorage.ClashLog] = logStorage.logs.reversed()
|
||||
@@ -45,6 +46,28 @@ struct LogsView: View {
|
||||
TableColumn("", value: \.log)
|
||||
}
|
||||
.searchable(text: $searchString)
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Picker("", selection: $logLevel) {
|
||||
ForEach([
|
||||
ClashLogLevel.silent,
|
||||
.error,
|
||||
.warning,
|
||||
.info,
|
||||
.debug
|
||||
], id: \.self) {
|
||||
Text($0.rawValue.capitalized).tag($0)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.menu)
|
||||
.onChange(of: logLevel) { newValue in
|
||||
guard newValue != ConfigManager.selectLoggingApiLevel else { return }
|
||||
logStorage.logs.removeAll()
|
||||
ConfigManager.selectLoggingApiLevel = newValue
|
||||
ApiRequest.shared.resetLogStreamApi()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ import SwiftUI
|
||||
|
||||
struct ProvidersView: View {
|
||||
@ObservedObject var providerStorage = DBProviderStorage()
|
||||
@EnvironmentObject var hideProxyNames: HideProxyNames
|
||||
|
||||
@State private var searchString = ProxiesSearchString()
|
||||
|
||||
@StateObject private var hideProxyNames = HideProxyNames()
|
||||
|
||||
var body: some View {
|
||||
|
||||
NavigationView {
|
||||
@@ -40,6 +42,16 @@ struct ProvidersView: View {
|
||||
.onAppear {
|
||||
loadProviders()
|
||||
}
|
||||
.environmentObject(hideProxyNames)
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
hideProxyNames.hide = !hideProxyNames.hide
|
||||
} label: {
|
||||
Image(systemName: hideProxyNames.hide ? "eyeglasses" : "wand.and.stars")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func loadProviders() {
|
||||
|
||||
@@ -19,6 +19,8 @@ struct ProxiesView: View {
|
||||
@State private var searchString = ProxiesSearchString()
|
||||
@State private var isGlobalMode = false
|
||||
|
||||
@StateObject private var hideProxyNames = HideProxyNames()
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List(proxyStorage.groups, id: \.id) { group in
|
||||
@@ -36,6 +38,16 @@ struct ProxiesView: View {
|
||||
.onAppear {
|
||||
loadProxies()
|
||||
}
|
||||
.environmentObject(hideProxyNames)
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
hideProxyNames.hide = !hideProxyNames.hide
|
||||
} label: {
|
||||
Image(systemName: hideProxyNames.hide ? "eyeglasses" : "wand.and.stars")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user