import 'package:flutter_translate/model/history_model.dart';
import 'package:hive_flutter/hive_flutter.dart';

const historyBox = 'historyBox';
const remoteConfigBox = 'remoteConfigBox';

Future initHive() async {
  // 初始化
  await Hive.initFlutter();
  // 注册类型适配器
  Hive.registerAdapter(HistoryEntityAdapter());
  // 打开盒子
  await Hive.openBox<HistoryModel>(historyBox);
  await Hive.openBox(remoteConfigBox);
}

Box<HistoryModel> getHistoryBox() {
  return Hive.box<HistoryModel>(historyBox);
}

Box getRemoteConfigBox() {
  return Hive.box(remoteConfigBox);
}