feat: 首页推荐视频缓存

This commit is contained in:
guozhigq
2023-05-17 10:27:54 +08:00
parent 83fac74630
commit 75ed91c29d
17 changed files with 526 additions and 14 deletions

View File

@ -1,14 +1,27 @@
import 'package:hive/hive.dart';
// import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pilipala/models/model_owner.dart';
import 'package:pilipala/models/model_rec_video_item.dart';
class GStrorage {
static late final Box user;
static late final Box recVideo;
static Future<void> init() async {
final dir = await getApplicationDocumentsDirectory();
final path = dir.path;
Hive.init('$path/hive');
await Hive.initFlutter('$path/hive');
// 首页推荐视频
Hive.registerAdapter(RecVideoItemModelAdapter());
Hive.registerAdapter(RcmdReasonAdapter());
Hive.registerAdapter(StatAdapter());
Hive.registerAdapter(OwnerAdapter());
// 用户信息
user = await Hive.openBox('user');
// 首页推荐视频
recVideo = await Hive.openBox('recVideo');
}
}