fix(LessonRecordsView): 从 LessonDetailResponse 嵌套结构正确解析 classId
Made-with: Cursor
This commit is contained in:
parent
030bbba3bb
commit
7f0ea0daa4
@ -336,13 +336,16 @@ const loadRecords = async () => {
|
|||||||
|
|
||||||
const loadLessonDetail = async () => {
|
const loadLessonDetail = async () => {
|
||||||
try {
|
try {
|
||||||
const lesson = await getLesson(lessonId.value);
|
// 后端返回 LessonDetailResponse: { lesson, course, class },需从嵌套结构解析
|
||||||
|
const res = await getLesson(lessonId.value);
|
||||||
|
const l = res?.lesson ?? res;
|
||||||
|
const classInfo = res?.class ?? res?.classInfo;
|
||||||
lessonDetail.value = {
|
lessonDetail.value = {
|
||||||
id: lesson.id,
|
id: l?.id,
|
||||||
courseId: lesson.courseId,
|
courseId: l?.courseId ?? res?.course?.id,
|
||||||
courseName: lesson.course?.name,
|
courseName: res?.course?.name ?? l?.courseName,
|
||||||
classId: lesson.classId,
|
classId: l?.classId ?? classInfo?.id,
|
||||||
className: lesson.class?.name,
|
className: classInfo?.name ?? l?.className,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载课程详情失败', error);
|
console.error('加载课程详情失败', error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user