logo和名称替换

This commit is contained in:
谢宇宁
2026-10-14 11:23:36 +07:00
parent 1cb514cd02
commit c5c04a7967
478 changed files with 8990 additions and 4948 deletions
+27 -16
View File
@@ -1,13 +1,13 @@
import 'dart:convert';
import 'package:hgmj/config/address.dart';
import 'package:hgmj/hj_model/home/module_detail_model.dart';
import 'package:hgmj/hj_model/splash/ads_model.dart';
import 'package:hgmj/hj_model/user/user_info_model.dart';
import 'package:hgmj/hj_model/video_model.dart';
import 'package:hgmj/hj_utils/light_model.dart';
import 'package:hgmj/hj_utils/store_keys.dart';
import 'package:hgmj/hj_utils/text_util.dart';
import 'package:wydj/config/address.dart';
import 'package:wydj/hj_model/home/module_detail_model.dart';
import 'package:wydj/hj_model/splash/ads_model.dart';
import 'package:wydj/hj_model/user/user_info_model.dart';
import 'package:wydj/hj_model/video_model.dart';
import 'package:wydj/hj_utils/light_model.dart';
import 'package:wydj/hj_utils/store_keys.dart';
import 'package:wydj/hj_utils/text_util.dart';
import 'package:path/path.dart' as path;
/// 广告总管:广告数据(内存+本地缓存)、免广告策略、列表插广告
@@ -29,12 +29,14 @@ class AdManager {
}
/// 按 [position] 同步取广告,走内存缓存
List<AdsInfoModel> adsByType(int? position) => _filterByPosition(_adsList, position);
List<AdsInfoModel> adsByType(int? position) =>
_filterByPosition(_adsList, position);
/// 按 [position] 异步取上次展示的广告,直接读磁盘(不走/不写内存缓存,splash 启动早期用)
Future<List<AdsInfoModel>> lastAdsByType(int? position) async {
if (position == null) return const [];
return _filterByPosition(_decodeAds(await lightKV.getString(StoreKeys.ADS_LIST)), position);
return _filterByPosition(
_decodeAds(await lightKV.getString(StoreKeys.ADS_LIST)), position);
}
/// 保存服务端下发的广告:cover 补全成完整地址后刷内存、写磁盘
@@ -42,7 +44,9 @@ class AdManager {
for (final model in ads ?? const <AdsInfoModel>[]) {
final cover = model.cover;
// 完整链接只取 path 拼当前图片域名,相对路径直接拼
final subPath = cover?.startsWith('http') == true ? Uri.tryParse(cover!)?.path : cover;
final subPath = cover?.startsWith('http') == true
? Uri.tryParse(cover!)?.path
: cover;
model.cover = path.join(Address.baseImagePath ?? '', subPath);
}
_adsList = ads;
@@ -58,7 +62,9 @@ class AdManager {
List<AdsInfoModel>? _decodeAds(String? jsonStr) {
if (TextUtil.isEmpty(jsonStr)) return null;
try {
return (jsonDecode(jsonStr!) as List?)?.map((o) => AdsInfoModel.fromMap(o)).toList();
return (jsonDecode(jsonStr!) as List?)
?.map((o) => AdsInfoModel.fromMap(o))
.toList();
} catch (_) {
return null;
}
@@ -91,14 +97,17 @@ class AdManager {
// 注册时刻起算 type 分钟:注册时间是固定的绝对时刻,重进 app 既不会续期也不会丢剩余时长
// createdAt 是 UTC 串,缺时区标记时补 Z 再解析,否则会被当成本地时间差出时区偏移
final raw = userInfo?.createdAt ?? '';
final registeredAt = DateTime.tryParse(raw.endsWith('Z') || raw.contains('+') ? raw : '${raw}Z')?.toLocal();
final registeredAt = DateTime.tryParse(
raw.endsWith('Z') || raw.contains('+') ? raw : '${raw}Z')
?.toLocal();
_adFreeUntil = registeredAt?.add(Duration(minutes: type));
}
}
/// 专题列表插入广告:每隔 [adGap] 条普通内容插一条广告位
/// [modelArr] 原始列表(会被原地修改);[advList] 广告数据;[adGap] 间隔条数
void insertSectionAds(List<AllSection> modelArr, List<AdsInfoModel> advList, {int adGap = 5}) {
void insertSectionAds(List<AllSection> modelArr, List<AdsInfoModel> advList,
{int adGap = 5}) {
if (advList.isEmpty || modelArr.isEmpty || !showAbTestAd) return;
int countGap = 0; // 距上一条广告已累计的普通内容数
modelArr.removeWhere((it) => it.isAdsArr()); // 先清掉旧广告,避免重复插入
@@ -127,7 +136,8 @@ class AdManager {
}
/// 视频流插入「单条随机广告」:每隔 [adGap] 条插一条,广告按 adIndex 轮播取用
void insertRandomAds(List<VideoModel> modelArr, List<AdsInfoModel> advList, {int adGap = 5}) {
void insertRandomAds(List<VideoModel> modelArr, List<AdsInfoModel> advList,
{int adGap = 5}) {
if (advList.isEmpty || modelArr.isEmpty || !showAbTestAd) return;
int countGap = 0; // 距上一条广告已累计的普通内容数
int adIndex = 0; // 当前取到第几条广告,与 advList 取模实现轮播
@@ -158,7 +168,8 @@ class AdManager {
}
/// 视频流插入「整组广告」:每隔 [adGap] 条插一条,广告位携带整个 advList(与 [insertRandomAds] 的单条随机不同)
void insertGroupAds(List<VideoModel> modelArr, List<AdsInfoModel> advList, {int adGap = 5}) {
void insertGroupAds(List<VideoModel> modelArr, List<AdsInfoModel> advList,
{int adGap = 5}) {
if (advList.isEmpty || modelArr.isEmpty || !showAbTestAd) return;
int countGap = 0; // 距上一条广告已累计的普通内容数
modelArr.removeWhere((it) => it.isAdsArr()); // 先清掉旧广告