feat: ajout de la fonctionnalité de récupération des chapitres de manga, avec mise à jour de l'API et des composants pour gérer la récupération asynchrone des chapitres, ainsi que des améliorations dans la gestion des erreurs et des tests associés.
This commit is contained in:
parent
5a5569cf2c
commit
ee2a9b3750
@@ -189,6 +189,22 @@ export const useMangaStore = defineStore('manga', {
|
||||
}
|
||||
},
|
||||
|
||||
async fetchMangaChapters(mangaId) {
|
||||
if (this.loadingChapters) return;
|
||||
this.loadingChapters = true;
|
||||
this.chaptersError = null;
|
||||
|
||||
try {
|
||||
await mangaRepository.fetchMangaChapters(mangaId);
|
||||
this.mangaChapters[mangaId] = chaptersData;
|
||||
console.log('Chapitres récupérés avec succès');
|
||||
} catch (err) {
|
||||
this.chaptersError = err.message;
|
||||
} finally {
|
||||
this.loadingChapters = false;
|
||||
}
|
||||
},
|
||||
|
||||
// --- Scrape Chapter Action ---
|
||||
async searchChapter(chapterId) {
|
||||
try {
|
||||
|
||||
@@ -123,6 +123,25 @@ export class ApiMangaRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async fetchMangaChapters(mangaId) {
|
||||
try {
|
||||
const response = await fetch(`/api/manga/chapters/fetch`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ mangaId })
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch manga chapters');
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('API Error:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async searchChapter(chapterId) {
|
||||
try {
|
||||
const response = await fetch('/api/scraping/chapters', {
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
|
||||
try {
|
||||
await mangaStore.createFromMangaDex(selectedManga.value.externalId);
|
||||
await mangaStore.fetchMangaChapters(selectedManga.value.id);
|
||||
router.push('/manga');
|
||||
} catch (e) {
|
||||
console.error("Erreur d'ajout:", e);
|
||||
|
||||
Reference in New Issue
Block a user