增加注解

This commit is contained in:
JinJiangHuang
2026-03-01 22:23:38 +08:00
parent 99a8cc799b
commit ee8c71dcd4
23 changed files with 374 additions and 24 deletions
+22
View File
@@ -1,10 +1,15 @@
import SwiftUI
import SwiftData
///
/// SwiftData `AppState`
@main
struct tvboxApp: App {
///
@StateObject private var appState = AppState()
/// SwiftData
/// Schema//使
var sharedModelContainer: ModelContainer = {
let schema = Schema([
VodCollect.self,
@@ -19,6 +24,7 @@ struct tvboxApp: App {
}
}()
///
var body: some Scene {
WindowGroup {
ContentView()
@@ -31,20 +37,32 @@ struct tvboxApp: App {
}
}
///
///
@MainActor
class AppState: ObservableObject {
/// ViewModel 使
@Published var apiConfig = ApiConfig.shared
/// `ContentView`
@Published var isConfigLoaded = false
/// key
@Published var currentSourceKey: String = ""
#if os(macOS)
/// macOS //
@Published var splitViewVisibility: NavigationSplitViewVisibility = .all
/// 退
private var splitViewVisibilityBeforePlayerFullScreen: NavigationSplitViewVisibility?
#endif
///
func loadConfig(url: String) async {
await loadConfig(vodUrl: url, liveUrl: nil)
}
///
/// - Parameters:
/// - vodUrl:
/// - liveUrl: 退
func loadConfig(vodUrl: String, liveUrl: String?) async {
let trimmedVod = vodUrl.trimmingCharacters(in: .whitespacesAndNewlines)
let trimmedLive = (liveUrl ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
@@ -59,12 +77,15 @@ class AppState: ObservableObject {
}
}
///
///
func applyLoadedConfigState() {
isConfigLoaded = true
currentSourceKey = ApiConfig.shared.homeSourceBean?.key ?? ""
}
#if os(macOS)
///
func enterPlayerFullScreen() {
if splitViewVisibilityBeforePlayerFullScreen == nil {
splitViewVisibilityBeforePlayerFullScreen = splitViewVisibility
@@ -72,6 +93,7 @@ class AppState: ObservableObject {
splitViewVisibility = .detailOnly
}
/// 退
func exitPlayerFullScreen() {
guard let previous = splitViewVisibilityBeforePlayerFullScreen else { return }
splitViewVisibility = previous