localhost-front/src/stores/toastStore.js
2025-01-10 15:21:47 +09:00

29 lines
618 B
JavaScript

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