feat: error response interceptor
This commit is contained in:
parent
a27dda4300
commit
3a310ef9db
3 changed files with 88 additions and 0 deletions
28
Services/client/src/stores/error.ts
Normal file
28
Services/client/src/stores/error.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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 }
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue