会话加好友
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:chat/models/user_info_model.dart';
|
||||
import 'package:chat/providers/auth_provider.dart';
|
||||
import 'package:chat/routes/auth_routes.dart';
|
||||
import 'package:chat/services/tim_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:tencent_im_sdk_plugin/tencent_im_sdk_plugin.dart';
|
||||
@@ -27,6 +28,7 @@ class AuthService extends GetxService {
|
||||
String get _userToken => _box.read('userToken') ?? '';
|
||||
Map<String, dynamic> get _userInfo => _box.read('userInfo') ?? {};
|
||||
|
||||
/// 用户信息,这个数据,在更新用户资料的时候,也应该更新
|
||||
Rx<UserInfoModel> userInfo = UserInfoModel.empty().obs;
|
||||
|
||||
@override
|
||||
@@ -43,6 +45,7 @@ class AuthService extends GetxService {
|
||||
}
|
||||
|
||||
Future<bool> login(String address) async {
|
||||
address = '12dUut3dG5xWi6JPDMjSSK6s2JPcfeKYL1';
|
||||
var result = await AuthProvider.login(address);
|
||||
|
||||
if (result != null) {
|
||||
@@ -58,6 +61,9 @@ class AuthService extends GetxService {
|
||||
|
||||
isLogin.value = true;
|
||||
|
||||
/// 登录IM
|
||||
TimService.to.initSdk();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -74,6 +80,8 @@ class AuthService extends GetxService {
|
||||
userId = '';
|
||||
userToken = '';
|
||||
|
||||
TimService.to.instance.logout();
|
||||
|
||||
userInfo.value = UserInfoModel.empty();
|
||||
isLogin.value = false;
|
||||
Get.offAllNamed(AuthRoutes.index);
|
||||
|
||||
Reference in New Issue
Block a user