feat: ajout de la fonctionnalité de monitoring des mangas, incluant l'activation et la désactivation du suivi, la synchronisation des chapitres, et la mise à jour de l'API pour gérer ces nouvelles actions. Création de nouveaux composants Vue pour le rafraîchissement des chapitres et l'affichage des notifications. Intégration de tests unitaires pour valider le bon fonctionnement de ces fonctionnalités.
This commit is contained in:
parent
d9e78b5229
commit
00d63dffeb
65
assets/vue/app/shared/composables/useNotifications.js
Normal file
65
assets/vue/app/shared/composables/useNotifications.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
const notifications = ref([]);
|
||||
let nextId = 1;
|
||||
|
||||
export function useNotifications() {
|
||||
const addNotification = (message, type = 'info', duration = 4000) => {
|
||||
const notification = {
|
||||
id: nextId++,
|
||||
message,
|
||||
type, // 'success', 'error', 'warning', 'info'
|
||||
duration,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
|
||||
notifications.value.push(notification);
|
||||
|
||||
// Auto-remove après la durée spécifiée
|
||||
if (duration > 0) {
|
||||
setTimeout(() => {
|
||||
removeNotification(notification.id);
|
||||
}, duration);
|
||||
}
|
||||
|
||||
return notification.id;
|
||||
};
|
||||
|
||||
const removeNotification = (id) => {
|
||||
const index = notifications.value.findIndex(n => n.id === id);
|
||||
if (index > -1) {
|
||||
notifications.value.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
const clearAll = () => {
|
||||
notifications.value = [];
|
||||
};
|
||||
|
||||
const showSuccess = (message, duration = 4000) => {
|
||||
return addNotification(message, 'success', duration);
|
||||
};
|
||||
|
||||
const showError = (message, duration = 6000) => {
|
||||
return addNotification(message, 'error', duration);
|
||||
};
|
||||
|
||||
const showWarning = (message, duration = 5000) => {
|
||||
return addNotification(message, 'warning', duration);
|
||||
};
|
||||
|
||||
const showInfo = (message, duration = 4000) => {
|
||||
return addNotification(message, 'info', duration);
|
||||
};
|
||||
|
||||
return {
|
||||
notifications,
|
||||
addNotification,
|
||||
removeNotification,
|
||||
clearAll,
|
||||
showSuccess,
|
||||
showError,
|
||||
showWarning,
|
||||
showInfo
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user