solve issue #19
This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
import { defineStore, acceptHMRUpdate } from 'pinia'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
export const useNotifications = defineStore('notifications', {
|
||||
state: () => {
|
||||
return {
|
||||
/**@type {{type: string, text: string, randomKey: string}[]} */
|
||||
notifications: new Array<{type: string, text: string, randomKey: string}>()
|
||||
/**@type {Map<string, {type: string, text: string}>} */
|
||||
notifications: new Map<string, {type: string, text: string}>()
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
removeAlert(index : number) : void {
|
||||
this.notifications.splice(index, 1)
|
||||
remove(id : string) : void {
|
||||
this.notifications.delete(id)
|
||||
},
|
||||
|
||||
add(type : string, text: string) : void {
|
||||
this.notifications.set(
|
||||
uuidv4(),
|
||||
{
|
||||
type:type,
|
||||
text:text,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user