diff --git a/lib/app.dart b/lib/app.dart index a74a752c..05cfe19b 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -20,11 +20,14 @@ class MyApp extends ApplicationWidget { Widget buildApplication(ApplicationModel applicationModel) => const App(); @override - Widget buildErrorWidget(Object e, Object s,BuildContext context, WidgetRef ref) { + Widget buildErrorWidget(Object e, Object s, BuildContext context, WidgetRef ref) { if (e is AppException) { kLog(e.message); } - return InitLoadingWidget(isError: true,retry: ()=>ref.invalidate(application(ApplocationContext(context, ref))),); + return InitLoadingWidget( + isError: true, + retry: () => ref.invalidate(application(ApplocationContext(context, ref))), + ); } @override @@ -80,11 +83,6 @@ class AppBottomNav extends View { currentIndex: currentIndex, onTap: ((index) { appCore.ref.read(homeModuleShowIndex.notifier).state = index; - if (index == 3) { - delayFunction(() { - appCore.favoritesRepository.refresh(true); - }); - } }), items: [ BottomNavigationBarItem(label: '首页', icon: _buildIcon(currentIndex, 0, 'home', context)), @@ -95,3 +93,5 @@ class AppBottomNav extends View { ]); } } + + diff --git a/lib/common/view.dart b/lib/common/view.dart index 0cc6ca0a..5fc58026 100644 --- a/lib/common/view.dart +++ b/lib/common/view.dart @@ -55,7 +55,7 @@ extension ApplicationContextEx on ApplocationContext { extension ApplicationModelEx on ApplicationModel { IList get watchCategory => ref.watch(categoryRiverpod.select((value) => value.categorys)); } - +typedef MyView = View; ///自定义封装view abstract class View extends ConsumerWidget { const View({super.key}); diff --git a/lib/provider/riverpod/favorites/riverpod_model.g.dart b/lib/provider/riverpod/favorites/riverpod_model.g.dart index d5eb1382..490c127a 100644 --- a/lib/provider/riverpod/favorites/riverpod_model.g.dart +++ b/lib/provider/riverpod/favorites/riverpod_model.g.dart @@ -10,7 +10,7 @@ _$_FavoritesStateModel _$$_FavoritesStateModelFromJson( Map json) => _$_FavoritesStateModel( favorites: (json['favorites'] as List) - .map((e) => MyFavoritesModel.fromJson(e)) + .map(MyFavoritesModel.fromJson) .toList(), page: json['page'] as int, ); diff --git a/lib/provider/riverpod/model/my_user.dart b/lib/provider/riverpod/model/my_user.dart index 1773d63c..072a3f48 100644 --- a/lib/provider/riverpod/model/my_user.dart +++ b/lib/provider/riverpod/model/my_user.dart @@ -21,7 +21,21 @@ class MyUser with _$MyUser{ @Default(false) bool accountNonExpired, @Default(false) bool accountNonLocked, @Default(false) bool credentialsNonExpired, - + @Default(Vip.none) Vip vip }) = _MyUser; factory MyUser.fromJson(Map json)=>_$MyUserFromJson(json); } + +@JsonEnum(valueField: 'vip') +enum Vip { + @JsonValue(0) + none, + @JsonValue(1) + vip, + + @JsonValue(2) + superVip, + + @JsonValue(3) + specialVip +} \ No newline at end of file diff --git a/lib/provider/riverpod/model/my_user.freezed.dart b/lib/provider/riverpod/model/my_user.freezed.dart index 1012a7af..6c839560 100644 --- a/lib/provider/riverpod/model/my_user.freezed.dart +++ b/lib/provider/riverpod/model/my_user.freezed.dart @@ -34,6 +34,7 @@ mixin _$MyUser { bool get accountNonExpired => throw _privateConstructorUsedError; bool get accountNonLocked => throw _privateConstructorUsedError; bool get credentialsNonExpired => throw _privateConstructorUsedError; + Vip get vip => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -59,7 +60,8 @@ abstract class $MyUserCopyWith<$Res> { bool enabled, bool accountNonExpired, bool accountNonLocked, - bool credentialsNonExpired}); + bool credentialsNonExpired, + Vip vip}); } /// @nodoc @@ -89,6 +91,7 @@ class _$MyUserCopyWithImpl<$Res, $Val extends MyUser> Object? accountNonExpired = null, Object? accountNonLocked = null, Object? credentialsNonExpired = null, + Object? vip = null, }) { return _then(_value.copyWith( id: null == id @@ -147,6 +150,10 @@ class _$MyUserCopyWithImpl<$Res, $Val extends MyUser> ? _value.credentialsNonExpired : credentialsNonExpired // ignore: cast_nullable_to_non_nullable as bool, + vip: null == vip + ? _value.vip + : vip // ignore: cast_nullable_to_non_nullable + as Vip, ) as $Val); } } @@ -171,7 +178,8 @@ abstract class _$$_MyUserCopyWith<$Res> implements $MyUserCopyWith<$Res> { bool enabled, bool accountNonExpired, bool accountNonLocked, - bool credentialsNonExpired}); + bool credentialsNonExpired, + Vip vip}); } /// @nodoc @@ -198,6 +206,7 @@ class __$$_MyUserCopyWithImpl<$Res> Object? accountNonExpired = null, Object? accountNonLocked = null, Object? credentialsNonExpired = null, + Object? vip = null, }) { return _then(_$_MyUser( id: null == id @@ -256,6 +265,10 @@ class __$$_MyUserCopyWithImpl<$Res> ? _value.credentialsNonExpired : credentialsNonExpired // ignore: cast_nullable_to_non_nullable as bool, + vip: null == vip + ? _value.vip + : vip // ignore: cast_nullable_to_non_nullable + as Vip, )); } } @@ -277,7 +290,8 @@ class _$_MyUser implements _MyUser { this.enabled = false, this.accountNonExpired = false, this.accountNonLocked = false, - this.credentialsNonExpired = false}); + this.credentialsNonExpired = false, + this.vip = Vip.none}); factory _$_MyUser.fromJson(Map json) => _$$_MyUserFromJson(json); @@ -323,10 +337,13 @@ class _$_MyUser implements _MyUser { @override @JsonKey() final bool credentialsNonExpired; + @override + @JsonKey() + final Vip vip; @override String toString() { - return 'MyUser(id: $id, loginNumber: $loginNumber, username: $username, email: $email, nickName: $nickName, picture: $picture, phone: $phone, type: $type, status: $status, loginTime: $loginTime, enabled: $enabled, accountNonExpired: $accountNonExpired, accountNonLocked: $accountNonLocked, credentialsNonExpired: $credentialsNonExpired)'; + return 'MyUser(id: $id, loginNumber: $loginNumber, username: $username, email: $email, nickName: $nickName, picture: $picture, phone: $phone, type: $type, status: $status, loginTime: $loginTime, enabled: $enabled, accountNonExpired: $accountNonExpired, accountNonLocked: $accountNonLocked, credentialsNonExpired: $credentialsNonExpired, vip: $vip)'; } @override @@ -354,7 +371,8 @@ class _$_MyUser implements _MyUser { (identical(other.accountNonLocked, accountNonLocked) || other.accountNonLocked == accountNonLocked) && (identical(other.credentialsNonExpired, credentialsNonExpired) || - other.credentialsNonExpired == credentialsNonExpired)); + other.credentialsNonExpired == credentialsNonExpired) && + (identical(other.vip, vip) || other.vip == vip)); } @JsonKey(ignore: true) @@ -374,7 +392,8 @@ class _$_MyUser implements _MyUser { enabled, accountNonExpired, accountNonLocked, - credentialsNonExpired); + credentialsNonExpired, + vip); @JsonKey(ignore: true) @override @@ -405,7 +424,8 @@ abstract class _MyUser implements MyUser { final bool enabled, final bool accountNonExpired, final bool accountNonLocked, - final bool credentialsNonExpired}) = _$_MyUser; + final bool credentialsNonExpired, + final Vip vip}) = _$_MyUser; factory _MyUser.fromJson(Map json) = _$_MyUser.fromJson; @@ -438,6 +458,8 @@ abstract class _MyUser implements MyUser { @override bool get credentialsNonExpired; @override + Vip get vip; + @override @JsonKey(ignore: true) _$$_MyUserCopyWith<_$_MyUser> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/provider/riverpod/model/my_user.g.dart b/lib/provider/riverpod/model/my_user.g.dart index 10e4cd01..070c46d3 100644 --- a/lib/provider/riverpod/model/my_user.g.dart +++ b/lib/provider/riverpod/model/my_user.g.dart @@ -21,6 +21,7 @@ _$_MyUser _$$_MyUserFromJson(Map json) => _$_MyUser( accountNonExpired: json['accountNonExpired'] as bool? ?? false, accountNonLocked: json['accountNonLocked'] as bool? ?? false, credentialsNonExpired: json['credentialsNonExpired'] as bool? ?? false, + vip: $enumDecodeNullable(_$VipEnumMap, json['vip']) ?? Vip.none, ); Map _$$_MyUserToJson(_$_MyUser instance) => { @@ -38,4 +39,12 @@ Map _$$_MyUserToJson(_$_MyUser instance) => { 'accountNonExpired': instance.accountNonExpired, 'accountNonLocked': instance.accountNonLocked, 'credentialsNonExpired': instance.credentialsNonExpired, + 'vip': _$VipEnumMap[instance.vip]!, }; + +const _$VipEnumMap = { + Vip.none: 0, + Vip.vip: 1, + Vip.superVip: 2, + Vip.specialVip: 3, +};