From fcbe8cd5c3adeb4fc7a74920d9a1d4da891f10be Mon Sep 17 00:00:00 2001 From: qwerzl Date: Tue, 1 Oct 2024 20:24:55 +0800 Subject: [PATCH] fix: undefined error on reload --- .../ClassroomReservation/NewClassroomReservation.vue | 8 ++++---- components/custom/sidebar.vue | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/components/custom/CAS/ClassroomReservation/NewClassroomReservation.vue b/components/custom/CAS/ClassroomReservation/NewClassroomReservation.vue index 49acabd5..14cc4dcb 100644 --- a/components/custom/CAS/ClassroomReservation/NewClassroomReservation.vue +++ b/components/custom/CAS/ClassroomReservation/NewClassroomReservation.vue @@ -217,15 +217,15 @@ async function handleSubmit(e: any) { - - + + {{ club.name.zh }} 社长 - + {{ club.name.zh }} @@ -233,7 +233,7 @@ async function handleSubmit(e: any) { - + {{ club.name.zh }} diff --git a/components/custom/sidebar.vue b/components/custom/sidebar.vue index da068287..140cf3a1 100644 --- a/components/custom/sidebar.vue +++ b/components/custom/sidebar.vue @@ -7,14 +7,12 @@ const route = useRoute() const isPresidentOrVicePresident = ref(false) -const { data } = await useAsyncData('classroomStatuses', () => { - return $fetch(`/api/user/all_clubs`, { - headers: useRequestHeaders(), - method: 'GET', - }) +const { data } = await useFetch(`/api/user/all_clubs`, { + headers: useRequestHeaders(), + method: 'GET', }) -if (data.value?.president.length !== 0 || data.value?.vice.length !== 0) { +if (data.value && (data.value?.president.length !== 0 || data.value?.vice.length !== 0)) { isPresidentOrVicePresident.value = true }