31 lines
1.4 KiB
Dart
31 lines
1.4 KiB
Dart
// ============================================================
|
|
// MessageProvider — 通知/消息 Riverpod Providers
|
|
// ============================================================
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../../core/services/notification_service.dart';
|
|
|
|
final notificationServiceProvider = Provider<NotificationService>((ref) {
|
|
return NotificationService();
|
|
});
|
|
|
|
// ── 通知列表 ──────────────────────────────────────────────────
|
|
|
|
final notificationsProvider =
|
|
FutureProvider.autoDispose.family<NotificationListResponse, NotificationType?>(
|
|
(ref, type) async {
|
|
return ref.read(notificationServiceProvider).getNotifications(type: type);
|
|
});
|
|
|
|
// ── 未读数量 ──────────────────────────────────────────────────
|
|
|
|
final unreadCountProvider = FutureProvider.autoDispose((ref) async {
|
|
return ref.read(notificationServiceProvider).getUnreadCount();
|
|
});
|
|
|
|
// ── 公告列表 ──────────────────────────────────────────────────
|
|
|
|
final announcementsProvider = FutureProvider.autoDispose((ref) async {
|
|
return ref.read(notificationServiceProvider).getAnnouncements();
|
|
});
|