tokenreplacedhandler.dart 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:flyinsonolite/helpers/dialoghelper.dart';
  4. import 'package:flyinsonolite/infrastructure/storage.dart';
  5. import 'package:flyinsonolite/infrastructure/routeconstants.dart';
  6. import 'package:get/get.dart';
  7. /// 账号被挤出通知
  8. class TokenReplacedNotificationHandler
  9. extends NotificationHandler<TokenReplacedNotification> {
  10. TokenReplacedNotificationHandler()
  11. : super(NotificationTypeEnum.TokenReplacedNotification);
  12. @override
  13. void execute(TokenReplacedNotification message) async {
  14. super.execute(message);
  15. await Storage.user.handleLogOutAsync(goToLoginPage: false);
  16. if (Get.context == null) return;
  17. DialogHelper.showConfirmDialog(
  18. Get.context!, i18nBook.auth.tokenReplacedTips.t, () async {
  19. Get.close(1);
  20. if (Get.currentRoute !=
  21. RouteConstants.consultationRouteConstants.applyconsultation) {
  22. ///applyconsultation如果直接offAllNamed会多次Rebuild
  23. Get.close(1);
  24. }
  25. await Get.offAllNamed(Storage.loginRoute);
  26. }, showCancelButton: false, showCloseButton: false);
  27. }
  28. }