import SwiftUI

struct ContentView: View {
    @State private var store = WordStore()
    @State private var speech = SpeechService()

    var body: some View {
        Group {
            if let error = store.loadError {
                ContentUnavailableView(
                    "词库加载失败",
                    systemImage: "exclamationmark.triangle",
                    description: Text(error)
                )
            } else {
                CategoryListView(categories: store.categories)
            }
        }
        .environment(speech)
        .onAppear { store.load() }
    }
}

#Preview {
    ContentView()
}
