2026-01-11 19:42:22 +08:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
|
|
|
|
|
import '../domain/entities/user_entity.dart';
|
2026-01-18 20:21:14 +08:00
|
|
|
import 'app_user_state.dart';
|
2026-01-11 19:42:22 +08:00
|
|
|
|
2026-01-18 20:21:14 +08:00
|
|
|
class AppUserCubit extends Cubit<AppUserState> {
|
|
|
|
|
AppUserCubit() : super(const AppUserState());
|
2026-01-11 19:42:22 +08:00
|
|
|
|
|
|
|
|
void setAuth(UserEntity user) {
|
2026-08-10 10:00:52 +08:00
|
|
|
print('✅ [AppUserCubit] setAuth 被调用,用户: ${user.username}, roleKey=${user.roleKey}, orgId=${user.orgId}, siteId=${user.siteId}');
|
2026-01-11 19:42:22 +08:00
|
|
|
emit(state.copyWith(user));
|
2026-08-10 10:00:52 +08:00
|
|
|
print('✅ [AppUserCubit] 状态已更新,当前用户: ${state.user?.username}, roleKey=${state.user?.roleKey}');
|
2026-01-11 19:42:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clearAuth() {
|
2026-01-18 20:21:14 +08:00
|
|
|
emit(const AppUserState());
|
2026-01-11 19:42:22 +08:00
|
|
|
}
|
|
|
|
|
}
|