初始化
This commit is contained in:
33
lib/data/repository/auto_repo.dart
Normal file
33
lib/data/repository/auto_repo.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user