mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-28 01:32:17 +00:00
34 lines
952 B
Swift
34 lines
952 B
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct LiteLLMUsageMenuBarApp: App {
|
|
@StateObject private var store = UsageStore()
|
|
|
|
var body: some Scene {
|
|
MenuBarExtra {
|
|
UsagePopover().environmentObject(store)
|
|
} label: {
|
|
MenuBarLabel().environmentObject(store)
|
|
}
|
|
.menuBarExtraStyle(.window)
|
|
|
|
Window("로그인 설정", id: "login-settings") {
|
|
SettingsView().environmentObject(store)
|
|
}
|
|
.windowResizability(.contentSize)
|
|
.defaultPosition(.center)
|
|
}
|
|
}
|
|
|
|
private struct MenuBarLabel: View {
|
|
@EnvironmentObject private var store: UsageStore
|
|
|
|
var body: some View {
|
|
switch store.state {
|
|
case let .ready(snapshot): Text("🚅 \(snapshot.percentage.formatted(.number.precision(.fractionLength(0))))%")
|
|
case .loading: Text("🚅 ...")
|
|
case .needsKey: Text("🚅 --")
|
|
case .unavailable, .failure: Text("🚅 !")
|
|
}
|
|
}
|
|
}
|