fix: versionCode match失败时跳过(避免curCode=0误报)

This commit is contained in:
LukeMackin
2026-07-22 16:50:59 +08:00
parent e209db6be8
commit a98d35cb1c

View File

@@ -27,7 +27,7 @@ function checkUpdate(){
var j=JSON.parse(Android.fetchManifest(channel));
if(j.error){log('ERR: '+j.error);return}
var h5=j.h5;log('latest: '+h5.latest+' min: '+h5.min_version);
var apk=j.apk;if(apk){var curCode=parseInt((document.getElementById('ver').innerText.match(/(\d+)$/)||[0])[0]);if(apk.versionCode>curCode){log('APK UPDATE: v'+apk.version+' (code '+apk.versionCode+')');document.getElementById('apkLink').innerHTML='<a href=\"'+apk.url+'\">Download APK v'+apk.version+'</a>';document.getElementById('apkLink').style.display='block'}}
var apk=j.apk;if(apk){var m=(document.getElementById('ver').innerText||'').match(/(\d+)$/);if(m){var curCode=parseInt(m[0]);if(apk.versionCode>curCode){log('APK UPDATE:v'+apk.version);document.getElementById('apkLink').innerHTML='<a href=\"'+apk.url+'\">Download APK v'+apk.version+'</a>';document.getElementById('apkLink').style.display='block'}}}
var v=(h5.min_version||'').replace(/[^0-9]/g,''),my=(document.getElementById('ver').innerText||'').replace(/[^0-9]/g,'');
if(parseInt(my||'0')<parseInt(v||'0')){log('ERR: APK too old (need v'+h5.min_version+')');return}
dlUrl=h5.url;dlSha=h5.sha256||'';