Skip to content

Commit

Permalink
fix: undefined error on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerzl committed Oct 1, 2024
1 parent 8ca8fad commit fcbe8cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,23 @@ async function handleSubmit(e: any) {
<SelectValue placeholder="选择你的社团" />
</SelectTrigger>
<SelectContent>
<SelectGroup v-if="clubs?.president.length">
<SelectItem v-for="club in clubs.president" :key="club.id" :value="club.id">
<SelectGroup v-if="clubs?.president && clubs?.president.length">
<SelectItem v-for="club in clubs?.president" :key="club.id" :value="club.id">
{{ club.name.zh }}
<span class="inline-block text-gray-500">
社长
</span>
</SelectItem>
</SelectGroup>
<SelectGroup v-if="clubs?.vice.length">
<SelectGroup v-if="clubs?.vice && clubs?.vice.length">
<SelectItem v-for="club in clubs?.vice" :key="club.id" :value="club.id">
{{ club.name.zh }}
<span class="inline-block text-gray-500">
副社
</span>
</SelectItem>
</SelectGroup>
<SelectGroup v-if="clubs?.member.length">
<SelectGroup v-if="clubs?.member && clubs?.member.length">
<SelectItem v-for="club in clubs?.member" :key="club.id" :value="club.id">
{{ club.name.zh }}
<span class="inline-block text-gray-500">
Expand Down
10 changes: 4 additions & 6 deletions components/custom/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ const route = useRoute()
const isPresidentOrVicePresident = ref(false)
const { data } = await useAsyncData<AllClubs>('classroomStatuses', () => {
return $fetch<AllClubs>(`/api/user/all_clubs`, {
headers: useRequestHeaders(),
method: 'GET',
})
const { data } = await useFetch<AllClubs>(`/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
}
</script>
Expand Down

0 comments on commit fcbe8cd

Please sign in to comment.