mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-06 05:49:03 +08:00
add thumbnail format settings
This commit is contained in:
@@ -11,6 +11,13 @@ enum ThumbnailMethod {
|
||||
ffmpegApi,
|
||||
}
|
||||
|
||||
enum ThumbnailFormat {
|
||||
@JsonValue(0)
|
||||
jpeg,
|
||||
@JsonValue(1)
|
||||
webp,
|
||||
}
|
||||
|
||||
enum ImportMethod {
|
||||
@JsonValue(0)
|
||||
copy,
|
||||
@@ -75,6 +82,7 @@ class Config {
|
||||
required this.importMethod,
|
||||
required this.maxImportImgCount,
|
||||
required this.enableServerTiming,
|
||||
required this.thumbnailFormat,
|
||||
});
|
||||
bool cookies;
|
||||
@JsonKey(name: 'db_path')
|
||||
@@ -141,6 +149,8 @@ class Config {
|
||||
int maxImportImgCount;
|
||||
@JsonKey(name: 'enable_server_timing')
|
||||
bool enableServerTiming;
|
||||
@JsonKey(name: 'thumbnail_format')
|
||||
ThumbnailFormat thumbnailFormat;
|
||||
factory Config.fromJson(Map<String, dynamic> json) => _$ConfigFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ConfigToJson(this);
|
||||
}
|
||||
@@ -262,6 +272,8 @@ class ConfigOptional {
|
||||
int? maxImportImgCount;
|
||||
@JsonKey(name: 'enable_server_timing')
|
||||
bool? enableServerTiming;
|
||||
@JsonKey(name: 'thumbnail_format')
|
||||
ThumbnailFormat? thumbnailFormat;
|
||||
factory ConfigOptional.fromJson(Map<String, dynamic> json) =>
|
||||
_$ConfigOptionalFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ConfigOptionalToJson(this);
|
||||
|
||||
@@ -49,6 +49,8 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config(
|
||||
importMethod: $enumDecode(_$ImportMethodEnumMap, json['import_method']),
|
||||
maxImportImgCount: (json['max_import_img_count'] as num).toInt(),
|
||||
enableServerTiming: json['enable_server_timing'] as bool,
|
||||
thumbnailFormat:
|
||||
$enumDecode(_$ThumbnailFormatEnumMap, json['thumbnail_format']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
@@ -88,6 +90,7 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'import_method': _$ImportMethodEnumMap[instance.importMethod]!,
|
||||
'max_import_img_count': instance.maxImportImgCount,
|
||||
'enable_server_timing': instance.enableServerTiming,
|
||||
'thumbnail_format': _$ThumbnailFormatEnumMap[instance.thumbnailFormat]!,
|
||||
};
|
||||
|
||||
const _$ThumbnailMethodEnumMap = {
|
||||
@@ -102,6 +105,11 @@ const _$ImportMethodEnumMap = {
|
||||
ImportMethod.keep: 3,
|
||||
};
|
||||
|
||||
const _$ThumbnailFormatEnumMap = {
|
||||
ThumbnailFormat.jpeg: 0,
|
||||
ThumbnailFormat.webp: 1,
|
||||
};
|
||||
|
||||
UpdateConfigResult _$UpdateConfigResultFromJson(Map<String, dynamic> json) =>
|
||||
UpdateConfigResult(
|
||||
isUnsafe: json['is_unsafe'] as bool,
|
||||
@@ -157,7 +165,8 @@ ConfigOptional _$ConfigOptionalFromJson(Map<String, dynamic> json) =>
|
||||
$enumDecodeNullable(_$ImportMethodEnumMap, json['import_method']),
|
||||
maxImportImgCount: (json['max_import_img_count'] as num?)?.toInt(),
|
||||
enableServerTiming: json['enable_server_timing'] as bool?,
|
||||
);
|
||||
)..thumbnailFormat =
|
||||
$enumDecodeNullable(_$ThumbnailFormatEnumMap, json['thumbnail_format']);
|
||||
|
||||
Map<String, dynamic> _$ConfigOptionalToJson(ConfigOptional instance) =>
|
||||
<String, dynamic>{
|
||||
@@ -197,4 +206,5 @@ Map<String, dynamic> _$ConfigOptionalToJson(ConfigOptional instance) =>
|
||||
'import_method': _$ImportMethodEnumMap[instance.importMethod],
|
||||
'max_import_img_count': instance.maxImportImgCount,
|
||||
'enable_server_timing': instance.enableServerTiming,
|
||||
'thumbnail_format': _$ThumbnailFormatEnumMap[instance.thumbnailFormat],
|
||||
};
|
||||
|
||||
@@ -331,5 +331,7 @@
|
||||
"updateTagTranslation": "Update tag's translation",
|
||||
"createUpdateTagTranslationTask": "Create update tag's translation task",
|
||||
"translationFile": "Tnanslation file",
|
||||
"translationFileHelp": "The path to json file contains tag's translation. Will download from website if this is empty."
|
||||
"translationFileHelp": "The path to json file contains tag's translation. Will download from website if this is empty.",
|
||||
"thumbnailFormat": "Thumbnail format",
|
||||
"thumbnailFormatHelp": "Webp is not supported in ffmpeg API method."
|
||||
}
|
||||
|
||||
@@ -331,5 +331,7 @@
|
||||
"updateTagTranslation": "更新标签的翻译",
|
||||
"createUpdateTagTranslationTask": "创建更新标签翻译的任务",
|
||||
"translationFile": "翻译文件",
|
||||
"translationFileHelp": "包含标签翻译的JSON文件路径。未指定时将从网站上下载。"
|
||||
"translationFileHelp": "包含标签翻译的JSON文件路径。未指定时将从网站上下载。",
|
||||
"thumbnailFormat": "缩略图格式",
|
||||
"thumbnailFormatHelp": "ffmpeg API方式不支持webp格式。"
|
||||
}
|
||||
|
||||
@@ -787,6 +787,27 @@ class _ServerSettingsPage extends State<ServerSettingsPage>
|
||||
});
|
||||
},
|
||||
)),
|
||||
_buildWithVecticalPadding(DropdownButtonFormField<ThumbnailFormat>(
|
||||
items: ThumbnailFormat.values
|
||||
.map((e) => DropdownMenuItem(
|
||||
value: e,
|
||||
child: Text(
|
||||
e.toString().replaceFirst("ThumbnailFormat.", ""))))
|
||||
.toList(),
|
||||
onChanged: (v) {
|
||||
if (v != null) {
|
||||
setState(() {
|
||||
_now.thumbnailFormat = v;
|
||||
_changed = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
value: _now.thumbnailFormat ?? _config!.thumbnailFormat,
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: i18n.thumbnailFormat,
|
||||
helperText: i18n.thumbnailFormatHelp,
|
||||
))),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user