Quellcode durchsuchen

[new]增加账号顶替弹窗

zk vor 6 Monaten
Ursprung
Commit
98b8dfd5c2

+ 21 - 0
lib/dialog/account_replace_dialog.dart

@@ -0,0 +1,21 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+
+class AccountReplaceDialog {
+  static const String _tag = 'AccountReplaceDialog';
+
+  static void show() {
+    SmartDialog.show(builder: (_) => _AccountReplaceView(), tag: _tag);
+  }
+
+  static void dismiss() {
+    SmartDialog.dismiss(tag: _tag);
+  }
+}
+
+class _AccountReplaceView extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return Container(child: Text('账号已在其他设备登录,请重新登录'));
+  }
+}

+ 5 - 0
lib/socket/atmob_location_client.dart

@@ -15,6 +15,7 @@ import '../data/bean/location_info.dart';
 import '../data/repositories/account_repository.dart';
 import '../data/repositories/contact_repository.dart';
 import '../data/repositories/message_repository.dart';
+import '../dialog/account_replace_dialog.dart';
 import 'location_message.dart';
 
 typedef OnLocationChangeListener = void Function(List<LocationInfo> data);
@@ -133,6 +134,10 @@ class AtmobLocationClient {
             case SocketConstants.refreshMember:
               AccountRepository.getInstance().refreshMemberStatus();
               break;
+            case SocketConstants.refreshUserLogin:
+              AccountReplaceDialog.show();
+              AccountRepository.getInstance().logout();
+              break;
           }
           return SocketConstants.receiveFriendBatchLocation == message.cmd;
         })

+ 1 - 0
lib/socket/socket_constants.dart

@@ -10,6 +10,7 @@ class SocketConstants {
       'd.refresh.friend.message'; // 刷新好友消息
   static const String refreshContact = 'd.refresh.contact'; // 刷新联系人
   static const String refreshMember = 'd.refresh.member'; // 刷新会员信息
+  static const String refreshUserLogin = 'd.refresh.user.login'; // 刷新用户登录
 
   static const String receiveFriendBatchLocation =
       'd.location.batch'; //批量接收好友位置信息