[설정 및 상태 관리 개선] Nuxt 설정에 pinia-plugin-persistedstate 추가, package.json 및 package-lock.json 업데이트, tab 및 user 스토어에 persist 기능 적용

This commit is contained in:
2025-08-28 16:59:15 +09:00
parent 285a2662b7
commit 791d21d052
5 changed files with 168 additions and 122 deletions

View File

@@ -1,9 +1,9 @@
import { defineStore } from "pinia";
interface Tab {
key: number; // 1~10
key: number; // 1~10
label: string;
to: string; // 페이지 라우트
to: string; // 페이지 라우트
componentName: string;
}
@@ -12,7 +12,7 @@ const defaultTab = { key: 1, label: "홈", to: "/", componentName: "home" };
export const useTabsStore = defineStore("tabs", {
state: () => ({
tabs: [defaultTab] as Tab[],
activeTab: 1
activeTab: 1,
}),
actions: {
// ✅ 새 탭 추가 (기본 페이지는 "/")
@@ -27,7 +27,7 @@ export const useTabsStore = defineStore("tabs", {
let key = 1;
while (this.tabs.find(t => t.key === key)) key++;
this.tabs.push({...defaultTab, key : key});
this.tabs.push({ ...defaultTab, key: key });
this.activeTab = key;
$router.push(defaultTab.to);
return key;
@@ -49,7 +49,9 @@ export const useTabsStore = defineStore("tabs", {
removeTab(key: number) {
this.tabs = this.tabs.filter(t => t.key !== key);
if (this.activeTab === key) {
this.activeTab = this.tabs.length ? this.tabs[this.tabs.length - 1].key : 0;
this.activeTab = this.tabs.length
? this.tabs[this.tabs.length - 1].key
: 0;
}
},
@@ -59,6 +61,7 @@ export const useTabsStore = defineStore("tabs", {
const tab = this.tabs.find(t => t.key === this.activeTab);
$router.push(`/${tab?.key}${tab?.to}`);
}
}
},
},
persist: true,
});