admin.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="admin--layout">
  3. <!-- Header -->
  4. <header class="admin--header">
  5. <div class="admin--header-left">
  6. <div class="admin--logo">
  7. <h1>AUDI</h1>
  8. <span class="admin--logo-sub">고진모터스</span>
  9. </div>
  10. </div>
  11. <div class="admin--header-right">
  12. <button class="admin--header-btn" @click="goToProfile">
  13. 정보수정
  14. </button>
  15. <button
  16. type="button"
  17. class="admin--header-btn admin--header-btn-logout"
  18. @click.prevent="handleLogout"
  19. >
  20. 로그아웃
  21. </button>
  22. </div>
  23. </header>
  24. <!-- Main Content Area -->
  25. <div class="admin--content-wrapper">
  26. <!-- Sidebar GNB -->
  27. <aside class="admin--sidebar">
  28. <nav class="admin--gnb">
  29. <div
  30. v-for="menu in menuItems"
  31. :key="menu.id"
  32. class="admin--gnb-group"
  33. >
  34. <div
  35. class="admin--gnb-title"
  36. @click="toggleMenu(menu.id)"
  37. >
  38. {{ menu.title }}
  39. <span class="admin--gnb-arrow" :class="{ 'is-open': openMenus.includes(menu.id) }">
  40. </span>
  41. </div>
  42. <transition name="admin--submenu">
  43. <ul v-show="openMenus.includes(menu.id)" class="admin--gnb-submenu">
  44. <li
  45. v-for="submenu in menu.children"
  46. :key="submenu.path"
  47. class="admin--gnb-item"
  48. :class="{ 'is-active': isActiveRoute(submenu.path) }"
  49. >
  50. <NuxtLink :to="submenu.path" class="admin--gnb-link">
  51. {{ submenu.title }}
  52. </NuxtLink>
  53. </li>
  54. </ul>
  55. </transition>
  56. </div>
  57. </nav>
  58. </aside>
  59. <!-- Content Area -->
  60. <main class="admin--main">
  61. <!-- Breadcrumb & Title -->
  62. <div class="admin--page-header">
  63. <h2 class="admin--page-title">{{ pageTitle }}</h2>
  64. <div class="admin--breadcrumb">
  65. <span v-for="(crumb, index) in breadcrumbs" :key="index">
  66. <NuxtLink v-if="crumb.path" :to="crumb.path" class="admin--breadcrumb-link">
  67. {{ crumb.title }}
  68. </NuxtLink>
  69. <span v-else class="admin--breadcrumb-current">{{ crumb.title }}</span>
  70. <span v-if="index < breadcrumbs.length - 1" class="admin--breadcrumb-separator">/</span>
  71. </span>
  72. </div>
  73. </div>
  74. <!-- Page Content -->
  75. <div class="admin--page-content">
  76. <slot />
  77. </div>
  78. <!-- Admin Footer -->
  79. <footer class="admin--footer">
  80. <p>&copy; {{ new Date().getFullYear() }} Audi 고진모터스. All rights reserved.</p>
  81. </footer>
  82. </main>
  83. </div>
  84. <!-- 로그아웃 확인 모달 -->
  85. <AdminAlertModal
  86. v-if="showLogoutModal"
  87. title="로그아웃"
  88. message="로그아웃 하시겠습니까?"
  89. type="confirm"
  90. @confirm="confirmLogout"
  91. @cancel="closeLogoutModal"
  92. @close="closeLogoutModal"
  93. />
  94. </div>
  95. </template>
  96. <script setup>
  97. import { ref, computed } from 'vue'
  98. import { useRoute, useRouter } from 'vue-router'
  99. import AdminAlertModal from '~/components/admin/AdminAlertModal.vue'
  100. const route = useRoute()
  101. const router = useRouter()
  102. // 메뉴 열림 상태 관리
  103. const openMenus = ref(['basic', 'branch', 'staff', 'service', 'board', 'system'])
  104. // GNB 메뉴 구조
  105. const menuItems = ref([
  106. {
  107. id: 'basic',
  108. title: '기본정보관리',
  109. children: [
  110. { title: '사이트 정보', path: '/admin/basic/site-info' },
  111. { title: '팝업관리', path: '/admin/basic/popup' }
  112. ]
  113. },
  114. {
  115. id: 'branch',
  116. title: '지점장관리',
  117. children: [
  118. { title: '지점목록', path: '/admin/branch/list' },
  119. { title: '지점장목록', path: '/admin/branch/manager' }
  120. ]
  121. },
  122. {
  123. id: 'staff',
  124. title: '사원관리',
  125. children: [
  126. { title: '영업사원관리', path: '/admin/staff/sales' },
  127. { title: '어드바이저등록', path: '/admin/staff/advisor' }
  128. ]
  129. },
  130. {
  131. id: 'service',
  132. title: '서비스관리',
  133. children: [
  134. { title: '브로셔요청', path: '/admin/service/brochure' }
  135. ]
  136. },
  137. {
  138. id: 'board',
  139. title: '게시판관리',
  140. children: [
  141. { title: '이벤트', path: '/admin/board/event' },
  142. { title: '뉴스', path: '/admin/board/news' },
  143. { title: 'IR', path: '/admin/board/ir' }
  144. ]
  145. },
  146. {
  147. id: 'system',
  148. title: '시스템관리',
  149. children: [
  150. { title: '관리자관리', path: '/admin/admins' }
  151. ]
  152. }
  153. ])
  154. // 메뉴 토글
  155. const toggleMenu = (menuId) => {
  156. const index = openMenus.value.indexOf(menuId)
  157. if (index > -1) {
  158. openMenus.value.splice(index, 1)
  159. } else {
  160. openMenus.value.push(menuId)
  161. }
  162. }
  163. // 현재 활성 라우트 체크
  164. const isActiveRoute = (path) => {
  165. return route.path === path
  166. }
  167. // 페이지 타이틀 계산
  168. const pageTitle = computed(() => {
  169. for (const menu of menuItems.value) {
  170. const found = menu.children.find(child => child.path === route.path)
  171. if (found) return found.title
  172. }
  173. return '대시보드'
  174. })
  175. // Breadcrumb 계산
  176. const breadcrumbs = computed(() => {
  177. const crumbs = [{ title: 'Home', path: '/admin/dashboard' }]
  178. for (const menu of menuItems.value) {
  179. const found = menu.children.find(child => child.path === route.path)
  180. if (found) {
  181. crumbs.push({ title: menu.title, path: null })
  182. crumbs.push({ title: found.title, path: null })
  183. break
  184. }
  185. }
  186. return crumbs
  187. })
  188. // 로그아웃 모달
  189. const showLogoutModal = ref(false)
  190. const handleLogout = () => {
  191. console.log('[Logout] 로그아웃 버튼 클릭')
  192. showLogoutModal.value = true
  193. console.log('[Logout] showLogoutModal:', showLogoutModal.value)
  194. }
  195. const confirmLogout = () => {
  196. console.log('[Logout] 로그아웃 확인')
  197. localStorage.removeItem('admin_token')
  198. localStorage.removeItem('admin_user')
  199. router.push('/admin')
  200. }
  201. const closeLogoutModal = () => {
  202. console.log('[Logout] 모달 닫기')
  203. showLogoutModal.value = false
  204. }
  205. // 정보수정
  206. const goToProfile = () => {
  207. router.push('/admin/profile')
  208. }
  209. </script>