feat: 添加画廊列表显示模式和合并功能,优化画廊列表卡片组件

This commit is contained in:
2025-03-08 17:11:16 +08:00
parent 5f92d036fa
commit e64910d572
9 changed files with 183 additions and 6 deletions

View File

@@ -239,10 +239,10 @@ class GMetaSearchInfo {
}
class GalleryThumbnails {
const GalleryThumbnails({
GalleryThumbnails({
required this.thumbnails,
});
final Map<int, ApiResult<ExtendedPMeta>> thumbnails;
Map<int, ApiResult<ExtendedPMeta>> thumbnails;
factory GalleryThumbnails.fromJson(Map<String, dynamic> json) =>
GalleryThumbnails(
thumbnails: json.map((key, value) => MapEntry(
@@ -251,4 +251,17 @@ class GalleryThumbnails {
value as Map<String, dynamic>,
(json) =>
ExtendedPMeta.fromJson(json as Map<String, dynamic>)))));
void merge(GalleryThumbnails another) {
another.thumbnails.forEach((key, value) {
if (thumbnails.containsKey(key)) {
if (value.ok) {
thumbnails[key] = value;
} else if (!thumbnails[key]!.ok) {
thumbnails[key] = value;
}
} else {
thumbnails[key] = value;
}
});
}
}