[폴더, 파일 구조 정리]

This commit is contained in:
2025-09-25 15:33:11 +09:00
parent 51019d7f5f
commit ded762517e
30 changed files with 644 additions and 770 deletions

View File

@@ -0,0 +1,223 @@
<template>
<header
class="w-full bg-white shadow flex items-center justify-center px-4 h-24 relative"
>
<nav class="flex justify-center space-x-4">
<!-- 권한 기반 메뉴 -->
<button
v-for="menu in availableMenus"
:key="menu.code"
class="menu-btn"
:class="{ active: modelValue === menu.code }"
@click="onMenuClick(menu.code)"
>
{{ menu.name }}
</button>
</nav>
<!-- 사용자 정보 드롭다운 -->
<div class="user-menu-wrapper">
<div class="user-info" @click="toggleDropdown">
<span class="user-name">{{ userStore.user?.name }}</span>
<div class="user-icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#222"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="8" r="4" />
<path d="M4 20c0-2.5 3.5-4 8-4s8 1.5 8 4" />
</svg>
</div>
</div>
<div v-show="showDropdown" class="user-dropdown">
<div class="dropdown-divider"></div>
<button class="logout-btn" @click="logout">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path>
<polyline points="16,17 21,12 16,7"></polyline>
<line x1="21" y1="12" x2="9" y2="12"></line>
</svg>
로그아웃
</button>
</div>
</div>
</header>
</template>
<script setup lang="ts">
const modelValue = defineModel({ type: String, required: true });
const showDropdown = ref(false);
const userStore = useUserStore();
const permissionStore = usePermissionsStore();
// 권한이 있고 메뉴에 표시할 페이지그룹들만 필터링
const availableMenus = computed(() => {
return permissionStore.permissions.resources.pageGroups.filter(pageGroup => {
return (
permissionStore.hasPageGroupPermission(pageGroup.code) &&
pageGroup.menuYn === "Y"
);
});
});
// 메뉴 클릭 핸들러
function onMenuClick(menu: string) {
modelValue.value = menu;
}
function toggleDropdown() {
showDropdown.value = !showDropdown.value;
}
function handleClickOutside(event: MouseEvent) {
const menu = document.querySelector(".user-menu-wrapper");
if (menu && !menu.contains(event.target as Node)) {
showDropdown.value = false;
}
}
async function logout() {
showDropdown.value = false;
userStore.logout();
}
onMounted(() => {
window.addEventListener("click", handleClickOutside);
});
onBeforeUnmount(() => {
window.removeEventListener("click", handleClickOutside);
});
</script>
<style scoped>
.menu-btn {
font-size: 1.08rem;
font-weight: 500;
color: #222;
background: none;
border: none;
padding: 0.5rem 1.5rem;
border-radius: 6px;
transition:
background 0.15s,
color 0.15s;
cursor: pointer;
}
.menu-btn.active {
background: none;
color: #1976d2;
}
.menu-btn:hover {
background: #e6f0fa;
color: #1976d2;
}
.group:hover .group-hover\:opacity-100 {
opacity: 1 !important;
pointer-events: auto !important;
}
.group-hover\:pointer-events-auto {
pointer-events: auto;
}
.user-menu-wrapper {
position: absolute;
right: 2rem;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
}
.user-info {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
padding: 8px 12px;
border-radius: 8px;
transition: background 0.15s;
}
.user-info:hover {
background: #f5f5f5;
}
.user-name {
font-size: 0.9rem;
font-weight: 500;
color: #333;
}
.user-icon {
width: 32px;
height: 32px;
border-radius: 50%;
background: #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
}
.user-dropdown {
position: absolute;
top: 48px;
right: 0;
min-width: 200px;
background: #fff;
border-radius: 12px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
padding: 1rem;
z-index: 10;
display: flex;
flex-direction: column;
align-items: flex-start;
}
.user-details {
width: 100%;
margin-bottom: 8px;
}
.user-email {
font-size: 0.85rem;
color: #666;
margin: 0 0 4px 0;
}
.user-role {
font-size: 0.8rem;
color: #888;
margin: 0;
font-weight: 500;
}
.dropdown-divider {
width: 100%;
height: 1px;
background: #e0e0e0;
margin: 8px 0;
}
.logout-btn {
background: none;
border: none;
color: #d32f2f;
font-size: 0.9rem;
font-weight: 500;
cursor: pointer;
padding: 8px 0;
width: 100%;
text-align: left;
border-radius: 6px;
transition: background 0.15s;
display: flex;
align-items: center;
gap: 8px;
}
.logout-btn:hover {
background: #fbe9e7;
}
</style>

