feat: app proxy

This commit is contained in:
Simon Ding
2024-07-27 17:18:38 +08:00
parent 5175e651ee
commit feecc9f983
8 changed files with 52 additions and 14 deletions

View File

@@ -50,14 +50,17 @@ class GeneralSetting {
String? tmdbApiKey;
String? downloadDIr;
String? logLevel;
String? proxy;
GeneralSetting({this.tmdbApiKey, this.downloadDIr, this.logLevel});
GeneralSetting(
{this.tmdbApiKey, this.downloadDIr, this.logLevel, this.proxy});
factory GeneralSetting.fromJson(Map<String, dynamic> json) {
return GeneralSetting(
tmdbApiKey: json["tmdb_api_key"],
downloadDIr: json["download_dir"],
logLevel: json["log_level"]);
logLevel: json["log_level"],
proxy: json["proxy"]);
}
Map<String, dynamic> toJson() {
@@ -65,6 +68,7 @@ class GeneralSetting {
data['tmdb_api_key'] = tmdbApiKey;
data['download_dir'] = downloadDIr;
data["log_level"] = logLevel;
data["proxy"] = proxy;
return data;
}
}

View File

@@ -36,14 +36,14 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
initialValue: {
"tmdb_api": v.tmdbApiKey,
"download_dir": v.downloadDIr,
"log_level": v.logLevel
"log_level": v.logLevel,
"proxy": v.proxy,
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FormBuilderTextField(
name: "tmdb_api",
autofocus: true,
decoration: Commons.requiredTextFieldStyle(
text: "TMDB Api Key", icon: const Icon(Icons.key)),
//
@@ -51,12 +51,16 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
),
FormBuilderTextField(
name: "download_dir",
autofocus: true,
decoration: Commons.requiredTextFieldStyle(
text: "下载路径", icon: const Icon(Icons.folder)),
text: "下载路径", icon: const Icon(Icons.folder), helperText: "媒体文件临时下载路径,非最终存储路径"),
//
validator: FormBuilderValidators.required(),
),
FormBuilderTextField(
name: "proxy",
decoration: const InputDecoration(
labelText: "代理地址", icon: Icon(Icons.folder), helperText: "后台联网代理地址,留空表示不启用代理"),
),
SizedBox(
width: 300,
child: FormBuilderDropdown(
@@ -66,13 +70,10 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
icon: Icon(Icons.file_present_rounded),
),
items: const [
DropdownMenuItem(
value: "debug", child: Text("DEBUG")),
DropdownMenuItem(value: "debug", child: Text("DEBUG")),
DropdownMenuItem(value: "info", child: Text("INFO")),
DropdownMenuItem(
value: "warn", child: Text("WARNING")),
DropdownMenuItem(
value: "error", child: Text("ERROR")),
DropdownMenuItem(value: "warn", child: Text("WARN")),
DropdownMenuItem(value: "error", child: Text("ERROR")),
],
validator: FormBuilderValidators.required(),
),
@@ -93,7 +94,8 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
.updateSettings(GeneralSetting(
tmdbApiKey: values["tmdb_api"],
downloadDIr: values["download_dir"],
logLevel: values["log_level"]));
logLevel: values["log_level"],
proxy: values["proxy"]));
f.then((v) {
Utils.showSnakeBar("更新成功");
}).onError((e, s) {

View File

@@ -37,7 +37,7 @@ class _SystemPageState extends ConsumerState<SystemPage> {
columns: const [
DataColumn(label: Text("日志")),
DataColumn(label: Text("大小")),
DataColumn(label: Text("*"))
DataColumn(label: Text("下载"))
],
rows: List.generate(list.length, (i) {
final item = list[i];

View File

@@ -4,8 +4,10 @@ class Commons {
static InputDecoration requiredTextFieldStyle({
required String text,
Widget? icon,
String? helperText,
}) {
return InputDecoration(
helperText: helperText,
label: Row(
children: [
Text(text),