[탭 및 권한 시스템 개선] TabBar에서 이미 활성화된 탭 클릭 시 동작 방지 로직 추가, 권한 리소스 코드로 검색 기능 추가, 권한 테스트 페이지에서 불필요한 로딩 메시지 제거, 탭 관리 스토어에서 중복 탭 체크 및 활성 탭 전환 로직 개선
This commit is contained in:
@@ -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);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
userStore.user.userId
|
||||
}})
|
||||
</p>
|
||||
<p>
|
||||
<strong>권한 로딩:</strong>
|
||||
{{ permission.isLoading.value ? "로딩 중..." : "완료" }}
|
||||
</p>
|
||||
<p v-if="!userStore.isLoggedIn" class="text-orange-600 text-sm">
|
||||
<strong>참고:</strong> 로그인이 필요합니다. 로그인 후 권한 데이터가
|
||||
자동으로 로드됩니다.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user