From 827fe9e6c97fe750c8e3864b966eeb8c2c3e0225 Mon Sep 17 00:00:00 2001 From: iris1598 Date: Tue, 3 Sep 2024 12:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E5=89=A7?= =?UTF-8?q?=E9=9B=86=E4=B8=8D=E5=88=87=E6=8D=A2=E5=BC=B9=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bean/appbar/sys_app_bar.dart | 31 -------------------- lib/controllers/detail_controller.dart | 18 ++++++++++++ lib/controllers/watch/reader_controller.dart | 3 +- lib/controllers/watch/video_controller.dart | 10 +++++-- lib/main.dart | 3 ++ lib/views/pages/settings/settings_page.dart | 2 +- lib/webdav_editor/webdav_editor_page.dart | 8 ++--- lib/webdav_editor/webdav_setting.dart | 29 ++++++++---------- 8 files changed, 49 insertions(+), 55 deletions(-) diff --git a/lib/bean/appbar/sys_app_bar.dart b/lib/bean/appbar/sys_app_bar.dart index d3f45b56..9e0517e4 100644 --- a/lib/bean/appbar/sys_app_bar.dart +++ b/lib/bean/appbar/sys_app_bar.dart @@ -1,5 +1,3 @@ -import 'dart:io'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:miru_app/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:window_manager/window_manager.dart'; @@ -24,31 +22,6 @@ class SysAppBar extends StatelessWidget implements PreferredSizeWidget { const SysAppBar({super.key, this.toolbarHeight, this.title, this.backgroundColor, this.elevation, this.shape, this.actions, this.leading, this.bottom}); - void _handleCloseEvent() { - SmartDialog.show( - useAnimation: false, - builder: (context) { - return AlertDialog( - title: const Text('退出确认'), - content: const Text('您想要退出 Kazumi 吗?'), - actions: [ - TextButton( - onPressed: () => exit(0), - child: const Text('退出 Kazumi')), - TextButton( - onPressed: () { - SmartDialog.dismiss(); - windowManager.hide(); - }, - child: const Text('最小化至托盘')), - const TextButton( - onPressed: SmartDialog.dismiss, - child: Text('取消')), - ], - ); - } - ); - } @override Widget build(BuildContext context) { @@ -56,10 +29,6 @@ class SysAppBar extends StatelessWidget implements PreferredSizeWidget { if (actions != null) { acs.addAll(actions!); } - if (Utils.isDesktop()) { - // acs.add(IconButton(onPressed: () => windowManager.minimize(), icon: const Icon(Icons.minimize))); - acs.add(CloseButton(onPressed: () => _handleCloseEvent())); - } return GestureDetector( // behavior: HitTestBehavior.translucent, onPanStart: (_) => (Utils.isDesktop()) ? windowManager.startDragging() : null, diff --git a/lib/controllers/detail_controller.dart b/lib/controllers/detail_controller.dart index f862c070..3081fe13 100644 --- a/lib/controllers/detail_controller.dart +++ b/lib/controllers/detail_controller.dart @@ -6,10 +6,15 @@ import 'dart:io'; import 'package:fluent_ui/fluent_ui.dart' as fluent; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_windows_webview/flutter_windows_webview.dart'; import 'package:get/get.dart'; +import 'package:hive/hive.dart'; +import 'package:logger/logger.dart'; import 'package:miru_app/data/providers/tmdb_provider.dart'; import 'package:miru_app/models/index.dart'; +import 'package:miru_app/utils/storage.dart'; +import 'package:miru_app/utils/webdav.dart'; import 'package:miru_app/views/dialogs/tmdb_binding.dart'; import 'package:miru_app/controllers/home_controller.dart'; import 'package:miru_app/controllers/main_controller.dart'; @@ -23,6 +28,8 @@ import 'package:miru_app/utils/i18n.dart'; import 'package:miru_app/utils/miru_storage.dart'; import 'package:miru_app/views/widgets/messenger.dart'; +import '../utils/logger.dart'; + class DetailPageController extends GetxController { DetailPageController({ required this.package, @@ -327,6 +334,17 @@ class DetailPageController extends GetxController { rethrow; } await refreshFavorite(); + Box setting = GStorage.setting; + late bool webDavEnable = setting.get(SettingBoxKey.webDavEnable, defaultValue: false); + if (webDavEnable) { + try { + var webDav = WebDav(); + webDav.uploadDefaultIsar(); + } catch (e) { + SmartDialog.showToast('同步记录失败 ${e.toString()}'); + KazumiLogger().log(Level.error, '同步记录失败 ${e.toString()}'); + } + } Get.find().onRefresh(); } diff --git a/lib/controllers/watch/reader_controller.dart b/lib/controllers/watch/reader_controller.dart index 439e6506..c7f87b80 100644 --- a/lib/controllers/watch/reader_controller.dart +++ b/lib/controllers/watch/reader_controller.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:logger/logger.dart'; @@ -90,7 +91,7 @@ class ReaderController extends GetxController { var webDav = WebDav(); webDav.uploadDefaultIsar(); } catch (e) { - //SmartDialog.showToast('同步记录失败 ${e.toString()}'); + SmartDialog.showToast('同步记录失败 ${e.toString()}'); KazumiLogger().log(Level.error, '同步记录失败 ${e.toString()}'); } } diff --git a/lib/controllers/watch/video_controller.dart b/lib/controllers/watch/video_controller.dart index f03ad594..0d08be31 100644 --- a/lib/controllers/watch/video_controller.dart +++ b/lib/controllers/watch/video_controller.dart @@ -11,6 +11,7 @@ import 'package:flutter/material.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/services.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:logger/logger.dart'; @@ -136,6 +137,7 @@ void toggleDanmaku() { .setProperty('demuxer-max-bytes', '30MiB'); } play(); + danmakuController.pause(); getDanDanmaku(title,playIndex); getPlayerTimer() { return Timer.periodic(const Duration(seconds: 1), (timer) { @@ -193,10 +195,13 @@ void toggleDanmaku() { // 切换剧集 ever(index, (callback) { play(); + danmakuController.pause(); + danmakuController.clear(); + getDanDanmaku(title,index.value); }); // 播放状态监听,当开始播放时启动计时器 player.stream.playing.listen((playing) { - if (playing) { + if (playing&&!player.state.buffering) { danmakuController.resume(); getPlayerTimer(); } @@ -470,6 +475,7 @@ void toggleDanmaku() { await Future.delayed(const Duration(seconds: 3)); play(); + danmakuController.pause(); return; } @@ -553,7 +559,7 @@ void toggleDanmaku() { var webDav = WebDav(); webDav.uploadDefaultIsar(); } catch (e) { - //SmartDialog.showToast('同步记录失败 ${e.toString()}'); + SmartDialog.showToast('同步记录失败 ${e.toString()}'); KazumiLogger().log(Level.error, '同步记录失败 ${e.toString()}'); } } diff --git a/lib/main.dart b/lib/main.dart index bce7f234..c8329b55 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:fluent_ui/fluent_ui.dart' as fluent; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:media_kit/media_kit.dart'; import 'package:miru_app/controllers/application_controller.dart'; @@ -127,6 +128,7 @@ class _MainAppState extends State { localizationsDelegates: [ I18nUtils.flutterI18nDelegate, ], + builder: FlutterSmartDialog.init(), ); } @@ -148,6 +150,7 @@ class _MainAppState extends State { localizationsDelegates: [ I18nUtils.flutterI18nDelegate, ], + builder: FlutterSmartDialog.init(), ); } diff --git a/lib/views/pages/settings/settings_page.dart b/lib/views/pages/settings/settings_page.dart index d7bb334c..819701a8 100644 --- a/lib/views/pages/settings/settings_page.dart +++ b/lib/views/pages/settings/settings_page.dart @@ -426,7 +426,7 @@ class _SettingsPageState extends State { } }, ), - const SizedBox(height: 10), + const SizedBox(height: 10), SettingsTile( isCard: true, icon: Container( diff --git a/lib/webdav_editor/webdav_editor_page.dart b/lib/webdav_editor/webdav_editor_page.dart index 9408b2de..5f1ab7f9 100644 --- a/lib/webdav_editor/webdav_editor_page.dart +++ b/lib/webdav_editor/webdav_editor_page.dart @@ -73,16 +73,16 @@ class _WebDavEditorPageState extends State { try { await webDav.init(); } catch (e) { - debugPrint('配置失败 ${e.toString()}'); + SmartDialog.showToast('配置失败 ${e.toString()}'); await setting.put(SettingBoxKey.webDavEnable, false); return; } - debugPrint('配置成功, 开始测试'); + SmartDialog.showToast('配置成功, 开始测试'); try { await webDav.ping(); - debugPrint('测试成功'); + SmartDialog.showToast('测试成功'); } catch (e) { - debugPrint('测试失败 ${e.toString()}'); + SmartDialog.showToast('测试失败 ${e.toString()}'); await setting.put(SettingBoxKey.webDavEnable, false); } }, diff --git a/lib/webdav_editor/webdav_setting.dart b/lib/webdav_editor/webdav_setting.dart index 2d32e1fe..f5bd60d2 100644 --- a/lib/webdav_editor/webdav_setting.dart +++ b/lib/webdav_editor/webdav_setting.dart @@ -3,14 +3,11 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; -import 'package:get/get_core/src/get_main.dart'; import 'package:miru_app/router/router.dart'; -import 'package:miru_app/utils/utils.dart'; import 'package:miru_app/bean/settings/settings.dart'; import 'package:miru_app/utils/storage.dart'; import 'package:miru_app/utils/webdav.dart'; import 'package:hive/hive.dart'; -import 'package:flutter_modular/flutter_modular.dart'; import 'package:miru_app/bean/appbar/sys_app_bar.dart'; import 'package:miru_app/webdav_editor/webdav_editor_page.dart'; @@ -41,19 +38,19 @@ class _PlayerSettingsPageState extends State { await setting.get(SettingBoxKey.webDavURL, defaultValue: ''); if (webDavURL == '') { await setting.put(SettingBoxKey.webDavEnable, false); - debugPrint('未找到有效的webdav配置'); + SmartDialog.showToast('未找到有效的webdav配置'); return; } try { - debugPrint('尝试从WebDav同步'); + SmartDialog.showToast('尝试从WebDav同步'); var webDav = WebDav(); await webDav.downloadAndMigrateIsar(); - debugPrint('同步成功'); + SmartDialog.showToast('同步成功'); } catch (e) { if (e.toString().contains('Error: Not Found')) { - debugPrint('配置成功, 这是一个不存在已有同步文件的全新WebDav'); + SmartDialog.showToast('配置成功, 这是一个不存在已有同步文件的全新WebDav'); } else { - debugPrint('同步失败 ${e.toString()}'); + SmartDialog.showToast('同步失败 ${e.toString()}'); } } } @@ -63,15 +60,15 @@ class _PlayerSettingsPageState extends State { await setting.get(SettingBoxKey.webDavEnable, defaultValue: false); if (webDavEnable) { try { - debugPrint('尝试上传到WebDav'); + SmartDialog.showToast('尝试上传到WebDav'); var webDav = WebDav(); await webDav.uploadDefaultIsar(); - debugPrint('同步成功'); + SmartDialog.showToast('同步成功'); } catch (e) { - debugPrint('同步失败 ${e.toString()}'); + SmartDialog.showToast('同步失败 ${e.toString()}'); } } else { - debugPrint('未开启WebDav同步或配置无效'); + SmartDialog.showToast('未开启WebDav同步或配置无效'); } } @@ -80,15 +77,15 @@ class _PlayerSettingsPageState extends State { await setting.get(SettingBoxKey.webDavEnable, defaultValue: false); if (webDavEnable) { try { - debugPrint('尝试从WebDav同步'); + SmartDialog.showToast('尝试从WebDav同步'); var webDav = WebDav(); await webDav.downloadAndMigrateIsar(); - debugPrint('同步成功'); + SmartDialog.showToast('同步成功'); } catch (e) { - debugPrint('同步失败 ${e.toString()}'); + SmartDialog.showToast('同步失败 ${e.toString()}'); } } else { - debugPrint('未开启WebDav同步或配置无效'); + SmartDialog.showToast('未开启WebDav同步或配置无效'); } }