mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
35 lines
728 B
TypeScript
35 lines
728 B
TypeScript
import { defineStore } from "pinia";
|
|
|
|
enum NotificationType {
|
|
Success,
|
|
Error,
|
|
}
|
|
|
|
const useNotificationStore = defineStore("notification", {
|
|
state: () => ({
|
|
text: "",
|
|
type: NotificationType.Success,
|
|
visible: false,
|
|
}),
|
|
actions: {
|
|
showNotification(new_text: string, new_type?: NotificationType) {
|
|
console.log(arguments);
|
|
this.text = new_text;
|
|
this.type = new_type;
|
|
this.visible = true;
|
|
|
|
setTimeout(() => {
|
|
this.visible = false;
|
|
}, 2000);
|
|
},
|
|
},
|
|
});
|
|
|
|
class Notification {
|
|
constructor(text: string, type?: NotificationType) {
|
|
useNotificationStore().showNotification(text, type);
|
|
}
|
|
}
|
|
|
|
export { useNotificationStore, Notification, NotificationType };
|