Merge branch 'main' into pr/434

This commit is contained in:
orz12
2024-01-27 10:28:55 +08:00
43 changed files with 719 additions and 586 deletions

7
lib/utils/extension.dart Normal file
View File

@ -0,0 +1,7 @@
import 'package:flutter/material.dart';
extension ImageExtension on num {
int cacheSize(BuildContext context) {
return (this * MediaQuery.of(context).devicePixelRatio).round();
}
}

View File

@ -1,5 +1,6 @@
// ignore_for_file: constant_identifier_names
import 'dart:convert';
import 'dart:math';
import 'package:flutter/material.dart';
@ -72,4 +73,19 @@ class IdUtils {
}
return result;
}
// eid生成
static String? genAuroraEid(int uid) {
if (uid == 0) {
return null;
}
String uidString = uid.toString();
List<int> resultBytes = List.generate(
uidString.length,
(i) => uidString.codeUnitAt(i) ^ "ad1va46a7lza".codeUnitAt(i % 12),
);
String auroraEid = base64Url.encode(resultBytes);
auroraEid = auroraEid.replaceAll(RegExp(r'=*$', multiLine: true), '');
return auroraEid;
}
}

View File

@ -3,13 +3,11 @@ import 'dart:io';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pilipala/models/home/rcmd/result.dart';
import 'package:pilipala/models/model_owner.dart';
import 'package:pilipala/models/search/hot.dart';
import 'package:pilipala/models/user/info.dart';
class GStrorage {
static late final Box<dynamic> recVideo;
static late final Box<dynamic> userInfo;
static late final Box<dynamic> historyword;
static late final Box<dynamic> localCache;
@ -21,13 +19,6 @@ class GStrorage {
final String path = dir.path;
await Hive.initFlutter('$path/hive');
regAdapter();
// 首页推荐视频
recVideo = await Hive.openBox(
'recVideo',
compactionStrategy: (int entries, int deletedEntries) {
return deletedEntries > 12;
},
);
// 登录用户信息
userInfo = await Hive.openBox(
'userInfo',
@ -54,10 +45,6 @@ class GStrorage {
}
static void regAdapter() {
Hive.registerAdapter(RecVideoItemAppModelAdapter());
Hive.registerAdapter(RcmdReasonAdapter());
Hive.registerAdapter(RcmdStatAdapter());
Hive.registerAdapter(RcmdOwnerAdapter());
Hive.registerAdapter(OwnerAdapter());
Hive.registerAdapter(UserInfoDataAdapter());
Hive.registerAdapter(LevelInfoAdapter());
@ -73,8 +60,6 @@ class GStrorage {
static Future<void> close() async {
// user.compact();
// user.close();
recVideo.compact();
recVideo.close();
userInfo.compact();
userInfo.close();
historyword.compact();
@ -151,7 +136,8 @@ class SettingBoxKey {
customRows = 'customRows', // 自定义列
enableMYBar = 'enableMYBar',
hideSearchBar = 'hideSearchBar', // 收起顶栏
hideTabBar = 'hideTabBar'; // 收起底栏
hideTabBar = 'hideTabBar', // 收起底栏
tabbarSort = 'tabbarSort'; // 首页tabbar
}
class LocalCacheKey {