#if os(iOS) import SwiftUI struct ContentView: View { @EnvironmentObject var importer: BundleImporter @EnvironmentObject var libraryVM: LibraryViewModel @State private var tab = 0 var body: some View { TabView(selection: $tab) { NavigationStack { BookListView(importer: importer, vm: libraryVM) } .tabItem { Label("书库", systemImage: "books.vertical") } .tag(0) NavigationStack { if let index = importer.index { StatsView(index: index) } else { VStack(spacing: 16) { Text("尚未导入数据包") Button("导入 iPad 导出包") { importer.presentPicker() } }.padding() } } .tabItem { Label("统计", systemImage: "chart.bar") } .tag(1) NavigationStack { ScrollView { VStack(alignment:.leading, spacing: 12) { Text("关于").font(.title2).bold() Text("离线阅读与统计查看器。加载 Python 导出的 iPad Bundle。") Button("重新导入") { importer.presentPicker() } if let p = importer.lastImportedURL { Text("最近: \(p.lastPathComponent)").font(.footnote).foregroundColor(.secondary) } }.padding() } } .tabItem { Label("关于", systemImage: "info.circle") } .tag(2) } .onReceive(importer.$bundleIndex) { newIndex in if let newIndex { libraryVM.attach(index: newIndex) } } } } #endif