From 70f1e609dd6e0963057c431fa6e0dfb8955e5289 Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Tue, 25 Nov 2025 14:14:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle.kts | 2 +- lib/main.dart | 5 ++++- lib/utils/notify_utils.dart | 21 ++++++++------------- pubspec.lock | 20 ++++++++++++++------ pubspec.yaml | 2 +- windows/flutter/generated_plugins.cmake | 1 + 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 9e9871c..40c244e 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -78,7 +78,7 @@ android { dependencies { // 添加核心库脱糖依赖 - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") } flutter { diff --git a/lib/main.dart b/lib/main.dart index 70aedd6..48c584a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,6 +6,7 @@ import 'package:flisp_app/provider/flisp_provider.dart'; import 'package:flisp_app/utils/notify_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_common/flutter_common.dart'; +import 'package:flutter_common/utils/log_utils.dart'; import 'package:flutter_common/utils/sp_utils.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:hive_flutter/adapters.dart'; @@ -20,7 +21,9 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); // 初始化存储 await SPUtil.init(); - + // 初始化日志 + await initLogger(); + // 初始化提醒服务 final notifyService = NotifyService(); await notifyService.initialize(); diff --git a/lib/utils/notify_utils.dart b/lib/utils/notify_utils.dart index 4e110e4..4a50aa8 100644 --- a/lib/utils/notify_utils.dart +++ b/lib/utils/notify_utils.dart @@ -17,9 +17,6 @@ class NotifyService { late FlutterLocalNotificationsPlugin _notifications; - // 使用绝对时间(而不是相对时间),避免时区转换问题。 - final dateInterpretation = UILocalNotificationDateInterpretation.absoluteTime; - // Android特殊模式,即使设备处于省电模式也能准时触发。 final scheduleMode = AndroidScheduleMode.exactAllowWhileIdle; @@ -29,7 +26,6 @@ class NotifyService { // 初始化时区 tz.initializeTimeZones(); - // String timeZoneName = await FlutterNativeTimezone.getLocalTimezone(); tz.setLocalLocation(tz.getLocation("Asia/Shanghai")); // 设置Android平台的初始化配置 使用应用图标作为通知图标 @@ -66,11 +62,11 @@ class NotifyService { TodoSortMode.priority, ); final List todayTodos = - todoResult - .where( - (todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime), - ) - .toList(); + todoResult + .where( + (todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime), + ) + .toList(); for (Todo todo in todayTodos) { await scheduleNotification( @@ -84,9 +80,9 @@ class NotifyService { CalendarService calendarService = CalendarService(); final List calendarResult = calendarService.getAllCalendars(); final List todayCalendars = - calendarResult - .where((item) => isAfterToday(item.scheduledTime)) - .toList(); + calendarResult + .where((item) => isAfterToday(item.scheduledTime)) + .toList(); for (Calendar calendar in todayCalendars) { await scheduleNotification( @@ -152,7 +148,6 @@ class NotifyService { body, tz.TZDateTime.from(scheduledTime, tz.local), _details, - uiLocalNotificationDateInterpretation: dateInterpretation, androidScheduleMode: scheduleMode, ); } diff --git a/pubspec.lock b/pubspec.lock index 235f1c4..19e5da6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -350,26 +350,34 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: ef41ae901e7529e52934feba19ed82827b11baa67336829564aeab3129460610 + sha256: "19ffb0a8bb7407875555e5e98d7343a633bb73707bae6c6a5f37c90014077875" url: "https://pub.flutter-io.cn" source: hosted - version: "18.0.1" + version: "19.5.0" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux - sha256: "8f685642876742c941b29c32030f6f4f6dacd0e4eaecb3efbb187d6a3812ca01" + sha256: e3c277b2daab8e36ac5a6820536668d07e83851aeeb79c446e525a70710770a5 url: "https://pub.flutter-io.cn" source: hosted - version: "5.0.0" + version: "6.0.0" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - sha256: "6c5b83c86bf819cdb177a9247a3722067dd8cc6313827ce7c77a4b238a26fd52" + sha256: "277d25d960c15674ce78ca97f57d0bae2ee401c844b6ac80fcd972a9c99d09fe" url: "https://pub.flutter-io.cn" source: hosted - version: "8.0.0" + version: "9.1.0" + flutter_local_notifications_windows: + dependency: transitive + description: + name: flutter_local_notifications_windows + sha256: "8d658f0d367c48bd420e7cf2d26655e2d1130147bca1eea917e576ca76668aaf" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.3" flutter_localizations: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 58a4858..c375a56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1 +1 @@ -name: flisp_app description: "闪灵" publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+2 environment: sdk: ^3.7.0 dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 # 状态管理 provider: ^6.1.1 # 切换开关组件 toggle_switch: ^2.3.0 # 表单构建器 flutter_form_builder: ^10.0.0 # 表单验证器 form_builder_validators: ^10.0.0 # 国际化支持 intl: ^0.19.0 # 轻量级NoSQL数据库 hive: ^2.2.3 # Hive的Flutter集成 hive_flutter: ^1.1.0 # 路径提供器 path_provider: ^2.1.1 # 本地通知 flutter_local_notifications: ^18.0.0 # 时区支持 timezone: ^0.10.1 file_picker: ^10.3.3 syncfusion_flutter_calendar: ^30.1.37 syncfusion_localizations: ^30.1.37 package_info_plus: ^8.0.0 flutter_common: path: ..\flutter_common dev_dependencies: flutter_test: sdk: flutter hive_generator: ^2.0.1 build_runner: ^2.4.6 flutter_lints: ^5.0.0 flutter: uses-material-design: true fonts: - family: CustomFont fonts: - asset: fonts/custom.ttf \ No newline at end of file +name: flisp_app description: "闪灵" publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+2 environment: sdk: ^3.7.0 dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 provider: ^6.1.1 toggle_switch: ^2.3.0 flutter_form_builder: ^10.0.0 form_builder_validators: ^10.0.0 intl: ^0.19.0 hive: ^2.2.3 hive_flutter: ^1.1.0 path_provider: ^2.1.1 flutter_local_notifications: ^19.0.0 timezone: ^0.10.1 file_picker: ^10.3.3 syncfusion_flutter_calendar: ^30.1.37 syncfusion_localizations: ^30.1.37 package_info_plus: ^8.0.0 flutter_common: path: ..\flutter_common dev_dependencies: flutter_test: sdk: flutter hive_generator: ^2.0.1 build_runner: ^2.4.6 flutter_lints: ^5.0.0 flutter: uses-material-design: true fonts: - family: CustomFont fonts: - asset: fonts/custom.ttf \ No newline at end of file diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 22806d1..28c9fa8 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + flutter_local_notifications_windows ) set(PLUGIN_BUNDLED_LIBRARIES)