diff --git a/src/components/ExamQuickView/index.scss b/src/components/ExamQuickView/index.scss index 8157dcb5..ed42e076 100644 --- a/src/components/ExamQuickView/index.scss +++ b/src/components/ExamQuickView/index.scss @@ -25,14 +25,22 @@ } .exam-name { - font-size: 1.2rem; - border-bottom: 1Px solid var(--wjh-color-week); + font-size: 1.1rem; + border-bottom: 1.5Px solid var(--wjh-color-week); padding-bottom: 6Px; padding-right: .5rem; } .exam-time { font-size: 0.9rem; + display: flex; + gap: 8Px; + flex: none; + } + + .exam-state { + font-size: 0.9rem; + flex: none; } } diff --git a/src/components/ExamQuickView/index.vue b/src/components/ExamQuickView/index.vue index 26708f0f..5a9e232e 100644 --- a/src/components/ExamQuickView/index.vue +++ b/src/components/ExamQuickView/index.vue @@ -14,21 +14,37 @@ - {{ item.lessonName }} + + {{ item.lessonName }} + + {{ dayjs(getExamTime(item.examTime).date).format("MM/DD") }} + {{ getExamTime(item.examTime).start }} + + {{ `${item.examPlace} - 座位号:${item.seatNum}` }} - + 正在考试 考试已结束 - - 还有 {{ timeUtils.getDayInterval(item.examTime) }} 天开始 - + @@ -63,7 +79,7 @@ const updateTimeString = computed( () => { /** * 筛选近期考试 * - * 未来2日,过去1日 + * 未来3日 */ const filteredExamItems = computed(() => { let list: Exam[] = []; @@ -76,12 +92,16 @@ const filteredExamItems = computed(() => { const resDay = timeUtils.getDayInterval( new Date(date + " " + start + ":00") ); - return (resDay <= 3 && resDay >= -1); + return (resDay <= 3 && resDay >= 0 && examState(item.examTime) !== "after"); }); } catch (e) { console.log(e); } - return list; + return list.sort((a, b) => { + const { date: dateA, start: timeA } = getExamTime(a.examTime); + const { date: dateB, start: timeB } = getExamTime(b.examTime); + return dayjs(`${dateA}-${timeA}`) < dayjs(`${dateB}-${timeB}`) ? 1: -1; + }); }); const updateTime = computed(() => { @@ -115,6 +135,12 @@ function getExamTime(examTimeString: string) { }; } +const minuteInterval = (clock: string) => { + const [ hour, minute ] = clock.split(":").map(item => parseInt(item)); + const { hours, minutes } = timeUtils.getHMInterval({ hour, minute }); + return hours * 60 + minutes; +}; + /** * 考试状态 * @param examTimeString diff --git a/src/components/LibraryQuickView/index.vue b/src/components/LibraryQuickView/index.vue index d40e4e8d..ade6d583 100644 --- a/src/components/LibraryQuickView/index.vue +++ b/src/components/LibraryQuickView/index.vue @@ -42,11 +42,7 @@ const current = computed(() => { const bookCardBackgroundColor = (index: number): CSSProperties => { return { - backgroundColor: ` - var(--wjh-color- - ${index % 2 ? "yellow" : "orange"} - -light)` - }; + backgroundColor: ` var(--wjh-color-${index % 2 ? "yellow" : "orange"}-light)` }; }; function nav() { diff --git a/src/utils/time.ts b/src/utils/time.ts index 3937a0d0..c6fce9a2 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -22,13 +22,13 @@ export const getDayInterval = ( */ export const getHMInterval = ( timeBefore: { hour: number; minute: number }, - timeAfter: { hour: number; minute: number } + timeAfter?: { hour: number; minute: number } ) => { const minutesCount = { before: timeBefore.hour * 60 + timeBefore.minute, - after: timeAfter.hour * 60 + timeAfter.minute + after: timeAfter?.hour || new Date().getHours() * 60 + (timeAfter?.minute || new Date().getMinutes()) }; - const restHours = Math.floor(minutesCount.before - minutesCount.after ) / 60; + const restHours = Math.floor((minutesCount.before - minutesCount.after) / 60); const restMinutes = minutesCount.before - minutesCount.after - restHours * 60; return { hours: restHours,