import { defineStore } from 'pinia'; export const useToastStore = defineStore('toastStore', { state: () => ({ toastModal: false, toastMsg: '', time: 2000, toastType: 'success', // 'success' 또는 'error' }), actions: { onToast(msg = '', time = 2000, type = 'success') { this.toastModal = true; this.toastMsg = msg; this.time = time; this.toastType = type; // 시간이 지난 후 토스트 숨기기 setTimeout(() => { this.offToast(); }, this.time); }, offToast() { this.toastModal = false; this.toastMsg = ''; this.toastType = 'success'; // 기본 상태로 초기화 }, }, });