29 lines
618 B
JavaScript
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';
|
|
},
|
|
},
|
|
});
|