修正UNKNOWN状态

This commit is contained in:
mtvpls
2026-04-17 21:07:17 +08:00
parent f289607c36
commit 92a7a0d8a7
+29 -4
View File
@@ -75,6 +75,31 @@ export function buildSuwayomiImageProxyUrl(pathOrUrl: string): string {
return `/api/manga/image?path=${encodeURIComponent(pathOrUrl)}`; return `/api/manga/image?path=${encodeURIComponent(pathOrUrl)}`;
} }
function normalizeMangaStatus(status?: string): string | undefined {
if (!status) return undefined;
const normalized = status.trim().toUpperCase();
switch (normalized) {
case 'ONGOING':
return '连载中';
case 'COMPLETED':
return '已完结';
case 'LICENSED':
return '已授权';
case 'PUBLISHING_FINISHED':
return '已完结';
case 'CANCELLED':
return '已取消';
case 'ON_HIATUS':
return '休刊中';
case 'UNKNOWN':
case 'UNRECOGNIZED':
return undefined;
default:
return status;
}
}
export class SuwayomiClient { export class SuwayomiClient {
private options: SuwayomiClientOptions; private options: SuwayomiClientOptions;
@@ -210,7 +235,7 @@ export class SuwayomiClient {
author: manga.author, author: manga.author,
artist: manga.artist, artist: manga.artist,
genre: manga.genre, genre: manga.genre,
status: manga.status, status: normalizeMangaStatus(manga.status),
}); });
} }
} }
@@ -292,7 +317,7 @@ export class SuwayomiClient {
author: manga.author, author: manga.author,
artist: manga.artist, artist: manga.artist,
genre: manga.genre, genre: manga.genre,
status: manga.status, status: normalizeMangaStatus(manga.status),
})), })),
}; };
} }
@@ -410,7 +435,7 @@ export class SuwayomiClient {
author: detailData.manga.author || metadata.author, author: detailData.manga.author || metadata.author,
artist: detailData.manga.artist, artist: detailData.manga.artist,
genre: detailData.manga.genre, genre: detailData.manga.genre,
status: detailData.manga.status || metadata.status, status: normalizeMangaStatus(detailData.manga.status) || normalizeMangaStatus(metadata.status),
}; };
} }
} catch { } catch {
@@ -427,7 +452,7 @@ export class SuwayomiClient {
author: metadata.author, author: metadata.author,
artist: metadata.artist, artist: metadata.artist,
genre: metadata.genre, genre: metadata.genre,
status: metadata.status, status: normalizeMangaStatus(metadata.status),
chapters, chapters,
}; };
} }