33 lines
760 B
Dart
33 lines
760 B
Dart
|
|
import 'package:app/core/utils/storage.dart';
|
|
|
|
/// 登录数据仓库
|
|
class AuthRepo {
|
|
static final String _key = "login_info";
|
|
|
|
///登录储存信息
|
|
static Future<void> saveLogin(dynamic loginDto) async {
|
|
await Storage.set(_key, loginDto.toJson());
|
|
}
|
|
|
|
///获取登录信息
|
|
static Future<dynamic> getLoginInfo() async {
|
|
// final loginInfo = await Storage.get<dynamic?>(
|
|
// _key,
|
|
// decoder: (json) => dynamic.fromJson(json),
|
|
// );
|
|
// return loginInfo;
|
|
return null;
|
|
}
|
|
|
|
///获取token
|
|
static Future<String?> getToken() async {
|
|
final loginInfo = await getLoginInfo();
|
|
return loginInfo?.token;
|
|
}
|
|
|
|
///清除登录信息
|
|
static Future<void> clearLogin() async {
|
|
await Storage.remove(_key);
|
|
}
|
|
} |