feat: InportExportDialog (#1048)

This commit is contained in:
My-Responsitories
2025-08-18 21:25:00 +08:00
committed by GitHub
parent 08c3789321
commit ed57697fdc
4 changed files with 188 additions and 198 deletions

View File

@@ -14,7 +14,7 @@ import 'package:path_provider/path_provider.dart';
class GStorage {
static late final Box<UserInfoData> userInfo;
static late final Box<dynamic> historyWord;
static late final Box<List<String>> historyWord;
static late final Box<dynamic> localCache;
static late final Box<dynamic> setting;
static late final Box<dynamic> video;
@@ -41,7 +41,7 @@ class GStorage {
// 设置
setting = await Hive.openBox('setting');
// 搜索历史
historyWord = await Hive.openBox(
historyWord = await Hive.openBox<List<String>>(
'historyWord',
compactionStrategy: (int entries, int deletedEntries) {
return deletedEntries > 10;
@@ -60,8 +60,10 @@ class GStorage {
});
}
static Future<void> importAllSettings(String data) async {
final Map<String, dynamic> map = jsonDecode(data);
static Future<void> importAllSettings(String data) =>
importAllJsonSettings(jsonDecode(data));
static Future<void> importAllJsonSettings(Map<String, dynamic> map) async {
await setting.clear();
await video.clear();
await setting.putAll(map[setting.name]);