mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-17 08:24:45 +08:00
Add new settings
This commit is contained in:
@@ -39,6 +39,7 @@ class Config {
|
||||
required this.fetchTimeout,
|
||||
required this.downloadTimeout,
|
||||
required this.ffprobePath,
|
||||
required this.redirectToFlutter,
|
||||
});
|
||||
bool cookies;
|
||||
@JsonKey(name: 'db_path')
|
||||
@@ -87,6 +88,8 @@ class Config {
|
||||
int downloadTimeout;
|
||||
@JsonKey(name: 'ffprobe_path')
|
||||
String ffprobePath;
|
||||
@JsonKey(name: 'redirect_to_flutter')
|
||||
bool redirectToFlutter;
|
||||
factory Config.fromJson(Map<String, dynamic> json) => _$ConfigFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ConfigToJson(this);
|
||||
}
|
||||
@@ -133,6 +136,7 @@ class ConfigOptional {
|
||||
this.fetchTimeout,
|
||||
this.downloadTimeout,
|
||||
this.ffprobePath,
|
||||
this.redirectToFlutter,
|
||||
});
|
||||
String? cookies;
|
||||
@JsonKey(name: 'db_path')
|
||||
@@ -181,6 +185,8 @@ class ConfigOptional {
|
||||
int? downloadTimeout;
|
||||
@JsonKey(name: 'ffprobe_path')
|
||||
String? ffprobePath;
|
||||
@JsonKey(name: 'redirect_to_flutter')
|
||||
bool? redirectToFlutter;
|
||||
factory ConfigOptional.fromJson(Map<String, dynamic> json) =>
|
||||
_$ConfigOptionalFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ConfigOptionalToJson(this);
|
||||
|
||||
@@ -39,6 +39,7 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config(
|
||||
fetchTimeout: json['fetch_timeout'] as int,
|
||||
downloadTimeout: json['download_timeout'] as int,
|
||||
ffprobePath: json['ffprobe_path'] as String,
|
||||
redirectToFlutter: json['redirect_to_flutter'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
@@ -69,6 +70,7 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'fetch_timeout': instance.fetchTimeout,
|
||||
'download_timeout': instance.downloadTimeout,
|
||||
'ffprobe_path': instance.ffprobePath,
|
||||
'redirect_to_flutter': instance.redirectToFlutter,
|
||||
};
|
||||
|
||||
const _$ThumbnailMethodEnumMap = {
|
||||
@@ -120,6 +122,7 @@ ConfigOptional _$ConfigOptionalFromJson(Map<String, dynamic> json) =>
|
||||
fetchTimeout: json['fetch_timeout'] as int?,
|
||||
downloadTimeout: json['download_timeout'] as int?,
|
||||
ffprobePath: json['ffprobe_path'] as String?,
|
||||
redirectToFlutter: json['redirect_to_flutter'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ConfigOptionalToJson(ConfigOptional instance) =>
|
||||
@@ -151,4 +154,5 @@ Map<String, dynamic> _$ConfigOptionalToJson(ConfigOptional instance) =>
|
||||
'fetch_timeout': instance.fetchTimeout,
|
||||
'download_timeout': instance.downloadTimeout,
|
||||
'ffprobe_path': instance.ffprobePath,
|
||||
'redirect_to_flutter': instance.redirectToFlutter,
|
||||
};
|
||||
|
||||
@@ -8,6 +8,53 @@ import 'main.dart';
|
||||
|
||||
final _log = Logger("HomePage");
|
||||
|
||||
class HomeDrawer extends StatelessWidget {
|
||||
const HomeDrawer({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: Container()),
|
||||
IconButton(
|
||||
onPressed: () => Scaffold.of(context).closeDrawer(),
|
||||
icon: const Icon(Icons.close))
|
||||
],
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.collections),
|
||||
title: Text(AppLocalizations.of(context)!.galleries),
|
||||
onTap: () {
|
||||
Scaffold.of(context).closeDrawer();
|
||||
context.push("/galleries");
|
||||
},
|
||||
),
|
||||
auth.isAdmin == true
|
||||
? ListTile(
|
||||
leading: const Icon(Icons.admin_panel_settings),
|
||||
title: Text(AppLocalizations.of(context)!.serverSettings),
|
||||
onTap: () {
|
||||
Scaffold.of(context).closeDrawer();
|
||||
context.push("/server_settings");
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(AppLocalizations.of(context)!.settings),
|
||||
onTap: () {
|
||||
Scaffold.of(context).closeDrawer();
|
||||
context.push("/settings");
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class HomePage extends HookWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
|
||||
@@ -37,42 +84,7 @@ class HomePage extends HookWidget {
|
||||
buildMoreVertSettingsButon(context),
|
||||
],
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: ListView.builder(
|
||||
itemCount: 3,
|
||||
itemBuilder: (context, i) {
|
||||
if (i == 0) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: Container()),
|
||||
IconButton(
|
||||
onPressed: () => Scaffold.of(context).closeDrawer(),
|
||||
icon: const Icon(Icons.close))
|
||||
],
|
||||
);
|
||||
}
|
||||
if (i == 1) {
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.collections),
|
||||
title: Text(AppLocalizations.of(context)!.galleries),
|
||||
onTap: () {
|
||||
Scaffold.of(context).closeDrawer();
|
||||
context.push("/galleries");
|
||||
},
|
||||
);
|
||||
}
|
||||
if (i == 2) {
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(AppLocalizations.of(context)!.settings),
|
||||
onTap: () {
|
||||
Scaffold.of(context).closeDrawer();
|
||||
context.push("/settings");
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
})),
|
||||
drawer: const HomeDrawer(),
|
||||
body: Center(
|
||||
child: TextButton(
|
||||
child: Text('Hello World!'),
|
||||
|
||||
@@ -139,5 +139,6 @@
|
||||
"meiliHosts": "Meilisearch server hostname for specific domains",
|
||||
"meiliHostsHelp": "Requests from these domains will receive the corresponding Meilisearch server hostname.",
|
||||
"keyIsEmpty": "Key is empty.",
|
||||
"keyIsExists": "Key is exists."
|
||||
"keyIsExists": "Key is exists.",
|
||||
"redirectToFlutter": "Redirect to Flutter frontend when accessing the root URL."
|
||||
}
|
||||
|
||||
@@ -139,5 +139,6 @@
|
||||
"meiliHosts": "特定域名的 Meilisearch 服务器主机名",
|
||||
"meiliHostsHelp": "来自这些域的请求将收到相应的 Meilisearch 服务器主机名。",
|
||||
"keyIsEmpty": "键不能为空。",
|
||||
"keyIsExists": "键已存在。"
|
||||
"keyIsExists": "键已存在。",
|
||||
"redirectToFlutter": "访问根 URL 时重定向到 flutter 前端。"
|
||||
}
|
||||
|
||||
@@ -284,6 +284,17 @@ class _ServerSettingsPage extends State<ServerSettingsPage>
|
||||
}
|
||||
},
|
||||
label: Text(i18n.removePreviousGallery))),
|
||||
_buildWithVecticalPadding(LabeledCheckbox(
|
||||
value: _now.redirectToFlutter ?? _config!.redirectToFlutter,
|
||||
onChanged: (b) {
|
||||
if (b != null) {
|
||||
setState(() {
|
||||
_now.redirectToFlutter = b;
|
||||
_changed = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
label: Text(i18n.redirectToFlutter))),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user