|
|
|
@ -12,6 +12,7 @@ import '../../../modules/login/controllers/googleLogin.dart'; |
|
|
|
import '../../../modules/login/controllers/facebookLogin.dart'; |
|
|
|
import 'package:path_provider/path_provider.dart'; |
|
|
|
import 'dart:io'; |
|
|
|
import '../../../routes/app_routes.dart'; |
|
|
|
|
|
|
|
class SettingsController extends GetxController { |
|
|
|
// 语言设置 |
|
|
|
@ -279,14 +280,48 @@ class SettingsController extends GetxController { |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> signOut() async { |
|
|
|
// 在此实现退出登录逻辑 |
|
|
|
_storage.write("logintoken", ""); |
|
|
|
_storage.write("user_info", ""); |
|
|
|
try { |
|
|
|
//显示加载提示 |
|
|
|
// Get.dialog( |
|
|
|
// const Center(child: CircularProgressIndicator()), |
|
|
|
// barrierDismissible: false, |
|
|
|
// ); |
|
|
|
|
|
|
|
// 清理所有存储 |
|
|
|
await _storage.erase(); |
|
|
|
// 或者逐个清理关键存储项 |
|
|
|
await _storage.write("logintoken", null); |
|
|
|
await _storage.write("user_info", null); |
|
|
|
await _storage.write("local_avatar", null); |
|
|
|
print('清理存储成功'); |
|
|
|
|
|
|
|
// 第三方登录退出 |
|
|
|
try { |
|
|
|
final google = Google(); |
|
|
|
final facebook = Facebook(); |
|
|
|
await Future.wait([ |
|
|
|
google.signOutGoogle(), |
|
|
|
facebook.signOutFacebook(), |
|
|
|
]); |
|
|
|
} catch (e) { |
|
|
|
print('第三方登录退出错误: $e'); |
|
|
|
// 继续执行,不中断退出流程 |
|
|
|
} |
|
|
|
|
|
|
|
// 关闭加载提示 |
|
|
|
//Get.back(); |
|
|
|
|
|
|
|
// 确保导航到登录页面 |
|
|
|
if (Get.currentRoute != Routes.login) { |
|
|
|
await Get.offAllNamed(Routes.login); |
|
|
|
} |
|
|
|
|
|
|
|
await google.signOutGoogle(); |
|
|
|
await facebook.signOutFacebook(); |
|
|
|
Get.offAllNamed('/login'); |
|
|
|
Get.snackbar('成功', '已退出登录'); |
|
|
|
print('退出登录成功'); |
|
|
|
} catch (e) { |
|
|
|
//Get.back(); // 关闭加载提示 |
|
|
|
Get.snackbar('错误', '退出登录失败,请重试'); |
|
|
|
print('退出登录错误: $e'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|