mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
introduce notification type
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
enum NotificationType {
|
||||
Success,
|
||||
Error,
|
||||
}
|
||||
|
||||
const useNotificationStore = defineStore("notification", {
|
||||
state: () => ({
|
||||
text: "",
|
||||
type: NotificationType.Success,
|
||||
visible: false,
|
||||
}),
|
||||
actions: {
|
||||
showNotification(new_text: string) {
|
||||
showNotification(new_text: string, new_type?: NotificationType) {
|
||||
console.log(arguments);
|
||||
this.text = new_text;
|
||||
this.type = new_type;
|
||||
this.visible = true;
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -18,9 +26,9 @@ const useNotificationStore = defineStore("notification", {
|
||||
});
|
||||
|
||||
class Notification {
|
||||
constructor(text: string) {
|
||||
useNotificationStore().showNotification(text);
|
||||
constructor(text: string, type?: NotificationType) {
|
||||
useNotificationStore().showNotification(text, type);
|
||||
}
|
||||
}
|
||||
|
||||
export { useNotificationStore, Notification };
|
||||
export { useNotificationStore, Notification, NotificationType };
|
||||
|
||||
Reference in New Issue
Block a user