fixed some bugs
This commit is contained in:
@@ -105,6 +105,9 @@ struct RootView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onReceive(catalogVM.$activeVideoHash) { videoHash in
|
||||
syncCurrentCourse(with: videoHash)
|
||||
}
|
||||
.fullScreenCover(isPresented: $showFullscreenPlayer) {
|
||||
FullscreenPlayerView(controller: controller) {
|
||||
exitFullscreen()
|
||||
@@ -264,6 +267,29 @@ struct RootView: View {
|
||||
activeModule = .train
|
||||
}
|
||||
|
||||
/// 训练页的课程卡片直接操作 CatalogViewModel;
|
||||
/// 这里监听它的 activeVideoHash,保证返回课程页时高亮和“当前课程”同步。
|
||||
private func syncCurrentCourse(with videoHash: String?) {
|
||||
guard let videoHash else { return }
|
||||
if let course = courses.first(where: { $0.videoHash == videoHash }) {
|
||||
currentCourse = course
|
||||
return
|
||||
}
|
||||
|
||||
// 本地导入视频不在 /courses 列表里;仍建立当前课程信息,避免课程页状态回退。
|
||||
if let video = catalogVM.videos.first(where: { $0.videoHash == videoHash }) {
|
||||
currentCourse = Course(
|
||||
videoHash: video.videoHash,
|
||||
title: video.title,
|
||||
durationMs: video.durationMs,
|
||||
language: video.language,
|
||||
sentenceCount: video.sentenceCount,
|
||||
streamUrl: video.streamUrl,
|
||||
enrolled: false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Mine Page
|
||||
|
||||
private var minePage: some View {
|
||||
|
||||
Reference in New Issue
Block a user