Skip to content

Commit

Permalink
헤더의 async 함수 호출 후 렌더링을 위해 App.vue에 Suspense 컴포넌트 추가
Browse files Browse the repository at this point in the history
+ 배포 환경에서 UserImageComponent의 이미지가 조회되지 않는 문제로 관련 콘솔 로그 작성 코드 추가
  • Loading branch information
yhlee002 committed Jul 22, 2024
1 parent cafc65e commit 424722c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ const {modalOpen, datas, open} = storeToRefs(modalStore);

<template>
<div id="app">
<HeaderComponent></HeaderComponent>
<Suspense>
<HeaderComponent></HeaderComponent>
<template #fallback>
Loading...
</template>
</Suspense>

<div class="main-block">
<Suspense>
<RouterView/>
Expand Down
18 changes: 10 additions & 8 deletions src/components/fragment/HeaderComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import NoProfileImageComponent from "@/components/icon/NoProfileImageComponent.v
import UserImageComponent from "@/components/icon/UserImageComponent.vue";
const userStore = useUserStore();
userStore.getCurrentUser();
await userStore.getCurrentUser();
// const user = userStore.user;
const logoutUrl = `http://${import.meta.env.VITE_APP_HOST}:8080/api/members/logout`;
Expand Down Expand Up @@ -46,15 +48,15 @@ async function logout() {
<!-- profile image -->
<UserImageComponent :profileImage="userStore.profileImage" :role="userStore.role"></UserImageComponent>
<span class="userbox-text" v-if="userStore.user != null">{{ userStore.user.name }}
<span v-if="userStore.user.role ==='ROLE_ADMIN'" style="color: #c6c6c6; font-size: 0.8rem">(관리자)</span>
</span>
<span v-if="userStore.user.role ==='ROLE_ADMIN'" style="color: #c6c6c6; font-size: 0.8rem">(관리자)</span>
</span>
<br>
<span class="userbox-text">
<router-link to="/mypage" v-if="userStore.isAuthenticated" style="margin-right: 3px">내정보</router-link>
</span>
<span>
<span style="cursor: pointer;" @click="logout()">로그아웃</span>
</span>
<router-link to="/mypage" v-if="userStore.isAuthenticated" style="margin-right: 3px">내정보</router-link>
</span>
<span>
<span style="cursor: pointer;" @click="logout()">로그아웃</span>
</span>
<form id="logout" :action="logoutUrl" method="POST"></form>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/components/icon/UserImageComponent.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script setup>
import NoProfileImageComponent from "@/components/icon/NoProfileImageComponent.vue";
const props = defineProps(['profileImage', 'role', 'width', 'height'])
const props = defineProps(['profileImage', 'role', 'width', 'height']);
console.log('props', props);
</script>

<template>
<div v-if="profileImage" id="writerProfileImage">
<img v-if="profileImage && role !== 'ROLE_ADMIN'" :src="profileImage"
<img v-if="role !== 'ROLE_ADMIN'" :src="profileImage"
:style="{width: width, height: height}"
class="profile_image" alt="프로필 이미지"/>
</div>
Expand Down

0 comments on commit 424722c

Please sign in to comment.