View File

@@ -0,0 +1,66 @@
<template>
<nav
v-if="showSubmenuBar && subMenus.length > 0"
class="w-full bg-gray-100 shadow-sm px-4 py-2"
>
<div class="flex items-center space-x-6">
<span class="text-sm font-medium text-gray-600 mr-4">
{{ activeMenu }}
</span>
<div class="flex space-x-4">
<button
v-for="sub in subMenus"
:key="sub.key"
class="submenu-btn"
@click="onSubMenuClick(sub)"
>
{{ sub.label }}
</button>
</div>
</div>
</nav>
</template>
<script setup lang="ts">
interface SubMenu {
key: string;
label: string;
to: string;
componentName: string;
}
interface Props {
showSubmenuBar: boolean;
activeMenu: string;
subMenus: SubMenu[];
}
interface Emits {
(e: "submenu-click", sub: SubMenu): void;
}
defineProps<Props>();
const emit = defineEmits<Emits>();
function onSubMenuClick(sub: SubMenu) {
emit("submenu-click", sub);
}
</script>
<style scoped>
.submenu-btn {
padding: 0.25rem 0.75rem;
font-size: 0.875rem;
color: #374151;
background: none;
border: none;
border-radius: 0.25rem;
cursor: pointer;
transition: all 0.15s ease;
}
.submenu-btn:hover {
color: #2563eb;
background-color: #eff6ff;
}
</style>

View File

@@ -0,0 +1,116 @@
<template>
<div class="tab-bar">
<div
v-for="tab in tabsStore.tabs"
:key="tab.key"
class="tab-item"
:class="{ active: tabsStore.activeTab === tab.key }"
@click="handleTabClick(tab.key)"
>
<span class="tab-label">{{ tab.label }}</span>
<button
v-if="tab.key !== 1 && tabsStore.activeTab !== tab.key"
class="close-btn"
type="button"
@click.stop="handleTabClose(tab.key)"
>
×
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { useTabsStore } from "@/stores/tab";
const tabsStore = useTabsStore();
const handleTabClick = (tabKey: number) => {
// 이미 활성화된 탭이면 아무것도 하지 않음
if (tabsStore.activeTab === tabKey) {
return;
}
tabsStore.setActiveTab(tabKey);
};
const handleTabClose = (tabKey: number) => tabsStore.removeTab(tabKey);
</script>
<style scoped>
.tab-bar {
display: flex;
gap: 0.5rem;
padding: 0.75rem 1rem;
background: #ffffff;
border-bottom: 1px solid #e5e7eb;
overflow-x: auto;
scrollbar-width: none;
-ms-overflow-style: none;
}
.tab-bar::-webkit-scrollbar {
display: none;
}
.tab-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 0.5rem;
cursor: pointer;
transition: all 0.2s ease;
white-space: nowrap;
min-width: fit-content;
position: relative;
}
.tab-item:hover {
background: #f1f5f9;
border-color: #cbd5e1;
}
.tab-item.active {
background: #3b82f6;
border-color: #3b82f6;
color: #ffffff;
}
.tab-item.active:hover {
background: #2563eb;
border-color: #2563eb;
}
.tab-label {
font-size: 0.875rem;
font-weight: 500;
line-height: 1.25rem;
}
.close-btn {
display: flex;
align-items: center;
justify-content: center;
width: 1.25rem;
height: 1.25rem;
background: transparent;
border: none;
border-radius: 0.25rem;
cursor: pointer;
font-size: 1rem;
line-height: 1;
color: inherit;
transition: background-color 0.2s ease;
flex-shrink: 0;
}
.close-btn:hover {
background: rgba(0, 0, 0, 0.1);
}
.tab-item.active .close-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
</style>