Improve settings page

This commit is contained in:
世界
2023-07-17 14:02:58 +08:00
parent 2d3c0aa15d
commit 7a616bbe15
2 changed files with 25 additions and 10 deletions
@@ -29,7 +29,9 @@ public struct ExtensionStatusView: View {
StatusItem("Uplink Total", LibboxFormatBytes(message.uplinkTotal)) StatusItem("Uplink Total", LibboxFormatBytes(message.uplinkTotal))
StatusItem("Downlink Total", LibboxFormatBytes(message.downlinkTotal)) StatusItem("Downlink Total", LibboxFormatBytes(message.downlinkTotal))
} else { } else {
#if os(macOS)
StatusItem("Connections", "\(message.connectionsOut)") StatusItem("Connections", "\(message.connectionsOut)")
#endif
} }
} else { } else {
StatusItem("Memory", "Loading...") StatusItem("Memory", "Loading...")
@@ -3,6 +3,7 @@ import Libbox
import Library import Library
import SwiftUI import SwiftUI
#if os(macOS) #if os(macOS)
import AppKit
import ServiceManagement import ServiceManagement
#endif #endif
@@ -69,17 +70,29 @@ public struct SettingView: View {
NavigationLink(destination: ServiceLogView()) { NavigationLink(destination: ServiceLogView()) {
Text("View Service Log") Text("View Service Log")
} }
#elseif os(macOS)
Button("View Service Log") {
openWindow(id: ServiceLogView.windowID)
}
#endif
Button("Clear Working Directory") { Button("Clear Working Directory") {
Task.detached { Task.detached {
clearWorkingDirectory() clearWorkingDirectory()
} }
} }
.foregroundColor(.red) .foregroundColor(.red)
#elseif os(macOS)
HStack {
Button("View Service Log") {
openWindow(id: ServiceLogView.windowID)
}
Button("Open Working Directory") {
NSWorkspace.shared.selectFile(nil, inFileViewerRootedAtPath: FilePath.workingDirectory.relativePath)
}
Button {
Task.detached {
clearWorkingDirectory()
}
} label: {
Text("Clear Working Directory").foregroundColor(.red)
}
}.frame(maxWidth: .infinity, alignment: .trailing)
#endif
} }
Section("Debug") { Section("Debug") {
FormTextItem("Taiwan Flag Available", taiwanFlagAvailable.description) FormTextItem("Taiwan Flag Available", taiwanFlagAvailable.description)