基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
Update minimize to tray option when close
WhiteXero9fc09791944d
diff --git a/assets/images/logo/logo_windows.ico b/assets/images/logo/logo_windows.iconew file mode 100644index 00000000..394a1695Binary files /dev/null and b/assets/images/logo/logo_windows.ico differdiff --git a/lib/app_widget.dart b/lib/app_widget.dartindex fd6e9809..93220365 100644--- a/lib/app_widget.dart+++ b/lib/app_widget.dart@@ -8,6 +8,8 @@ import 'package:flutter_displaymode/flutter_displaymode.dart';import 'package:hive/hive.dart';import 'package:kazumi/utils/utils.dart';import 'package:kazumi/utils/storage.dart';+import 'package:tray_manager/tray_manager.dart';+import 'package:window_manager/window_manager.dart';class AppWidget extends StatefulWidget {const AppWidget({super.key});@@ -16,11 +18,71 @@ class AppWidget extends StatefulWidget {State<AppWidget> createState() => _AppWidgetState();}-class _AppWidgetState extends State<AppWidget> {+class _AppWidgetState extends State<AppWidget> with TrayListener {Box setting = GStorage.setting;+ final TrayManager trayManager = TrayManager.instance;++ @override+ void initState() {+ trayManager.addListener(this);+ super.initState();+ }++ @override+ void dispose() {+ trayManager.removeListener(this);+ super.dispose();+ }++ @override+ void onTrayIconMouseDown(){+ windowManager.show();+ }++ @override+ void onTrayIconRightMouseDown(){+ trayManager.popUpContextMenu();+ }++ @override+ void onTrayMenuItemClick(MenuItem menuItem) {+ switch (menuItem.key){+ case 'show_window':+ windowManager.show();+ case 'exit':+ windowManager.destroy();+ }+ }++ Future<void> handleTray() async {+ await trayManager.setIcon(+ Platform.isWindows+ ? 'assets/images/logo/logo_windows.ico'+ : 'assets/images/logo/logo_rounded.png'+ );+ await trayManager.setToolTip('Kazumi');+ Menu trayMenu = Menu(+ items: [+ MenuItem(+ key: 'show_window',+ label: '显示窗口'+ ),+ MenuItem.separator(),+ MenuItem(+ key: 'exit',+ label: '退出 Kazumi'+ )+ ]+ );+ await trayManager.setContextMenu(trayMenu);+ }+@overrideWidget build(BuildContext context) {+ if(Utils.isDesktop()) {+ handleTray();+ }dynamic color;dynamic defaultThemeColor =setting.get(SettingBoxKey.themeColor, defaultValue: 'default');diff --git a/lib/bean/appbar/sys_app_bar.dart b/lib/bean/appbar/sys_app_bar.dartindex 5fbb9f00..6dffae85 100644--- a/lib/bean/appbar/sys_app_bar.dart+++ b/lib/bean/appbar/sys_app_bar.dart@@ -1,3 +1,4 @@+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';import 'package:kazumi/utils/utils.dart';import 'package:flutter/material.dart';import 'package:window_manager/window_manager.dart';@@ -21,6 +22,31 @@ 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(+ builder: (context) {+ return AlertDialog(+ title: const Text('关闭确认'),+ content: const Text('您想要关闭 Kazumi 吗?'),+ actions: [+ TextButton(+ onPressed: windowManager.destroy,+ child: const Text('关闭 Kazumi')),+ TextButton(+ onPressed: () {+ SmartDialog.dismiss();+ windowManager.hide();+ },+ child: const Text('最小化至托盘')),+ const TextButton(+ onPressed: SmartDialog.dismiss,+ child: Text('取消')),+ ],+ );+ }+ );+ }+@overrideWidget build(BuildContext context) {List<Widget> acs = [];@@ -29,7 +55,7 @@ class SysAppBar extends StatelessWidget implements PreferredSizeWidget {}if (Utils.isDesktop()) {// acs.add(IconButton(onPressed: () => windowManager.minimize(), icon: const Icon(Icons.minimize)));- acs.add(CloseButton(onPressed: () => windowManager.close()));+ acs.add(CloseButton(onPressed: () => _handleCloseEvent()));}return GestureDetector(// behavior: HitTestBehavior.translucent,diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.ccindex d463a462..e26cc6f6 100644--- a/linux/flutter/generated_plugin_registrant.cc+++ b/linux/flutter/generated_plugin_registrant.cc@@ -9,6 +9,7 @@#include <flutter_volume_controller/flutter_volume_controller_plugin.h>#include <fvp/fvp_plugin.h>#include <screen_retriever/screen_retriever_plugin.h>+#include <tray_manager/tray_manager_plugin.h>#include <url_launcher_linux/url_launcher_plugin.h>#include <window_manager/window_manager_plugin.h>@@ -22,6 +23,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {g_autoptr(FlPluginRegistrar) screen_retriever_registrar =fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);+ g_autoptr(FlPluginRegistrar) tray_manager_registrar =+ fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");+ tray_manager_plugin_register_with_registrar(tray_manager_registrar);g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmakeindex 7718023d..eaf0de67 100644--- a/linux/flutter/generated_plugins.cmake+++ b/linux/flutter/generated_plugins.cmake@@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LISTflutter_volume_controllerfvpscreen_retriever+ tray_managerurl_launcher_linuxwindow_manager)diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swiftindex ee1c4537..84d071f9 100644--- a/macos/Flutter/GeneratedPluginRegistrant.swift+++ b/macos/Flutter/GeneratedPluginRegistrant.swift@@ -15,6 +15,7 @@ import screen_brightness_macosimport screen_retrieverimport shared_preferences_foundationimport sqflite+import tray_managerimport url_launcher_macosimport video_player_avfoundationimport wakelock_plus@@ -31,6 +32,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))+ TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))diff --git a/pubspec.lock b/pubspec.lockindex cbb685c3..d033001b 100644--- a/pubspec.lock+++ b/pubspec.lock@@ -669,6 +669,14 @@ packages:url: "https://pub.dev"source: hostedversion: "0.8.0"+ menu_base:+ dependency: transitive+ description:+ name: menu_base+ sha256: "820368014a171bd1241030278e6c2617354f492f5c703d7b7d4570a6b8b84405"+ url: "https://pub.dev"+ source: hosted+ version: "0.1.1"meta:dependency: transitivedescription:@@ -1021,6 +1029,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.0.4"+ shortid:+ dependency: transitive+ description:+ name: shortid+ sha256: d0b40e3dbb50497dad107e19c54ca7de0d1a274eb9b4404991e443dadb9ebedb+ url: "https://pub.dev"+ source: hosted+ version: "0.1.2"sky_engine:dependency: transitivedescription: flutter@@ -1138,6 +1154,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.0.1"+ tray_manager:+ dependency: "direct main"+ description:+ name: tray_manager+ sha256: c9a63fd88bd3546287a7eb8ccc978d707eef82c775397af17dda3a4f4c039e64+ url: "https://pub.dev"+ source: hosted+ version: "0.2.3"typed_data:dependency: transitivedescription:diff --git a/pubspec.yaml b/pubspec.yamlindex fc038ef0..ab2aa848 100644--- a/pubspec.yaml+++ b/pubspec.yaml@@ -75,6 +75,7 @@ dependencies:canvas_danmaku: ^0.1.7animated_search_bar: ^2.7.1webdav_client: ^1.2.2+ tray_manager: ^0.2.3webview_windows:git:url: https://github.com/Predidit/flutter-webview-windows.gitdiff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.ccindex 84ce9763..43da4f81 100644--- a/windows/flutter/generated_plugin_registrant.cc+++ b/windows/flutter/generated_plugin_registrant.cc@@ -11,6 +11,7 @@#include <fvp/fvp_plugin_c_api.h>#include <screen_brightness_windows/screen_brightness_windows_plugin.h>#include <screen_retriever/screen_retriever_plugin.h>+#include <tray_manager/tray_manager_plugin.h>#include <url_launcher_windows/url_launcher_windows.h>#include <webview_windows/webview_windows_plugin.h>#include <window_manager/window_manager_plugin.h>@@ -26,6 +27,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {registry->GetRegistrarForPlugin("ScreenBrightnessWindowsPlugin"));ScreenRetrieverPluginRegisterWithRegistrar(registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));+ TrayManagerPluginRegisterWithRegistrar(+ registry->GetRegistrarForPlugin("TrayManagerPlugin"));UrlLauncherWindowsRegisterWithRegistrar(registry->GetRegistrarForPlugin("UrlLauncherWindows"));WebviewWindowsPluginRegisterWithRegistrar(diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmakeindex 62127b94..3e413b30 100644--- a/windows/flutter/generated_plugins.cmake+++ b/windows/flutter/generated_plugins.cmake@@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LISTfvpscreen_brightness_windowsscreen_retriever+ tray_managerurl_launcher_windowswebview_windowswindow_manager