Files
sb-front/src/components/layout/AppHeader.vue
T
ByungCheol 4ffc01f484 feat: 둘러보기(데모)를 실제 화면 그대로 — 데모 모드 + API 더미 응답
- src/demo: demo.on 플래그 + DTO 형태 더미데이터 + mock API(읽기 더미/쓰기 차단)
- accountApi: Proxy 로 데모 시 읽기→더미, 쓰기→안내. 실제 뷰 그대로 렌더
- App: authed=인증||데모 → 실제 사이드바/셸 표시 + 데모 배너(로그인/나가기)
- 라우터: 데모 허용(가계부/고정/계좌/분류) 외 보호화면은 DemoLockedView(로그인 유도)
- 사이드바: 데모 시 잠금(🔒) 배지, 메뉴는 showMenu(인증||데모)
- 로그인/로그아웃 시 데모 자동 해제, 랜딩 '둘러보기'→enterDemo
- 기존 독립 DemoView 제거

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 07:49:37 +09:00

125 lines
3.3 KiB
Vue

<script setup>
import { computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { useUiStore } from '@/stores/ui'
import { boardLabel } from '@/constants/boards'
import IconBtn from '@/components/ui/IconBtn.vue'
const auth = useAuthStore()
const ui = useUiStore()
const router = useRouter()
const route = useRoute()
// 라우트별 헤더 타이틀(현재 화면 이름)
const TITLES = {
home: '돈돼지 가계부',
'demo-locked': '둘러보기',
'account-entries': '가계부 내역',
'account-stats': '통계',
'account-recurrings': '고정 지출',
'account-wallets': '계좌 관리',
'account-categories': '분류 관리',
'account-budget': '예산 설정',
'account-tags': '태그 관리',
users: '회원 관리',
'admin-tags': '태그 관리(관리자)',
'admin-default-categories': '기본 분류 설정',
settings: '설정',
'settings-account': '계정정보',
'settings-account-edit': '가입정보 변경',
}
const pageTitle = computed(() => {
const n = route.name
if (n === 'board' || n === 'board-detail') return boardLabel(route.params.category)
if (n === 'board-write' || n === 'board-edit') return route.params.id ? '글 수정' : '글쓰기'
return TITLES[n] || '돈돼지 가계부'
})
async function handleLogout() {
await auth.logout()
router.replace('/')
}
</script>
<template>
<header class="app-header">
<div class="header-left">
<button v-if="auth.isAuthenticated" class="hamburger" type="button" aria-label="메뉴" @click="ui.toggleSidebar()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<path d="M3 12h18" /><path d="M3 6h18" /><path d="M3 18h18" />
</svg>
</button>
<h1 class="page-title">{{ pageTitle }}</h1>
</div>
<div class="header-right">
<template v-if="auth.isAuthenticated">
<span class="username">{{ auth.user?.name || auth.user?.loginId }}</span>
<IconBtn icon="logout" title="로그아웃" @click="handleLogout" />
</template>
<IconBtn v-else icon="login" title="로그인" variant="primary" @click="ui.openLogin()" />
</div>
</header>
</template>
<style scoped>
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
height: 56px;
padding: 0 1.5rem;
background: var(--color-background-soft);
border-bottom: 1px solid var(--color-border);
}
.header-left {
display: flex;
align-items: center;
gap: 0.5rem;
}
.hamburger {
display: none;
padding: 0.3rem;
border: 0;
background: transparent;
color: var(--color-text);
cursor: pointer;
line-height: 0;
}
.hamburger svg {
width: 22px;
height: 22px;
}
.page-title {
font-size: 1.2rem;
font-weight: 700;
color: var(--color-heading);
letter-spacing: -0.01em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-right {
display: flex;
align-items: center;
gap: 0.75rem;
}
.username {
font-size: 0.9rem;
}
@media (max-width: 768px) {
.hamburger {
display: inline-flex;
}
.app-header {
padding: 0 1rem;
}
/* 좁은 화면(폰/앱): 브랜드명 텍스트 숨기고 로고만 — 두 줄 줄바꿈 방지 */
.brand-text {
display: none;
}
}
</style>