diff --git a/lib/api/config.dart b/lib/api/config.dart index 68f7ff6..daa70e2 100644 --- a/lib/api/config.dart +++ b/lib/api/config.dart @@ -74,6 +74,7 @@ class Config { required this.checkFileHash, required this.importMethod, required this.maxImportImgCount, + required this.enableServerTiming, }); bool cookies; @JsonKey(name: 'db_path') @@ -138,6 +139,8 @@ class Config { ImportMethod importMethod; @JsonKey(name: 'max_import_img_count') int maxImportImgCount; + @JsonKey(name: 'enable_server_timing') + bool enableServerTiming; factory Config.fromJson(Map json) => _$ConfigFromJson(json); Map toJson() => _$ConfigToJson(this); } @@ -192,6 +195,7 @@ class ConfigOptional { this.checkFileHash, this.importMethod, this.maxImportImgCount, + this.enableServerTiming, }); String? cookies; @JsonKey(name: 'db_path') @@ -256,6 +260,8 @@ class ConfigOptional { ImportMethod? importMethod; @JsonKey(name: 'max_import_img_count') int? maxImportImgCount; + @JsonKey(name: 'enable_server_timing') + bool? enableServerTiming; 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 baa594b..82913d9 100644 --- a/lib/api/config.g.dart +++ b/lib/api/config.g.dart @@ -48,6 +48,7 @@ Config _$ConfigFromJson(Map json) => Config( checkFileHash: json['check_file_hash'] as bool, importMethod: $enumDecode(_$ImportMethodEnumMap, json['import_method']), maxImportImgCount: (json['max_import_img_count'] as num).toInt(), + enableServerTiming: json['enable_server_timing'] as bool, ); Map _$ConfigToJson(Config instance) => { @@ -86,6 +87,7 @@ Map _$ConfigToJson(Config instance) => { 'check_file_hash': instance.checkFileHash, 'import_method': _$ImportMethodEnumMap[instance.importMethod]!, 'max_import_img_count': instance.maxImportImgCount, + 'enable_server_timing': instance.enableServerTiming, }; const _$ThumbnailMethodEnumMap = { @@ -154,6 +156,7 @@ ConfigOptional _$ConfigOptionalFromJson(Map json) => importMethod: $enumDecodeNullable(_$ImportMethodEnumMap, json['import_method']), maxImportImgCount: (json['max_import_img_count'] as num?)?.toInt(), + enableServerTiming: json['enable_server_timing'] as bool?, ); Map _$ConfigOptionalToJson(ConfigOptional instance) => @@ -193,4 +196,5 @@ Map _$ConfigOptionalToJson(ConfigOptional instance) => 'check_file_hash': instance.checkFileHash, 'import_method': _$ImportMethodEnumMap[instance.importMethod], 'max_import_img_count': instance.maxImportImgCount, + 'enable_server_timing': instance.enableServerTiming, }; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 5e96987..50256bb 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -313,5 +313,6 @@ "type": "String" } } - } + }, + "enableServerTiming": "Enable server time tracking" } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 0330175..cf6f0c5 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -313,5 +313,6 @@ "type": "String" } } - } + }, + "enableServerTiming": "测量服务器所用时间" } diff --git a/lib/pages/settings/server.dart b/lib/pages/settings/server.dart index 7a06ace..6913db2 100644 --- a/lib/pages/settings/server.dart +++ b/lib/pages/settings/server.dart @@ -317,6 +317,18 @@ class _ServerSettingsPage extends State } }, label: Text(i18n.checkFileHash))), + _buildWithVecticalPadding(LabeledCheckbox( + value: _now.enableServerTiming ?? _config!.enableServerTiming, + onChanged: (b) { + if (b != null) { + setState(() { + _now.enableServerTiming = b; + _changed = true; + }); + } + }, + label: Text(i18n.enableServerTiming), + )), ])); }