mod: 补充web端推荐
This commit is contained in:
@ -36,7 +36,7 @@ class RecVideoItemModel {
|
|||||||
@HiveField(6)
|
@HiveField(6)
|
||||||
String? title = '';
|
String? title = '';
|
||||||
@HiveField(7)
|
@HiveField(7)
|
||||||
int? duration = -1;
|
String? duration = '';
|
||||||
@HiveField(8)
|
@HiveField(8)
|
||||||
int? pubdate = -1;
|
int? pubdate = -1;
|
||||||
@HiveField(9)
|
@HiveField(9)
|
||||||
@ -56,7 +56,7 @@ class RecVideoItemModel {
|
|||||||
uri = json["uri"];
|
uri = json["uri"];
|
||||||
pic = json["pic"];
|
pic = json["pic"];
|
||||||
title = json["title"];
|
title = json["title"];
|
||||||
duration = json["duration"];
|
duration = json["duration"].toString();
|
||||||
pubdate = json["pubdate"];
|
pubdate = json["pubdate"];
|
||||||
owner = Owner.fromJson(json["owner"]);
|
owner = Owner.fromJson(json["owner"]);
|
||||||
stat = Stat.fromJson(json["stat"]);
|
stat = Stat.fromJson(json["stat"]);
|
||||||
@ -72,19 +72,19 @@ class Stat {
|
|||||||
Stat({
|
Stat({
|
||||||
this.view,
|
this.view,
|
||||||
this.like,
|
this.like,
|
||||||
this.danmaku,
|
this.danmu,
|
||||||
});
|
});
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
int? view;
|
int? view;
|
||||||
@HiveField(1)
|
@HiveField(1)
|
||||||
int? like;
|
int? like;
|
||||||
@HiveField(2)
|
@HiveField(2)
|
||||||
int? danmaku;
|
int? danmu;
|
||||||
|
|
||||||
Stat.fromJson(Map<String, dynamic> json) {
|
Stat.fromJson(Map<String, dynamic> json) {
|
||||||
view = json["view"];
|
view = json["view"];
|
||||||
like = json["like"];
|
like = json["like"];
|
||||||
danmaku = json['danmaku'];
|
danmu = json['danmaku'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class RecVideoItemModelAdapter extends TypeAdapter<RecVideoItemModel> {
|
|||||||
uri: fields[4] as String?,
|
uri: fields[4] as String?,
|
||||||
pic: fields[5] as String?,
|
pic: fields[5] as String?,
|
||||||
title: fields[6] as String?,
|
title: fields[6] as String?,
|
||||||
duration: fields[7] as int?,
|
duration: fields[7] as String?,
|
||||||
pubdate: fields[8] as int?,
|
pubdate: fields[8] as int?,
|
||||||
owner: fields[9] as Owner?,
|
owner: fields[9] as Owner?,
|
||||||
stat: fields[10] as Stat?,
|
stat: fields[10] as Stat?,
|
||||||
@ -89,7 +89,7 @@ class StatAdapter extends TypeAdapter<Stat> {
|
|||||||
return Stat(
|
return Stat(
|
||||||
view: fields[0] as int?,
|
view: fields[0] as int?,
|
||||||
like: fields[1] as int?,
|
like: fields[1] as int?,
|
||||||
danmaku: fields[2] as int?,
|
danmu: fields[2] as int?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class StatAdapter extends TypeAdapter<Stat> {
|
|||||||
..writeByte(1)
|
..writeByte(1)
|
||||||
..write(obj.like)
|
..write(obj.like)
|
||||||
..writeByte(2)
|
..writeByte(2)
|
||||||
..write(obj.danmaku);
|
..write(obj.danmu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -3,12 +3,14 @@ import 'package:get/get.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/video.dart';
|
import 'package:pilipala/http/video.dart';
|
||||||
import 'package:pilipala/models/home/rcmd/result.dart';
|
import 'package:pilipala/models/home/rcmd/result.dart';
|
||||||
|
// import 'package:pilipala/models/model_rec_video_item.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
class RcmdController extends GetxController {
|
class RcmdController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
int _currentPage = 0;
|
int _currentPage = 0;
|
||||||
RxList<RecVideoItemAppModel> videoList = <RecVideoItemAppModel>[].obs;
|
RxList<RecVideoItemAppModel> videoList = <RecVideoItemAppModel>[].obs;
|
||||||
|
// RxList<RecVideoItemModel> videoList = <RecVideoItemModel>[].obs;
|
||||||
bool isLoadingMore = true;
|
bool isLoadingMore = true;
|
||||||
OverlayEntry? popupDialog;
|
OverlayEntry? popupDialog;
|
||||||
Box recVideo = GStrorage.recVideo;
|
Box recVideo = GStrorage.recVideo;
|
||||||
@ -21,6 +23,7 @@ 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 &&
|
if (recVideo.get('cacheList') != null &&
|
||||||
recVideo.get('cacheList').isNotEmpty) {
|
recVideo.get('cacheList').isNotEmpty) {
|
||||||
List<RecVideoItemAppModel> list = [];
|
List<RecVideoItemAppModel> list = [];
|
||||||
@ -35,6 +38,11 @@ class RcmdController extends GetxController {
|
|||||||
|
|
||||||
// 获取推荐
|
// 获取推荐
|
||||||
Future queryRcmdFeed(type) async {
|
Future queryRcmdFeed(type) async {
|
||||||
|
return await queryRcmdFeedApp(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取app端推荐
|
||||||
|
Future queryRcmdFeedApp(type) async {
|
||||||
if (isLoadingMore == false) {
|
if (isLoadingMore == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,6 +75,40 @@ class RcmdController extends GetxController {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取web端推荐
|
||||||
|
Future queryRcmdFeedWeb(type) async {
|
||||||
|
if (isLoadingMore == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type == 'onRefresh') {
|
||||||
|
_currentPage = 0;
|
||||||
|
}
|
||||||
|
var res = await VideoHttp.rcmdVideoList(
|
||||||
|
ps: 20,
|
||||||
|
freshIdx: _currentPage,
|
||||||
|
);
|
||||||
|
if (res['status']) {
|
||||||
|
if (type == 'init') {
|
||||||
|
if (videoList.isNotEmpty) {
|
||||||
|
videoList.addAll(res['data']);
|
||||||
|
} else {
|
||||||
|
videoList.value = res['data'];
|
||||||
|
}
|
||||||
|
} else if (type == 'onRefresh') {
|
||||||
|
if (enableSaveLastData) {
|
||||||
|
videoList.insertAll(0, res['data']);
|
||||||
|
} else {
|
||||||
|
videoList.value = res['data'];
|
||||||
|
}
|
||||||
|
} else if (type == 'onLoad') {
|
||||||
|
videoList.addAll(res['data']);
|
||||||
|
}
|
||||||
|
_currentPage += 1;
|
||||||
|
}
|
||||||
|
isLoadingMore = false;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
Future onRefresh() async {
|
Future onRefresh() async {
|
||||||
isLoadingMore = true;
|
isLoadingMore = true;
|
||||||
|
Reference in New Issue
Block a user