logo和名称替换
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:hgmj/hj_utils/const.dart';
|
||||
import 'package:wydj/hj_utils/const.dart';
|
||||
|
||||
//亚模块模型
|
||||
class ModuleData {
|
||||
@@ -41,6 +41,7 @@ class ModuleData {
|
||||
bool get isACG => type == 4 || type == 5 || type == 6;
|
||||
//短剧
|
||||
bool get isDrama => type == 12;
|
||||
|
||||
/// 展示用的排序项:top=true 的置顶,最多 4 个。
|
||||
/// 标题、sort 值、随机刷新配置一律从这份派生——分头各排一次,遇到同名/同值 remove 会删错元素,两边就对不上了。
|
||||
/// haiJiaoStyle 解析完就不再变,算一次存起来,别每个 getter 各构造一遍
|
||||
@@ -53,10 +54,13 @@ class ModuleData {
|
||||
|
||||
/// 排序 tab(标题 + sort 值),为空返回 null 让调用方退回默认值。
|
||||
/// 标题和 sort 值必须一起产出:拆成两个并行数组时,后端只下发其中一个就会静默错位
|
||||
List<SortTab<int>>? get sortTabs => _sortedRules.isEmpty ? null : _sortedRules.map((e) => SortTab(e.name ?? '', e.val ?? -1)).toList();
|
||||
List<SortTab<int>>? get sortTabs => _sortedRules.isEmpty
|
||||
? null
|
||||
: _sortedRules.map((e) => SortTab(e.name ?? '', e.val ?? -1)).toList();
|
||||
|
||||
/// 按 sort 值取对应的排序规则(用于判断该排序项是否走随机刷新接口)
|
||||
SortRuleModel? sortRuleOf(int? val) => _sortedRules.firstWhereOrNull((e) => e.val == val);
|
||||
SortRuleModel? sortRuleOf(int? val) =>
|
||||
_sortedRules.firstWhereOrNull((e) => e.val == val);
|
||||
}
|
||||
|
||||
class HaiJiaoStyle {
|
||||
@@ -73,7 +77,8 @@ class HaiJiaoStyle {
|
||||
showChosenVideo = json['showChosenVideo'];
|
||||
sortShow = json['sortShow'];
|
||||
final rules = json['sortRules'];
|
||||
if (rules is List) sortRules = rules.map((e) => SortRuleModel.fromJson(e)).toList();
|
||||
if (rules is List)
|
||||
sortRules = rules.map((e) => SortRuleModel.fromJson(e)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,5 +134,8 @@ class HomePlateModel {
|
||||
}
|
||||
|
||||
//字段缺失或类型不对(后端偶发下发非数组)都退化成空列表,别让首页解析整个抛掉
|
||||
static List<ModuleData> _modules(dynamic list) => (list is List ? list : const []).map((e) => ModuleData.fromJson(e)).toList();
|
||||
static List<ModuleData> _modules(dynamic list) =>
|
||||
(list is List ? list : const [])
|
||||
.map((e) => ModuleData.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:hgmj/hj_model/home/module_detail_model.dart';
|
||||
import 'package:hgmj/hj_model/video_model.dart';
|
||||
import 'package:wydj/hj_model/home/module_detail_model.dart';
|
||||
import 'package:wydj/hj_model/video_model.dart';
|
||||
|
||||
//注意⚠️ VideoListResp 只用于兼容不同业务服务端返回的视频列表 key 不一致的情况
|
||||
//注意⚠️ 请勿添加其他类型的数据list,如需添加请单独另外创建新的类
|
||||
@@ -15,14 +15,24 @@ class VideoListResp {
|
||||
json ??= {};
|
||||
hasNext = json['hasNext'];
|
||||
//各业务的视频列表 key 不一样,逐个匹配(后命中的覆盖先命中的)
|
||||
for (final key in ['videos', 'vInfos', 'searchVideo', 'list', 'data', 'searchTag']) {
|
||||
for (final key in [
|
||||
'videos',
|
||||
'vInfos',
|
||||
'searchVideo',
|
||||
'list',
|
||||
'data',
|
||||
'searchTag'
|
||||
]) {
|
||||
if (json[key] is List) {
|
||||
videos = (json[key] as List).map((e) => VideoModel.fromJson(e)).toList();
|
||||
videos =
|
||||
(json[key] as List).map((e) => VideoModel.fromJson(e)).toList();
|
||||
}
|
||||
}
|
||||
tagID = json['tagID'] ?? json['libraryTag']?['id'];
|
||||
if (json['tagVidList'] is List) {
|
||||
tagVidList = (json['tagVidList'] as List).map((e) => VideoModel.fromJson(e)).toList();
|
||||
tagVidList = (json['tagVidList'] as List)
|
||||
.map((e) => VideoModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,4 +51,3 @@ class SectionListResp {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user