Add new server settings enableServerTiming

This commit is contained in:
2024-08-11 03:46:18 +00:00
committed by GitHub
parent 1a79e41f7a
commit e8fb94d6b9
5 changed files with 26 additions and 2 deletions

View File

@@ -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<String, dynamic> json) => _$ConfigFromJson(json);
Map<String, dynamic> 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<String, dynamic> json) =>
_$ConfigOptionalFromJson(json);
Map<String, dynamic> toJson() => _$ConfigOptionalToJson(this);

View File

@@ -48,6 +48,7 @@ Config _$ConfigFromJson(Map<String, dynamic> 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<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
@@ -86,6 +87,7 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
'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<String, dynamic> json) =>
importMethod:
$enumDecodeNullable(_$ImportMethodEnumMap, json['import_method']),
maxImportImgCount: (json['max_import_img_count'] as num?)?.toInt(),
enableServerTiming: json['enable_server_timing'] as bool?,
);
Map<String, dynamic> _$ConfigOptionalToJson(ConfigOptional instance) =>
@@ -193,4 +196,5 @@ Map<String, dynamic> _$ConfigOptionalToJson(ConfigOptional instance) =>
'check_file_hash': instance.checkFileHash,
'import_method': _$ImportMethodEnumMap[instance.importMethod],
'max_import_img_count': instance.maxImportImgCount,
'enable_server_timing': instance.enableServerTiming,
};

View File

@@ -313,5 +313,6 @@
"type": "String"
}
}
}
},
"enableServerTiming": "Enable server time tracking"
}

View File

@@ -313,5 +313,6 @@
"type": "String"
}
}
}
},
"enableServerTiming": "测量服务器所用时间"
}

View File

@@ -317,6 +317,18 @@ class _ServerSettingsPage extends State<ServerSettingsPage>
}
},
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),
)),
]));
}