feat: manifest字段规范化 {latest,min_version,url,sha256} + v6动态版本对比
- h5_version → latest + min_version(老旧客户端提示需APK升级) - v6 HTML: 去掉硬编码版本号,动态读取页面ver元素比对 - TBD sha256 → 直接拒绝(非空占位符) - 域名校验保留
This commit is contained in:
@@ -48,11 +48,16 @@ function checkUpdate(){
|
|||||||
log('checking '+manFile+' ...');
|
log('checking '+manFile+' ...');
|
||||||
fetch(BASE+manFile+'?t='+Date.now(),{cache:'no-store'})
|
fetch(BASE+manFile+'?t='+Date.now(),{cache:'no-store'})
|
||||||
.then(function(r){if(!r.ok)throw Error('HTTP '+r.status);return r.json()})
|
.then(function(r){if(!r.ok)throw Error('HTTP '+r.status);return r.json()})
|
||||||
.then(function(j){log('remote: '+j.h5_version);
|
.then(function(j){log('latest: '+j.latest+' min: '+j.min_version);
|
||||||
dlUrl=j.h5_url;dlSha=j.h5_sha256||'';
|
if(j.min_version){
|
||||||
if(!dlSha){log('ERR: manifest missing h5_sha256');return}
|
var v=j.min_version.replace(/[^0-9]/g,''),my=document.getElementById('ver').innerText.replace(/[^0-9]/g,'');
|
||||||
if(!dlUrl||dlUrl.indexOf(BASE)!==0){log('ERR: invalid h5_url domain');return}
|
if(parseInt(my)<parseInt(v)){log('ERR: too old, need APK update');return}
|
||||||
if(j.h5_version!=='0.1.0-dav-android-6'){dlVer=j.h5_version;
|
}
|
||||||
|
dlUrl=j.url;dlSha=j.sha256||'';
|
||||||
|
if(!dlSha||dlSha.startsWith('TBD')){log('ERR: channel no build');return}
|
||||||
|
if(!dlUrl||dlUrl.indexOf(BASE)!==0){log('ERR: invalid url');return}
|
||||||
|
var myVer=document.getElementById('ver').innerText;
|
||||||
|
if(j.latest!==myVer&&j.latest!=='v'+myVer&&'v'+j.latest!==myVer){dlVer=j.latest;
|
||||||
log('*** NEW VERSION ***');document.getElementById('btnApply').disabled=false}
|
log('*** NEW VERSION ***');document.getElementById('btnApply').disabled=false}
|
||||||
else log('up to date')})
|
else log('up to date')})
|
||||||
.catch(function(e){log('ERR: '+e.message)})
|
.catch(function(e){log('ERR: '+e.message)})
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"h5_version":"0.1.0-dav-android-6","h5_sha256":"779e291531062e916cad5e33ee51d6783a30e9e96babee37ae829b491a354413","h5_url":"https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html"}
|
{"url":"https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html","min_version":"0.1.0-dav-android-5","latest":"0.1.0-dav-android-6","sha256":"64fbae9250866f44ce7ade0fd415632b1e40299ca0606044cf8606996d060213"}
|
||||||
@@ -1 +1 @@
|
|||||||
{"h5_version":"0.1.0-dav-android-7","h5_sha256":"TBD-v7-not-built","h5_url":"https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v7.html"}
|
{"url":"https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v7.html","min_version":"0.1.0-dav-android-5","latest":"0.1.0-dav-android-7","sha256":"TBD-v7-not-built"}
|
||||||
@@ -1 +1 @@
|
|||||||
{"h5_version":"0.1.0-dav-android-6","h5_sha256":"779e291531062e916cad5e33ee51d6783a30e9e96babee37ae829b491a354413","h5_url":"https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html"}
|
{"url":"https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html","min_version":"0.1.0-dav-android-5","latest":"0.1.0-dav-android-6","sha256":"64fbae9250866f44ce7ade0fd415632b1e40299ca0606044cf8606996d060213"}
|
||||||
@@ -1 +1 @@
|
|||||||
0.1.0-dav-android-6|https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html|779e291531062e916cad5e33ee51d6783a30e9e96babee37ae829b491a354413
|
0.1.0-dav-android-6|https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html|64fbae9250866f44ce7ade0fd415632b1e40299ca0606044cf8606996d060213
|
||||||
Reference in New Issue
Block a user