This commit is contained in:
JinJiangHuang
2026-03-01 20:34:43 +08:00
parent 3f302f83b3
commit 54de47deb1
10 changed files with 487 additions and 211 deletions
+16 -5
View File
@@ -42,17 +42,28 @@ class AppState: ObservableObject {
#endif
func loadConfig(url: String) async {
await loadConfig(vodUrl: url, liveUrl: nil)
}
func loadConfig(vodUrl: String, liveUrl: String?) async {
let trimmedVod = vodUrl.trimmingCharacters(in: .whitespacesAndNewlines)
let trimmedLive = (liveUrl ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmedVod.isEmpty else { return }
let resolvedLive = trimmedLive.isEmpty ? trimmedVod : trimmedLive
do {
try await ApiConfig.shared.loadConfig(from: url)
await MainActor.run {
self.isConfigLoaded = true
self.currentSourceKey = ApiConfig.shared.homeSourceBean?.key ?? ""
}
try await ApiConfig.shared.loadConfigs(vodApiUrl: trimmedVod, liveApiUrl: resolvedLive)
applyLoadedConfigState()
} catch {
print("Failed to load config: \(error)")
}
}
func applyLoadedConfigState() {
isConfigLoaded = true
currentSourceKey = ApiConfig.shared.homeSourceBean?.key ?? ""
}
#if os(macOS)
func enterPlayerFullScreen() {
if splitViewVisibilityBeforePlayerFullScreen == nil {