Merge branch 'main' into pr/434
This commit is contained in:
7
lib/utils/extension.dart
Normal file
7
lib/utils/extension.dart
Normal 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();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user