Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: 减少课表卡片文件中不必要的计算属性 #117

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/components/LessonsTableQuickView/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,18 @@ import { dayScheduleStartTime } from "@/constants/dayScheduleStartTime";
import { useTimeInstance } from "@/hooks";
import { Lesson } from "@/types/Lesson";

const tenPM = dayjs().set('hour', 22).set('minute', 0).set('second', 0);
const tenPM = dayjs().set("hour", 22).set("minute", 0).set("second", 0);
const emit = defineEmits(["showHelp"]);
const timer: Ref<ReturnType<typeof setInterval> | null> = ref(null);

const showTomorrow = computed(() => {
return dayjs().isAfter(tenPM);
});
const showTomorrow = dayjs().isAfter(tenPM);

const lessonTable = computed(() => {
const year = systemStore.generalInfo.termYear;
const term = systemStore.generalInfo.term;
let tmp: Lesson[] | undefined;
try {
tmp = showTomorrow.value ? ZFService.getDayLessonTable('tomorrow') : ZFService.getDayLessonTable('today');
tmp = showTomorrow ? ZFService.getDayLessonTable("tomorrow") : ZFService.getDayLessonTable("today");
serviceStore.zf.lessonsTableInfo[year][term].data.lessonsTable;
} catch (error) {
tmp = undefined;
Expand All @@ -83,7 +81,6 @@ const updateRestTimeCounter = ref(0);
// TODO: 计时器控制渲染

onMounted(() => {
lessonTable.value; // 触发计算属性
timer.value = setInterval(() => {
updateRestTimeCounter.value++;
}, 5000);
Expand Down
Loading