[UI 개선] AppHeader에서 HOME 메뉴 제거, TabBar에서 탭 추가 버튼 및 관련 로직 삭제, 탭 관리 스토어에서 HOME 탭 제거 방지 및 서브메뉴 클릭 시 새 탭 생성 로직 수정

This commit is contained in:
2025-09-24 16:52:48 +09:00
parent 19bda71444
commit 41523a57b3
3 changed files with 20 additions and 65 deletions

View File

@@ -15,39 +15,34 @@ export const useTabsStore = defineStore("tabs", {
activeTab: 1,
}),
actions: {
// 새 탭 추가 (기본 페이지는 "/")
async addTab() {
if (this.tabs.length >= 10) {
alert("탭은 최대 10개까지 열 수 있습니다.");
return;
}
// 빈 key 찾기
let key = 1;
while (this.tabs.find(t => t.key === key)) key++;
this.tabs.push({ ...defaultTab, key: key });
this.activeTab = key;
await navigateTo(defaultTab.to);
return key;
},
// 활성 탭 내용 변경 (서브메뉴 클릭)
// 서브메뉴 클릭 시 새 탭 생성
async updateActiveTab(sub: {
label: string;
to: string;
componentName: string;
}) {
const tab = this.tabs.find(t => t.key === this.activeTab);
if (tab) {
tab.label = sub.label;
tab.to = sub.to;
tab.componentName = sub.componentName;
if (this.tabs.length > 10) {
alert("탭은 최대 10개까지 열 수 있습니다.");
return;
}
await navigateTo(`/${tab?.key}${tab?.to}`);
// 빈 key 찾기
let newKey = 1;
while (this.tabs.find(t => t.key === newKey)) newKey++;
this.tabs.push({
key: newKey,
label: sub.label,
to: sub.to,
componentName: sub.componentName,
});
this.activeTab = newKey;
await navigateTo(`/${newKey}${sub.to}`);
},
// 활성 탭 제거
// 활성 탭 제거 (HOME 탭 보호)
removeTab(key: number) {
if (key === 1) return; // HOME 탭은 제거 금지
this.tabs = this.tabs.filter(t => t.key !== key);
if (this.activeTab === key) {
this.activeTab = this.tabs.length
@@ -58,7 +53,6 @@ export const useTabsStore = defineStore("tabs", {
// 활성 탭 변경
async setActiveTab(key: number) {
console.log("tab.ts - setActiveTab", key);
this.activeTab = key;
const tab = this.tabs.find(t => t.key === this.activeTab);
@@ -67,12 +61,8 @@ export const useTabsStore = defineStore("tabs", {
// 탭 초기화
resetTabs() {
console.log("tab.ts - resetTabs");
this.tabs = [{ ...defaultTab }];
this.activeTab = 1;
console.log("tab.ts - tabs:", this.tabs);
console.log("tab.ts - activeTab:", this.activeTab);
console.log("tab.ts - resetTabs 완료");
},
},
persist: true,