[라우터 방식 변경]

This commit is contained in:
2025-09-24 16:35:52 +09:00
parent f9dde4eb09
commit 19bda71444
5 changed files with 19 additions and 25 deletions

View File

@@ -16,9 +16,7 @@ export const useTabsStore = defineStore("tabs", {
}),
actions: {
// 새 탭 추가 (기본 페이지는 "/")
addTab() {
const { $router } = useNuxtApp();
async addTab() {
if (this.tabs.length >= 10) {
alert("탭은 최대 10개까지 열 수 있습니다.");
return;
@@ -29,21 +27,23 @@ export const useTabsStore = defineStore("tabs", {
this.tabs.push({ ...defaultTab, key: key });
this.activeTab = key;
$router.push(defaultTab.to);
await navigateTo(defaultTab.to);
return key;
},
// 활성 탭 내용 변경 (서브메뉴 클릭)
updateActiveTab(sub: { label: string; to: string; componentName: string }) {
const { $router } = useNuxtApp();
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;
}
$router.push(`/${tab?.key}${tab?.to}`);
await navigateTo(`/${tab?.key}${tab?.to}`);
},
// 활성 탭 제거
@@ -57,13 +57,12 @@ export const useTabsStore = defineStore("tabs", {
},
// 활성 탭 변경
setActiveTab(key: number) {
async setActiveTab(key: number) {
console.log("tab.ts - setActiveTab", key);
const { $router } = useNuxtApp();
this.activeTab = key;
const tab = this.tabs.find(t => t.key === this.activeTab);
$router.push(`/${tab?.key}${tab?.to}`);
await navigateTo(`/${tab?.key}${tab?.to}`);
},
// 탭 초기화