更新界面

This commit is contained in:
HapeLee committed 2025-07-11 02:36:16 +08:00
1 parent b007a81277
commit 329cdac774
7 files changed
+212 -82

No files matched your search

@@ -13,7 +13,7 @@ data class AppReleaseInfo(
val downloadUrl: String,
val assetUrl: String
) {
val versionName: String = Regex("""legado_app_([\d.]+)""")
val versionName: String = Regex("""legado_app_([\d.]+)\.apk""")
.find(name)
?.groupValues?.get(1)
?: ""
@@ -48,22 +48,27 @@ object AppUpdateGitHub : AppUpdate.AppUpdateInterface {
.sortedByDescending { it.createdAt }
}
override fun check(
scope: CoroutineScope,
): Coroutine<AppUpdate.UpdateInfo> {
override fun check(scope: CoroutineScope): Coroutine<AppUpdate.UpdateInfo> {
return Coroutine.async(scope) {
getLatestRelease()
val currentVersion = AppConst.appInfo.versionName
val releases = getLatestRelease()
.filter { it.appVariant == checkVariant }
.firstOrNull { it.versionName > AppConst.appInfo.versionName }
?.let {
return@async AppUpdate.UpdateInfo(
it.versionName,
it.note,
it.downloadUrl,
it.name
)
}
?: throw NoStackTraceException("已是最新版本")
val latest = releases
.firstOrNull { it.versionName > currentVersion }
if (latest != null) {
return@async AppUpdate.UpdateInfo(
latest.versionName,
latest.note,
latest.downloadUrl,
latest.name
)
}
throw NoStackTraceException("已是最新版本")
}.timeout(10000)
}
}