Kaynağa Gözat

fix: keep companion calendar visible when empty

彭峰 1 ay önce
ebeveyn
işleme
727087170d

+ 11 - 5
projects/xiaoshu-mobile/src/app/core/home-learning-modules.integration.spec.ts

@@ -112,16 +112,21 @@ class LearningModulesApiService {
     }
     }
     if (action === 'app_companion_overview') {
     if (action === 'app_companion_overview') {
       this.lastScheduleParams = params;
       this.lastScheduleParams = params;
+      const schedules = [
+        { GeneralID: 901, bxrq: '2026-08-10 00:00:00', sdsd: '19:00', Title: '同步伴学', plxm: '张老师', dszt: 10 },
+        { GeneralID: 902, bxrq: '2026-08-03 00:00:00', sdsd: '18:00', Title: '历史伴学', plxm: '李老师', dszt: 30 },
+        { GeneralID: 903, bxrq: '2099-01-01 00:00:00', sdsd: '18:00', Title: '未来计划', plxm: '王老师', dszt: 0 },
+      ];
+      const rangeStart = String(params['rangeStart'] ?? '');
+      const rangeEnd = String(params['rangeEnd'] ?? '');
       return this.result<T>({
       return this.result<T>({
         courses: [
         courses: [
           { GeneralID: 801, id: 701, kcid: 801, Title: '初中英语|七年级上册@同步词汇' },
           { GeneralID: 801, id: 701, kcid: 801, Title: '初中英语|七年级上册@同步词汇' },
           { GeneralID: 802, id: 702, Title2: '【初中英语】阅读训练', syjd: '{"811":"811@Unit 1@1"}' },
           { GeneralID: 802, id: 702, Title2: '【初中英语】阅读训练', syjd: '{"811":"811@Unit 1@1"}' },
         ],
         ],
-        schedules: [
-          { GeneralID: 901, bxrq: '2026-08-10 00:00:00', sdsd: '19:00', Title: '同步伴学', plxm: '张老师', dszt: 10 },
-          { GeneralID: 902, bxrq: '2026-08-03 00:00:00', sdsd: '18:00', Title: '历史伴学', plxm: '李老师', dszt: 30 },
-          { GeneralID: 903, bxrq: '2099-01-01 00:00:00', sdsd: '18:00', Title: '未来计划', plxm: '王老师', dszt: 0 },
-        ],
+        schedules: rangeStart && rangeEnd
+          ? schedules.filter((item) => item.bxrq.slice(0, 10) >= rangeStart && item.bxrq.slice(0, 10) <= rangeEnd)
+          : schedules,
         refreshedAt: '2026-08-26T00:00:00.000Z',
         refreshedAt: '2026-08-26T00:00:00.000Z',
       });
       });
     }
     }
@@ -325,6 +330,7 @@ describe('home learning modules', () => {
 
 
     await harness.navigateByUrl('/pages/home/cart');
     await harness.navigateByUrl('/pages/home/cart');
     expect(harness.routeNativeElement?.querySelectorAll('.schedule-list article').length).toBe(0);
     expect(harness.routeNativeElement?.querySelectorAll('.schedule-list article').length).toBe(0);
+    expect(harness.routeNativeElement?.querySelectorAll('.calendar-day').length).toBe(42);
     const allDates = Array.from(harness.routeNativeElement?.querySelectorAll('.range-tabs button') ?? [])
     const allDates = Array.from(harness.routeNativeElement?.querySelectorAll('.range-tabs button') ?? [])
       .find((button) => button.textContent?.trim() === '全部') as HTMLButtonElement;
       .find((button) => button.textContent?.trim() === '全部') as HTMLButtonElement;
     allDates.click();
     allDates.click();

+ 1 - 1
projects/xiaoshu-mobile/src/app/features/course-center/course-center-page.component.html

@@ -13,7 +13,7 @@
 
 
     <section class="schedule-band">
     <section class="schedule-band">
       <header><lucide-icon [img]="isCoach ? icons.GraduationCap : icons.CalendarDays" [size]="21" /><h2>{{ isHistory ? '销课记录' : isCoach ? '陪练排课' : '伴学列表' }}</h2><span>{{ hasScheduleCalendar ? visibleSchedules().length + ' / ' + schedules().length : schedules().length }} 节</span></header>
       <header><lucide-icon [img]="isCoach ? icons.GraduationCap : icons.CalendarDays" [size]="21" /><h2>{{ isHistory ? '销课记录' : isCoach ? '陪练排课' : '伴学列表' }}</h2><span>{{ hasScheduleCalendar ? visibleSchedules().length + ' / ' + schedules().length : schedules().length }} 节</span></header>
-      @if (hasScheduleCalendar && schedules().length) {
+      @if (hasScheduleCalendar) {
         <div class="schedule-tools">
         <div class="schedule-tools">
           <div class="schedule-toolbar">
           <div class="schedule-toolbar">
             <nav class="range-tabs" aria-label="课表日期范围">
             <nav class="range-tabs" aria-label="课表日期范围">