Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

add webdav page

Predidit504a5c762d22
diff --git a/lib/pages/my/my_module.dart b/lib/pages/my/my_module.dart
index d85bb4ef..dad4fb6a 100644
--- a/lib/pages/my/my_module.dart
+++ b/lib/pages/my/my_module.dart
@@ -8,6 +8,7 @@ import 'package:kazumi/pages/settings/theme_settings_page.dart';
import 'package:kazumi/pages/settings/player_settings.dart';
import 'package:kazumi/pages/settings/displaymode_settings.dart';
import 'package:kazumi/pages/settings/other_settings.dart';
+import 'package:kazumi/pages/webdav_editor/webdav_module.dart';
class MyModule extends Module {
@override
@@ -23,6 +24,7 @@ class MyModule extends Module {
);
r.child("/player", child: (_) => const PlayerSettingsPage());
r.child("/other", child: (_) => const OtherSettingsPage());
+ r.module("/webdav", module: WebDavModule());
r.module("/about", module: AboutModule());
r.module("/plugin", module: PluginModule());
r.module("/history", module: HistoryModule());
diff --git a/lib/pages/my/my_page.dart b/lib/pages/my/my_page.dart
index 447bade9..fbfa0839 100644
--- a/lib/pages/my/my_page.dart
+++ b/lib/pages/my/my_page.dart
@@ -52,6 +52,13 @@ class _MyPageState extends State<MyPage> {
title: const Text('外观设置'),
// trailing: const Icon(Icons.navigate_next),
),
+ ListTile(
+ onTap: () async {
+ Modular.to.pushNamed('/tab/my/webdav');
+ },
+ dense: false,
+ title: const Text('同步设置'),
+ ),
ListTile(
onTap: () async {
Modular.to.pushNamed('/tab/my/other');
diff --git a/lib/pages/webdav_editor/webdav_editor_page.dart b/lib/pages/webdav_editor/webdav_editor_page.dart
new file mode 100644
index 00000000..ce7e5bb8
--- /dev/null
+++ b/lib/pages/webdav_editor/webdav_editor_page.dart
@@ -0,0 +1,91 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+import 'package:hive/hive.dart';
+import 'package:kazumi/utils/storage.dart';
+import 'package:kazumi/bean/appbar/sys_app_bar.dart';
+import 'package:kazumi/utils/webdav.dart';
+
+class WebDavEditorPage extends StatefulWidget {
+ const WebDavEditorPage({
+ super.key,
+ });
+
+ @override
+ State<WebDavEditorPage> createState() => _WebDavEditorPageState();
+}
+
+class _WebDavEditorPageState extends State<WebDavEditorPage> {
+ final TextEditingController webDavURLController = TextEditingController();
+ final TextEditingController webDavUsernameController =
+ TextEditingController();
+ final TextEditingController webDavPasswordController =
+ TextEditingController();
+ Box setting = GStorage.setting;
+
+ @override
+ void initState() {
+ super.initState();
+ webDavURLController.text =
+ setting.get(SettingBoxKey.webDavURL, defaultValue: '');
+ webDavUsernameController.text =
+ setting.get(SettingBoxKey.webDavUsername, defaultValue: '');
+ webDavPasswordController.text =
+ setting.get(SettingBoxKey.webDavPassword, defaultValue: '');
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: const SysAppBar(
+ title: Text('WEBDAV编辑'),
+ ),
+ body: SingleChildScrollView(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ children: [
+ TextField(
+ controller: webDavURLController,
+ decoration: const InputDecoration(labelText: 'URL'),
+ ),
+ TextField(
+ controller: webDavUsernameController,
+ decoration: const InputDecoration(labelText: 'Username'),
+ ),
+ TextField(
+ controller: webDavPasswordController,
+ decoration: const InputDecoration(labelText: 'Password'),
+ ),
+ const SizedBox(height: 20),
+ ExpansionTile(
+ title: const Text('高级选项'),
+ children: [],
+ ),
+ ],
+ ),
+ ),
+ floatingActionButton: FloatingActionButton(
+ child: const Icon(Icons.save),
+ onPressed: () async {
+ setting.put(SettingBoxKey.webDavURL, webDavURLController.text);
+ setting.put(SettingBoxKey.webDavUsername, webDavUsernameController.text);
+ setting.put(SettingBoxKey.webDavPassword, webDavPasswordController.text);
+ var webDav = WebDav();
+ try {
+ await webDav.init();
+ } catch (e) {
+ SmartDialog.showToast('配置失败 ${e.toString()}');
+ await setting.put(SettingBoxKey.webDavEnable, false);
+ return;
+ }
+ SmartDialog.showToast('配置成功, 开始测试');
+ try {
+ await webDav.ping();
+ } catch (e) {
+ SmartDialog.showToast('测试失败 ${e.toString()}');
+ await setting.put(SettingBoxKey.webDavEnable, false);
+ }
+ },
+ ),
+ );
+ }
+}
diff --git a/lib/pages/webdav_editor/webdav_module.dart b/lib/pages/webdav_editor/webdav_module.dart
new file mode 100644
index 00000000..e07722d2
--- /dev/null
+++ b/lib/pages/webdav_editor/webdav_module.dart
@@ -0,0 +1,15 @@
+import 'package:kazumi/pages/webdav_editor/webdav_editor_page.dart';
+import 'package:kazumi/pages/webdav_editor/webdav_setting.dart';
+import 'package:flutter_modular/flutter_modular.dart';
+
+class WebDavModule extends Module {
+ @override
+ void binds(i) {}
+
+ @override
+ void routes(r) {
+ r.child("/", child: (_) => const WebDavSettingsPage());
+ r.child("/editor",
+ child: (_) => const WebDavEditorPage(),);
+ }
+}
diff --git a/lib/pages/webdav_editor/webdav_setting.dart b/lib/pages/webdav_editor/webdav_setting.dart
new file mode 100644
index 00000000..df6bfdca
--- /dev/null
+++ b/lib/pages/webdav_editor/webdav_setting.dart
@@ -0,0 +1,87 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+import 'package:kazumi/utils/utils.dart';
+import 'package:kazumi/bean/settings/settings.dart';
+import 'package:kazumi/utils/storage.dart';
+import 'package:provider/provider.dart';
+import 'package:hive/hive.dart';
+import 'package:kazumi/utils/storage.dart';
+import 'package:kazumi/pages/menu/menu.dart';
+import 'package:kazumi/pages/menu/side_menu.dart';
+import 'package:flutter_modular/flutter_modular.dart';
+import 'package:kazumi/bean/appbar/sys_app_bar.dart';
+
+class WebDavSettingsPage extends StatefulWidget {
+ const WebDavSettingsPage({super.key});
+
+ @override
+ State<WebDavSettingsPage> createState() => _PlayerSettingsPageState();
+}
+
+class _PlayerSettingsPageState extends State<WebDavSettingsPage> {
+ dynamic navigationBarState;
+ Box setting = GStorage.setting;
+
+ @override
+ void initState() {
+ super.initState();
+ if (Utils.isCompact()) {
+ navigationBarState =
+ Provider.of<NavigationBarState>(context, listen: false);
+ } else {
+ navigationBarState =
+ Provider.of<SideNavigationBarState>(context, listen: false);
+ }
+ }
+
+ void onBackPressed(BuildContext context) {
+ navigationBarState.showNavigate();
+ }
+
+ checkWebDav() {
+ var webDavURL = setting.get(SettingBoxKey.webDavURL, defaultValue: '');
+ if (webDavURL == '') {
+ setting.put(SettingBoxKey.webDavEnable, false);
+ SmartDialog.showToast('未找到有效的webdav配置');
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ navigationBarState.hideNavigate();
+ });
+ return PopScope(
+ canPop: true,
+ onPopInvoked: (bool didPop) async {
+ onBackPressed(context);
+ },
+ child: Scaffold(
+ appBar: const SysAppBar(title: Text('同步设置')),
+ body: Column(
+ children: [
+ InkWell(
+ child: SetSwitchItem(
+ title: 'WEBDAV同步',
+ setKey: SettingBoxKey.webDavEnable,
+ callFn: (val) {
+ if (val) {
+ checkWebDav();
+ }
+ },
+ defaultVal: false,
+ ),
+ ),
+ ListTile(
+ onTap: () async {
+ Modular.to.pushNamed('/tab/my/webdav/editor');
+ },
+ dense: false,
+ title: Text('WEBDAV配置', style: Theme.of(context).textTheme.titleMedium!,),
+ )
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/request/webdav.dart b/lib/utils/webdav.dart
similarity index 98%
rename from lib/request/webdav.dart
rename to lib/utils/webdav.dart
index 76d3de24..1df41fbf 100644
--- a/lib/request/webdav.dart
+++ b/lib/utils/webdav.dart
@@ -82,4 +82,8 @@ class WebDav {
});
await GStorage.restoreHistory(existingFile.path);
}
+
+ Future ping() async {
+ await client.ping();
+ }
}