v1.0.72 #84

Merged
timi merged 7 commits from dev into master 2026-11-17 03:55:13 +00:00
Showing only changes of commit 8c0845d610 - Show all commits
@@ -45,6 +45,9 @@ public class AppVersionService {
/// 更新日志最多返回的版本条数
public static final int MAX_NOTES = 20;
/// 已是最新时展示的版本条数
public static final int TAIL_NOTES = 3;
/// 灰度基数
private static final long GRAY_BASE = 10000L;
@@ -82,12 +85,15 @@ public class AppVersionService {
/// 查询更新日志
///
/// 区间上界取通道当前版本,不再走灰度与兼容区间判断。
/// 区间上界取通道当前版本,不走灰度与兼容区间判断。
/// 原因:客户端拿不到原生 versionCode,也无法保证命中灰度分桶,套用检查更新的判定会让日志
/// 大面积为空。日志是「这个产品最近发了什么」,不是「你这台设备能装什么」,分发决策仍由 check 负责
///
/// 有更新时返回 (当前版本, 通道版本] 区间;已是最新时区间为空,改为返回最近 TAIL_NOTES 个版本,
/// 否则更新完就看不到任何说明
///
/// @param req 插件上报信息
/// @return 当前版本到通道当前版本之间的变更说明
/// @return 变更说明,按版本号从新到旧
public AppUpdateNotesResponse notes(AppUpdateCheckRequest req) {
String currentVersion = currentVersion(req);
AppProduct product = resolveProduct(req);
@@ -99,20 +105,27 @@ public class AppVersionService {
if (target == null || target.getKind() == AppRelease.Kind.NATIVE) {
return new AppUpdateNotesResponse(null, Collections.emptyList());
}
// 当前版本不低于通道版本:已是最新,或回滚后反而超前
boolean upToDate = 0 <= compareVersion(currentVersion, target.getVersionName());
List<AppUpdateNote> notes = new ArrayList<>();
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
// 只取比当前版本新、且不比目标版本新的记录
if (0 >= compareVersion(item.getVersionName(), currentVersion)) {
if (isMeaninglessNote(item.getNote())) {
continue;
}
// 上界恒定:不展示比通道版本更新的记录
if (0 < compareVersion(item.getVersionName(), target.getVersionName())) {
continue;
}
// 有更新时才设下界,已是最新则不限
if (!upToDate && 0 >= compareVersion(item.getVersionName(), currentVersion)) {
continue;
}
notes.add(new AppUpdateNote(item.getVersionName(), item.getNote(), item.getPublishedAt()));
}
// 按版本号倒序,最新的在最前
notes.sort((a, b) -> compareVersion(b.getVersion(), a.getVersion()));
List<AppUpdateNote> limited = MAX_NOTES < notes.size() ? notes.subList(0, MAX_NOTES) : notes;
int limit = upToDate ? TAIL_NOTES : MAX_NOTES;
List<AppUpdateNote> limited = limit < notes.size() ? notes.subList(0, limit) : notes;
return new AppUpdateNotesResponse(target.getVersionName(), limited);
}
@@ -159,6 +172,16 @@ public class AppVersionService {
return release;
}
/// 判断变更说明是否没有展示价值
///
/// 早期发布记录由 CI 写入构建号,对用户没有意义,日志与检查更新都跳过
///
/// @param note 变更说明
/// @return true 为不展示
private boolean isMeaninglessNote(String note) {
return TimiJava.isEmpty(note) || note.startsWith("CI 构建 ");
}
/// 原生包是否需要更新
///
/// @param release 通道当前发布记录