mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
feat: add log level setting
This commit is contained in:
@@ -49,18 +49,22 @@ class EditSettingData extends AutoDisposeAsyncNotifier<GeneralSetting> {
|
||||
class GeneralSetting {
|
||||
String? tmdbApiKey;
|
||||
String? downloadDIr;
|
||||
String? logLevel;
|
||||
|
||||
GeneralSetting({this.tmdbApiKey, this.downloadDIr});
|
||||
GeneralSetting({this.tmdbApiKey, this.downloadDIr, this.logLevel});
|
||||
|
||||
factory GeneralSetting.fromJson(Map<String, dynamic> json) {
|
||||
return GeneralSetting(
|
||||
tmdbApiKey: json["tmdb_api_key"], downloadDIr: json["download_dir"]);
|
||||
tmdbApiKey: json["tmdb_api_key"],
|
||||
downloadDIr: json["download_dir"],
|
||||
logLevel: json["log_level"]);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['tmdb_api_key'] = tmdbApiKey;
|
||||
data['download_dir'] = downloadDIr;
|
||||
data["log_level"] = logLevel;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -257,13 +261,13 @@ class StorageSettingData extends AutoDisposeAsyncNotifier<List<Storage>> {
|
||||
}
|
||||
|
||||
class Storage {
|
||||
Storage(
|
||||
{this.id,
|
||||
this.name,
|
||||
this.implementation,
|
||||
this.settings,
|
||||
this.isDefault,
|
||||
});
|
||||
Storage({
|
||||
this.id,
|
||||
this.name,
|
||||
this.implementation,
|
||||
this.settings,
|
||||
this.isDefault,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? name;
|
||||
|
||||
@@ -37,9 +37,11 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
initialValue: {
|
||||
"tmdb_api": v.tmdbApiKey,
|
||||
"download_dir": v.downloadDIr
|
||||
"download_dir": v.downloadDIr,
|
||||
"log_level": v.logLevel
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
name: "tmdb_api",
|
||||
@@ -57,6 +59,26 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
||||
//
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
child: FormBuilderDropdown(
|
||||
name: "log_level",
|
||||
decoration: const InputDecoration(
|
||||
labelText: "日志级别",
|
||||
icon: Icon(Icons.file_present_rounded),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: "debug", child: Text("Debug")),
|
||||
DropdownMenuItem(value: "info", child: Text("Info")),
|
||||
DropdownMenuItem(
|
||||
value: "warn", child: Text("Warnning")),
|
||||
DropdownMenuItem(
|
||||
value: "error", child: Text("Error")),
|
||||
],
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 28.0),
|
||||
@@ -72,7 +94,8 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
||||
.read(settingProvider.notifier)
|
||||
.updateSettings(GeneralSetting(
|
||||
tmdbApiKey: values["tmdb_api"],
|
||||
downloadDIr: values["download_dir"]));
|
||||
downloadDIr: values["download_dir"],
|
||||
logLevel: values["log_level"]));
|
||||
f.then((v) {
|
||||
Utils.showSnakeBar("更新成功");
|
||||
}).onError((e, s) {
|
||||
|
||||
Reference in New Issue
Block a user