Skip to content

Commit e484b82

Browse files
authored
Merge pull request #69 from KB-JAKKU/refactor/audio
feat: 모드전환 버튼 추가
2 parents 7f76b94 + d83d92a commit e484b82

3 files changed

Lines changed: 53 additions & 8 deletions

File tree

src/components/Header.vue

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<script setup>
2-
import { ref, computed, onMounted } from 'vue'
2+
import { ref, onMounted } from 'vue'
33
import { useRouter } from 'vue-router'
44
import authApi from '@/api/authApi'
55
66
const router = useRouter()
7+
defineOptions({ name: 'AppHeader' })
78
89
// props 정의
9-
const props = defineProps({
10+
defineProps({
1011
isTransparent: {
1112
type: Boolean,
1213
default: false,
@@ -29,16 +30,20 @@ const checkLoginStatus = () => {
2930
3031
// 로그인 상태 (실제 토큰 기반)
3132
const isLoggedIn = ref(false)
33+
const isChildLoggedIn = ref(false)
3234
3335
// 로그인 상태 업데이트
3436
const updateLoginStatus = () => {
3537
isLoggedIn.value = checkLoginStatus()
38+
isChildLoggedIn.value = !!localStorage.getItem('child-accessToken')
3639
}
3740
3841
function clearCookie(name) {
3942
try {
4043
document.cookie = `${name}=; Max-Age=0; path=/;`
41-
} catch {}
44+
} catch {
45+
// ignore
46+
}
4247
}
4348
4449
// 로그아웃 함수
@@ -52,7 +57,7 @@ const handleLogout = async () => {
5257
// 서버에 로그아웃 요청 (HttpOnly refresh 쿠키 제거)
5358
try {
5459
await authApi.logout()
55-
} catch (e) {
60+
} catch {
5661
// ignore
5762
}
5863
clearCookie('refreshToken')
@@ -64,6 +69,11 @@ const handleLogout = async () => {
6469
router.push('/')
6570
}
6671
72+
// 모드 전환 버튼: 모드 선택 페이지로 이동
73+
const handleToggleChildMode = () => {
74+
router.push('/mode')
75+
}
76+
6777
// 로그인/로그아웃 토글
6878
const toggleLogin = () => {
6979
if (isLoggedIn.value) {
@@ -109,6 +119,7 @@ onMounted(() => {
109119
if (e.key === 'accessToken' || e.key === 'child-accessToken') {
110120
updateLoginStatus()
111121
}
122+
// no-op for child-mode; header button just opens /mode
112123
})
113124
})
114125
</script>
@@ -123,9 +134,17 @@ onMounted(() => {
123134
style="width: 100%; height: 100%; cursor: pointer"
124135
/>
125136
</div>
126-
<button class="login-btn" @click="toggleLogin">
127-
{{ isLoggedIn ? '로그아웃' : '로그인' }}
128-
</button>
137+
<div class="header-actions">
138+
<button
139+
v-if="isChildLoggedIn && router.currentRoute.value.path !== '/mode'"
140+
class="login-btn"
141+
@click="handleToggleChildMode"
142+
aria-label="모드 전환"
143+
>모드 전환</button>
144+
<button class="login-btn" @click="toggleLogin">
145+
{{ isLoggedIn ? '로그아웃' : '로그인' }}
146+
</button>
147+
</div>
129148
</div>
130149
</header>
131150
</template>
@@ -159,6 +178,12 @@ onMounted(() => {
159178
margin: 0 auto;
160179
}
161180
181+
.header-actions {
182+
display: flex;
183+
align-items: center;
184+
gap: 0px;
185+
}
186+
162187
.logo {
163188
width: 120px;
164189
height: 50px;

src/pages/child/study/StudyMainPage.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const onPayQR = () => {
7979
console.log('페이 QR 기능 준비 중입니다.')
8080
}
8181
82+
8283
const showAll = ref(false)
8384
8485
const displayedFavorites = computed(() =>
@@ -174,7 +175,7 @@ const toggleShowAll = () => {
174175
.mission-top-bar {
175176
width: 380px;
176177
display: flex;
177-
justify-content: flex-start;
178+
justify-content: space-between;
178179
margin-top: 20px;
179180
margin-bottom: -20px;
180181
}
@@ -198,6 +199,21 @@ const toggleShowAll = () => {
198199
gap: 8px;
199200
cursor: pointer;
200201
}
202+
.mode-toggle-btn {
203+
background-color: #ffce14;
204+
border: none;
205+
border-radius: 12px;
206+
padding: 12px 20px;
207+
cursor: pointer;
208+
transition: background-color 0.3s ease;
209+
color: #0a0000;
210+
font-size: 16px;
211+
font-weight: bold;
212+
font-family: 'OngeulipKonKon', sans-serif;
213+
}
214+
.mode-toggle-btn:hover {
215+
background-color: #d1ad02;
216+
}
201217
202218
.mission-btn:hover {
203219
background: #fff1a0;

src/pages/child/trade/TradeMainPage.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const onHistoryClick = () => {
6464
router.push('/trade/history')
6565
}
6666
67+
6768
const loadCurrentChild = async () => {
6869
const response = await childApi.me()
6970
currentChild.value = response
@@ -206,6 +207,8 @@ onMounted(async () => {
206207
<CharacterGuide :speechText="guideMsg" :img="dragonImg" layout="right" />
207208
</div>
208209
210+
<!-- 상단 모드 전환 버튼 제거: 헤더로 이동 -->
211+
209212
<div class="wallet-container">
210213
<section class="wallet-header">
211214
<div class="bank-name-row">
@@ -386,6 +389,7 @@ onMounted(async () => {
386389
font-family: 'OngeulipKonKon', sans-serif;
387390
}
388391
392+
389393
.history-btn:hover {
390394
background: rgba(255, 255, 255, 0.3);
391395
transform: translateY(-1px);

0 commit comments

Comments
 (0)