hrms-edm/Services/client/src/stores/error.ts
2023-11-30 15:36:03 +07:00

28 lines
635 B
TypeScript

import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useErrorStore = defineStore('error-data', () => {
const visible = ref<boolean>(false)
const title = ref<string>('')
const msg = ref<string>('')
function set(obj: { title: string; msg: string }, timeout?: number) {
title.value = obj.title
msg.value = obj.msg
show(timeout)
}
function show(timeout: number = -1) {
visible.value = true
if (timeout > 0) {
setTimeout(() => (visible.value = false), timeout)
}
}
function hide() {
visible.value = false
}
return { visible, title, msg, show, hide, set }
})