From f9e920cc57a207e35acb32bd627e3bf470f35c72 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 17 Feb 2024 21:47:24 +0800 Subject: [PATCH] Add new server settings --- lib/api/config.dart | 6 ++++++ lib/api/config.g.dart | 4 ++++ lib/l10n/app_en.arb | 4 +++- lib/l10n/app_zh.arb | 4 +++- lib/server_settings.dart | 16 ++++++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/api/config.dart b/lib/api/config.dart index 4630ca0..8ff222b 100644 --- a/lib/api/config.dart +++ b/lib/api/config.dart @@ -41,6 +41,7 @@ class Config { required this.ffprobePath, required this.redirectToFlutter, required this.downloadTimeoutCheckInterval, + required this.ehMetadataCacheTime, }); bool cookies; @JsonKey(name: 'db_path') @@ -93,6 +94,8 @@ class Config { bool redirectToFlutter; @JsonKey(name: 'download_timeout_check_interval') int downloadTimeoutCheckInterval; + @JsonKey(name: "eh_metadata_cache_time") + int ehMetadataCacheTime; factory Config.fromJson(Map json) => _$ConfigFromJson(json); Map toJson() => _$ConfigToJson(this); } @@ -141,6 +144,7 @@ class ConfigOptional { this.ffprobePath, this.redirectToFlutter, this.downloadTimeoutCheckInterval, + this.ehMetadataCacheTime, }); String? cookies; @JsonKey(name: 'db_path') @@ -193,6 +197,8 @@ class ConfigOptional { bool? redirectToFlutter; @JsonKey(name: 'download_timeout_check_interval') int? downloadTimeoutCheckInterval; + @JsonKey(name: "eh_metadata_cache_time") + int? ehMetadataCacheTime; factory ConfigOptional.fromJson(Map json) => _$ConfigOptionalFromJson(json); Map toJson() => _$ConfigOptionalToJson(this); diff --git a/lib/api/config.g.dart b/lib/api/config.g.dart index e3e5424..3db26ca 100644 --- a/lib/api/config.g.dart +++ b/lib/api/config.g.dart @@ -42,6 +42,7 @@ Config _$ConfigFromJson(Map json) => Config( redirectToFlutter: json['redirect_to_flutter'] as bool, downloadTimeoutCheckInterval: json['download_timeout_check_interval'] as int, + ehMetadataCacheTime: json['eh_metadata_cache_time'] as int, ); Map _$ConfigToJson(Config instance) => { @@ -74,6 +75,7 @@ Map _$ConfigToJson(Config instance) => { 'ffprobe_path': instance.ffprobePath, 'redirect_to_flutter': instance.redirectToFlutter, 'download_timeout_check_interval': instance.downloadTimeoutCheckInterval, + 'eh_metadata_cache_time': instance.ehMetadataCacheTime, }; const _$ThumbnailMethodEnumMap = { @@ -128,6 +130,7 @@ ConfigOptional _$ConfigOptionalFromJson(Map json) => redirectToFlutter: json['redirect_to_flutter'] as bool?, downloadTimeoutCheckInterval: json['download_timeout_check_interval'] as int?, + ehMetadataCacheTime: json['eh_metadata_cache_time'] as int?, ); Map _$ConfigOptionalToJson(ConfigOptional instance) => @@ -161,4 +164,5 @@ Map _$ConfigOptionalToJson(ConfigOptional instance) => 'ffprobe_path': instance.ffprobePath, 'redirect_to_flutter': instance.redirectToFlutter, 'download_timeout_check_interval': instance.downloadTimeoutCheckInterval, + 'eh_metadata_cache_time': instance.ehMetadataCacheTime, }; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 66f8c1e..e1253b2 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -149,5 +149,7 @@ "running": "Running", "finished": "Finished", "failed": "Failed", - "allTasks": "All Tasks" + "allTasks": "All Tasks", + "ehMetadataCacheTime": "The time to cache the metadata of the gallery from E-Hentai", + "hour": "hour" } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 9a010e5..4cc91cb 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -149,5 +149,7 @@ "running": "运行中", "finished": "已完成", "failed": "已失败", - "allTasks": "所有任务" + "allTasks": "所有任务", + "ehMetadataCacheTime": "E-Hentai 画廊元数据缓存时间", + "hour": "小时" } diff --git a/lib/server_settings.dart b/lib/server_settings.dart index 1f86ce6..99a21d2 100644 --- a/lib/server_settings.dart +++ b/lib/server_settings.dart @@ -692,6 +692,22 @@ class _ServerSettingsPage extends State }); }, )), + _buildWithVecticalPadding(NumberFormField( + min: 1, + initialValue: + _now.ehMetadataCacheTime ?? _config!.ehMetadataCacheTime, + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: i18n.ehMetadataCacheTime, + suffixText: i18n.hour, + ), + onChanged: (s) { + setState(() { + _now.ehMetadataCacheTime = s; + _changed = true; + }); + }, + )), ])); }