feat: 用户信息缓存

This commit is contained in:
guozhigq
2023-05-19 23:48:09 +08:00
parent 13cecf5b84
commit 006f22bbb6
4 changed files with 34 additions and 21 deletions

View File

@ -14,14 +14,7 @@ class GStrorage {
final dir = await getApplicationDocumentsDirectory();
final path = dir.path;
await Hive.initFlutter('$path/hive');
// 首页推荐视频
Hive.registerAdapter(RecVideoItemModelAdapter());
Hive.registerAdapter(RcmdReasonAdapter());
Hive.registerAdapter(StatAdapter());
Hive.registerAdapter(OwnerAdapter());
Hive.registerAdapter(UserInfoDataAdapter());
Hive.registerAdapter(LevelInfoAdapter());
regAdapter();
// 用户信息
user = await Hive.openBox('user');
// 首页推荐视频
@ -29,6 +22,15 @@ class GStrorage {
// 登录用户信息
userInfo = await Hive.openBox('userInfo');
}
static regAdapter() {
Hive.registerAdapter(RecVideoItemModelAdapter());
Hive.registerAdapter(RcmdReasonAdapter());
Hive.registerAdapter(StatAdapter());
Hive.registerAdapter(OwnerAdapter());
Hive.registerAdapter(UserInfoDataAdapter());
Hive.registerAdapter(LevelInfoAdapter());
}
}
// 约定 key
@ -41,3 +43,7 @@ class UserBoxKey {
// 登录状态
static const String userLogin = 'userLogin';
}
class SettingBoxKey {
static const String themeMode = 'themeMode';
}