优化:请求接口全局处理loading和错误提示
This commit is contained in:
@@ -164,23 +164,19 @@ onLoad((options: any) => {
|
||||
* 加载章节详情
|
||||
*/
|
||||
const loadChapterDetail = async () => {
|
||||
try {
|
||||
const res = await courseApi.getChapterDetail(chapterId.value)
|
||||
if (res.code === 0 && res.data) {
|
||||
chapterDetail.value = res.data.detail
|
||||
videoList.value = res.data.videos || []
|
||||
const res = await courseApi.getChapterDetail(chapterId.value)
|
||||
if (res.code === 0 && res.data) {
|
||||
chapterDetail.value = res.data.detail
|
||||
videoList.value = res.data.videos || []
|
||||
|
||||
// 如果有历史播放记录,定位到对应视频
|
||||
if (res.data.current) {
|
||||
const index = videoList.value.findIndex(v => v.id === res.data.current)
|
||||
if (index !== -1) {
|
||||
currentVideoIndex.value = index
|
||||
activeVideoIndex.value = index
|
||||
}
|
||||
// 如果有历史播放记录,定位到对应视频
|
||||
if (res.data.current) {
|
||||
const index = videoList.value.findIndex(v => v.id === res.data.current)
|
||||
if (index !== -1) {
|
||||
currentVideoIndex.value = index
|
||||
activeVideoIndex.value = index
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载章节详情失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user