mod: 移除首页推荐视频默认缓存
This commit is contained in:
@ -1,8 +1,3 @@
|
|||||||
import 'package:hive/hive.dart';
|
|
||||||
|
|
||||||
part 'result.g.dart';
|
|
||||||
|
|
||||||
@HiveType(typeId: 0)
|
|
||||||
class RecVideoItemAppModel {
|
class RecVideoItemAppModel {
|
||||||
RecVideoItemAppModel({
|
RecVideoItemAppModel({
|
||||||
this.id,
|
this.id,
|
||||||
@ -27,47 +22,27 @@ class RecVideoItemAppModel {
|
|||||||
this.adInfo,
|
this.adInfo,
|
||||||
});
|
});
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
int? id;
|
int? id;
|
||||||
@HiveField(1)
|
|
||||||
int? aid;
|
int? aid;
|
||||||
@HiveField(2)
|
|
||||||
String? bvid;
|
String? bvid;
|
||||||
@HiveField(3)
|
|
||||||
int? cid;
|
int? cid;
|
||||||
@HiveField(4)
|
|
||||||
String? pic;
|
String? pic;
|
||||||
@HiveField(5)
|
|
||||||
RcmdStat? stat;
|
RcmdStat? stat;
|
||||||
@HiveField(6)
|
|
||||||
String? duration;
|
String? duration;
|
||||||
@HiveField(7)
|
|
||||||
String? title;
|
String? title;
|
||||||
@HiveField(8)
|
|
||||||
int? isFollowed;
|
int? isFollowed;
|
||||||
@HiveField(9)
|
|
||||||
RcmdOwner? owner;
|
RcmdOwner? owner;
|
||||||
@HiveField(10)
|
|
||||||
RcmdReason? rcmdReason;
|
RcmdReason? rcmdReason;
|
||||||
@HiveField(11)
|
|
||||||
String? goto;
|
String? goto;
|
||||||
@HiveField(12)
|
|
||||||
int? param;
|
int? param;
|
||||||
@HiveField(13)
|
|
||||||
String? uri;
|
String? uri;
|
||||||
@HiveField(14)
|
|
||||||
String? talkBack;
|
String? talkBack;
|
||||||
// 番剧
|
// 番剧
|
||||||
@HiveField(15)
|
|
||||||
String? bangumiView;
|
String? bangumiView;
|
||||||
@HiveField(16)
|
|
||||||
String? bangumiFollow;
|
String? bangumiFollow;
|
||||||
@HiveField(17)
|
|
||||||
String? bangumiBadge;
|
String? bangumiBadge;
|
||||||
|
|
||||||
@HiveField(18)
|
|
||||||
String? cardType;
|
String? cardType;
|
||||||
@HiveField(19)
|
|
||||||
Map? adInfo;
|
Map? adInfo;
|
||||||
|
|
||||||
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
||||||
@ -102,18 +77,14 @@ class RecVideoItemAppModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HiveType(typeId: 1)
|
|
||||||
class RcmdStat {
|
class RcmdStat {
|
||||||
RcmdStat({
|
RcmdStat({
|
||||||
this.view,
|
this.view,
|
||||||
this.like,
|
this.like,
|
||||||
this.danmu,
|
this.danmu,
|
||||||
});
|
});
|
||||||
@HiveField(0)
|
|
||||||
String? view;
|
String? view;
|
||||||
@HiveField(1)
|
|
||||||
String? like;
|
String? like;
|
||||||
@HiveField(2)
|
|
||||||
String? danmu;
|
String? danmu;
|
||||||
|
|
||||||
RcmdStat.fromJson(Map<String, dynamic> json) {
|
RcmdStat.fromJson(Map<String, dynamic> json) {
|
||||||
@ -122,13 +93,10 @@ class RcmdStat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HiveType(typeId: 2)
|
|
||||||
class RcmdOwner {
|
class RcmdOwner {
|
||||||
RcmdOwner({this.name, this.mid});
|
RcmdOwner({this.name, this.mid});
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
String? name;
|
String? name;
|
||||||
@HiveField(1)
|
|
||||||
int? mid;
|
int? mid;
|
||||||
|
|
||||||
RcmdOwner.fromJson(Map<String, dynamic> json) {
|
RcmdOwner.fromJson(Map<String, dynamic> json) {
|
||||||
@ -141,13 +109,11 @@ class RcmdOwner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HiveType(typeId: 8)
|
|
||||||
class RcmdReason {
|
class RcmdReason {
|
||||||
RcmdReason({
|
RcmdReason({
|
||||||
this.content,
|
this.content,
|
||||||
});
|
});
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
String? content;
|
String? content;
|
||||||
|
|
||||||
RcmdReason.fromJson(Map<String, dynamic> json) {
|
RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||||
|
|||||||
@ -1,209 +0,0 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
|
|
||||||
part of 'result.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// TypeAdapterGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
class RecVideoItemAppModelAdapter extends TypeAdapter<RecVideoItemAppModel> {
|
|
||||||
@override
|
|
||||||
final int typeId = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
RecVideoItemAppModel read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return RecVideoItemAppModel(
|
|
||||||
id: fields[0] as int?,
|
|
||||||
aid: fields[1] as int?,
|
|
||||||
bvid: fields[2] as String?,
|
|
||||||
cid: fields[3] as int?,
|
|
||||||
pic: fields[4] as String?,
|
|
||||||
stat: fields[5] as RcmdStat?,
|
|
||||||
duration: fields[6] as String?,
|
|
||||||
title: fields[7] as String?,
|
|
||||||
isFollowed: fields[8] as int?,
|
|
||||||
owner: fields[9] as RcmdOwner?,
|
|
||||||
rcmdReason: fields[10] as RcmdReason?,
|
|
||||||
goto: fields[11] as String?,
|
|
||||||
param: fields[12] as int?,
|
|
||||||
uri: fields[13] as String?,
|
|
||||||
talkBack: fields[14] as String?,
|
|
||||||
bangumiView: fields[15] as String?,
|
|
||||||
bangumiFollow: fields[16] as String?,
|
|
||||||
bangumiBadge: fields[17] as String?,
|
|
||||||
cardType: fields[18] as String?,
|
|
||||||
adInfo: (fields[19] as Map?)?.cast<dynamic, dynamic>(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, RecVideoItemAppModel obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(20)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.id)
|
|
||||||
..writeByte(1)
|
|
||||||
..write(obj.aid)
|
|
||||||
..writeByte(2)
|
|
||||||
..write(obj.bvid)
|
|
||||||
..writeByte(3)
|
|
||||||
..write(obj.cid)
|
|
||||||
..writeByte(4)
|
|
||||||
..write(obj.pic)
|
|
||||||
..writeByte(5)
|
|
||||||
..write(obj.stat)
|
|
||||||
..writeByte(6)
|
|
||||||
..write(obj.duration)
|
|
||||||
..writeByte(7)
|
|
||||||
..write(obj.title)
|
|
||||||
..writeByte(8)
|
|
||||||
..write(obj.isFollowed)
|
|
||||||
..writeByte(9)
|
|
||||||
..write(obj.owner)
|
|
||||||
..writeByte(10)
|
|
||||||
..write(obj.rcmdReason)
|
|
||||||
..writeByte(11)
|
|
||||||
..write(obj.goto)
|
|
||||||
..writeByte(12)
|
|
||||||
..write(obj.param)
|
|
||||||
..writeByte(13)
|
|
||||||
..write(obj.uri)
|
|
||||||
..writeByte(14)
|
|
||||||
..write(obj.talkBack)
|
|
||||||
..writeByte(15)
|
|
||||||
..write(obj.bangumiView)
|
|
||||||
..writeByte(16)
|
|
||||||
..write(obj.bangumiFollow)
|
|
||||||
..writeByte(17)
|
|
||||||
..write(obj.bangumiBadge)
|
|
||||||
..writeByte(18)
|
|
||||||
..write(obj.cardType)
|
|
||||||
..writeByte(19)
|
|
||||||
..write(obj.adInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is RecVideoItemAppModelAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RcmdStatAdapter extends TypeAdapter<RcmdStat> {
|
|
||||||
@override
|
|
||||||
final int typeId = 1;
|
|
||||||
|
|
||||||
@override
|
|
||||||
RcmdStat read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return RcmdStat(
|
|
||||||
view: fields[0] as String?,
|
|
||||||
like: fields[1] as String?,
|
|
||||||
danmu: fields[2] as String?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, RcmdStat obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(3)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.view)
|
|
||||||
..writeByte(1)
|
|
||||||
..write(obj.like)
|
|
||||||
..writeByte(2)
|
|
||||||
..write(obj.danmu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is RcmdStatAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RcmdOwnerAdapter extends TypeAdapter<RcmdOwner> {
|
|
||||||
@override
|
|
||||||
final int typeId = 2;
|
|
||||||
|
|
||||||
@override
|
|
||||||
RcmdOwner read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return RcmdOwner(
|
|
||||||
name: fields[0] as String?,
|
|
||||||
mid: fields[1] as int?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, RcmdOwner obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(2)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.name)
|
|
||||||
..writeByte(1)
|
|
||||||
..write(obj.mid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is RcmdOwnerAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RcmdReasonAdapter extends TypeAdapter<RcmdReason> {
|
|
||||||
@override
|
|
||||||
final int typeId = 8;
|
|
||||||
|
|
||||||
@override
|
|
||||||
RcmdReason read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return RcmdReason(
|
|
||||||
content: fields[0] as String?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, RcmdReason obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(1)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.content);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is RcmdReasonAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
@ -13,7 +13,6 @@ class RcmdController extends GetxController {
|
|||||||
RxList<RecVideoItemModel> webVideoList = <RecVideoItemModel>[].obs;
|
RxList<RecVideoItemModel> webVideoList = <RecVideoItemModel>[].obs;
|
||||||
bool isLoadingMore = true;
|
bool isLoadingMore = true;
|
||||||
OverlayEntry? popupDialog;
|
OverlayEntry? popupDialog;
|
||||||
Box recVideo = GStrorage.recVideo;
|
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
RxInt crossAxisCount = 2.obs;
|
RxInt crossAxisCount = 2.obs;
|
||||||
late bool enableSaveLastData;
|
late bool enableSaveLastData;
|
||||||
@ -24,15 +23,6 @@ class RcmdController extends GetxController {
|
|||||||
super.onInit();
|
super.onInit();
|
||||||
crossAxisCount.value =
|
crossAxisCount.value =
|
||||||
setting.get(SettingBoxKey.customRows, defaultValue: 2);
|
setting.get(SettingBoxKey.customRows, defaultValue: 2);
|
||||||
// 读取app端缓存内容
|
|
||||||
// if (recVideo.get('cacheList') != null &&
|
|
||||||
// recVideo.get('cacheList').isNotEmpty) {
|
|
||||||
// List<RecVideoItemAppModel> list = [];
|
|
||||||
// for (var i in recVideo.get('cacheList')) {
|
|
||||||
// list.add(i);
|
|
||||||
// }
|
|
||||||
// videoList.value = list;
|
|
||||||
// }
|
|
||||||
enableSaveLastData =
|
enableSaveLastData =
|
||||||
setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
|
setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
|
||||||
defaultRcmdType =
|
defaultRcmdType =
|
||||||
@ -77,7 +67,6 @@ class RcmdController extends GetxController {
|
|||||||
} else if (type == 'onLoad') {
|
} else if (type == 'onLoad') {
|
||||||
appVideoList.addAll(res['data']);
|
appVideoList.addAll(res['data']);
|
||||||
}
|
}
|
||||||
recVideo.put('cacheList', res['data']);
|
|
||||||
_currentPage += 1;
|
_currentPage += 1;
|
||||||
}
|
}
|
||||||
isLoadingMore = false;
|
isLoadingMore = false;
|
||||||
|
|||||||
@ -3,13 +3,11 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:path_provider/path_provider.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/model_owner.dart';
|
||||||
import 'package:pilipala/models/search/hot.dart';
|
import 'package:pilipala/models/search/hot.dart';
|
||||||
import 'package:pilipala/models/user/info.dart';
|
import 'package:pilipala/models/user/info.dart';
|
||||||
|
|
||||||
class GStrorage {
|
class GStrorage {
|
||||||
static late final Box<dynamic> recVideo;
|
|
||||||
static late final Box<dynamic> userInfo;
|
static late final Box<dynamic> userInfo;
|
||||||
static late final Box<dynamic> historyword;
|
static late final Box<dynamic> historyword;
|
||||||
static late final Box<dynamic> localCache;
|
static late final Box<dynamic> localCache;
|
||||||
@ -21,13 +19,6 @@ class GStrorage {
|
|||||||
final String path = dir.path;
|
final String path = dir.path;
|
||||||
await Hive.initFlutter('$path/hive');
|
await Hive.initFlutter('$path/hive');
|
||||||
regAdapter();
|
regAdapter();
|
||||||
// 首页推荐视频
|
|
||||||
recVideo = await Hive.openBox(
|
|
||||||
'recVideo',
|
|
||||||
compactionStrategy: (int entries, int deletedEntries) {
|
|
||||||
return deletedEntries > 12;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// 登录用户信息
|
// 登录用户信息
|
||||||
userInfo = await Hive.openBox(
|
userInfo = await Hive.openBox(
|
||||||
'userInfo',
|
'userInfo',
|
||||||
@ -54,10 +45,6 @@ class GStrorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void regAdapter() {
|
static void regAdapter() {
|
||||||
Hive.registerAdapter(RecVideoItemAppModelAdapter());
|
|
||||||
Hive.registerAdapter(RcmdReasonAdapter());
|
|
||||||
Hive.registerAdapter(RcmdStatAdapter());
|
|
||||||
Hive.registerAdapter(RcmdOwnerAdapter());
|
|
||||||
Hive.registerAdapter(OwnerAdapter());
|
Hive.registerAdapter(OwnerAdapter());
|
||||||
Hive.registerAdapter(UserInfoDataAdapter());
|
Hive.registerAdapter(UserInfoDataAdapter());
|
||||||
Hive.registerAdapter(LevelInfoAdapter());
|
Hive.registerAdapter(LevelInfoAdapter());
|
||||||
@ -73,8 +60,6 @@ class GStrorage {
|
|||||||
static Future<void> close() async {
|
static Future<void> close() async {
|
||||||
// user.compact();
|
// user.compact();
|
||||||
// user.close();
|
// user.close();
|
||||||
recVideo.compact();
|
|
||||||
recVideo.close();
|
|
||||||
userInfo.compact();
|
userInfo.compact();
|
||||||
userInfo.close();
|
userInfo.close();
|
||||||
historyword.compact();
|
historyword.compact();
|
||||||
|
|||||||
Reference in New Issue
Block a user