From c0a54bb64ceeccd6af67731f0ea9a1e91c224395 Mon Sep 17 00:00:00 2001 From: sohot8653 Date: Wed, 24 Sep 2025 17:21:19 +0900 Subject: [PATCH] =?UTF-8?q?[=ED=83=AD=20=EB=B0=8F=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=20=EA=B0=9C=EC=84=A0]=20TabBar?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9D=B4=EB=AF=B8=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=EB=90=9C=20=ED=83=AD=20=ED=81=B4=EB=A6=AD=20=EC=8B=9C?= =?UTF-8?q?=20=EB=8F=99=EC=9E=91=20=EB=B0=A9=EC=A7=80=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80,=20=EA=B6=8C=ED=95=9C=20=EB=A6=AC?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=BD=94=EB=93=9C=EB=A1=9C=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80,=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=A1=9C=EB=94=A9=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=A0=9C=EA=B1=B0,=20=ED=83=AD=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=EC=8A=A4=ED=86=A0=EC=96=B4=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=ED=83=AD=20=EC=B2=B4=ED=81=AC=20=EB=B0=8F?= =?UTF-8?q?=20=ED=99=9C=EC=84=B1=20=ED=83=AD=20=EC=A0=84=ED=99=98=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/layout/TabBar.vue | 9 ++++++++- composables/usePermission.ts | 7 +++++++ pages/[tabId]/test/permission-test.vue | 4 ---- stores/tab.ts | 14 +++++++++++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/components/layout/TabBar.vue b/components/layout/TabBar.vue index 0fc3060..80bc3c5 100644 --- a/components/layout/TabBar.vue +++ b/components/layout/TabBar.vue @@ -25,7 +25,14 @@ import { useTabsStore } from "@/stores/tab"; const tabsStore = useTabsStore(); -const handleTabClick = (tabKey: number) => tabsStore.setActiveTab(tabKey); +const handleTabClick = (tabKey: number) => { + // 이미 활성화된 탭이면 아무것도 하지 않음 + if (tabsStore.activeTab === tabKey) { + return; + } + + tabsStore.setActiveTab(tabKey); +}; const handleTabClose = (tabKey: number) => tabsStore.removeTab(tabKey); diff --git a/composables/usePermission.ts b/composables/usePermission.ts index d25424c..35fcc64 100644 --- a/composables/usePermission.ts +++ b/composables/usePermission.ts @@ -28,5 +28,12 @@ export const usePermission = () => { getPages: () => permissionsStore.permissions?.resources?.pages || [], getComponents: () => permissionsStore.permissions?.resources?.components || [], + + // 코드로 리소스 찾기 + getResourceByCode: (code: string) => { + const components = + permissionsStore.permissions?.resources?.components || []; + return components.find(component => component.code === code); + }, }; }; diff --git a/pages/[tabId]/test/permission-test.vue b/pages/[tabId]/test/permission-test.vue index e7f162a..6bc8602 100644 --- a/pages/[tabId]/test/permission-test.vue +++ b/pages/[tabId]/test/permission-test.vue @@ -30,10 +30,6 @@ userStore.user.userId }})

-

- 권한 로딩: - {{ permission.isLoading.value ? "로딩 중..." : "완료" }} -

참고: 로그인이 필요합니다. 로그인 후 권한 데이터가 자동으로 로드됩니다. diff --git a/stores/tab.ts b/stores/tab.ts index 78592d3..a539652 100644 --- a/stores/tab.ts +++ b/stores/tab.ts @@ -15,12 +15,24 @@ export const useTabsStore = defineStore("tabs", { activeTab: 1, }), actions: { - // 서브메뉴 클릭 시 새 탭 생성 + // 서브메뉴 클릭 시 새 탭 생성 (중복 체크 추가) async updateActiveTab(sub: { label: string; to: string; componentName: string; }) { + // 이미 동일한 페이지가 열려있는지 확인 + const existingTab = this.tabs.find( + tab => tab.to === sub.to && tab.componentName === sub.componentName + ); + + if (existingTab) { + // 이미 동일한 페이지가 열려있으면 해당 탭으로 이동 + this.activeTab = existingTab.key; + await navigateTo(`/${existingTab.key}${existingTab.to}`); + return; + } + if (this.tabs.length > 10) { alert("탭은 최대 10개까지 열 수 있습니다."); return;