fix: H5热更新缓存击穿+版本比对修复

- fetch URL 加 ?t=Date.now() 缓存击穿
- 版本比对兼容 v0.1.0 vs 0.1.0-dav 前缀差异
This commit is contained in:
LukeMackin
2026-07-21 15:26:17 +08:00
parent 8f04acaf98
commit 6f8b346e73

View File

@@ -23,11 +23,11 @@ function log(m){document.getElementById('log').innerText+=m+'\n'}
function checkUpdate(){
log('checking '+BASE+'/version.txt ...');
fetch(BASE+'/version.txt',{cache:'no-store'})
fetch(BASE+'/version.txt?t='+Date.now(),{cache:'no-store'})
.then(r=>{if(!r.ok)throw Error('HTTP '+r.status);return r.text()})
.then(t=>{t=t.trim();log('remote: '+t);
var local=document.getElementById('ver').innerText;
if(t!==local){dlVer=t;dlUrl=BASE+'/h5/index-v7.html';
if(t!==local&&t!=='v'+local&&'v'+t!==local){dlVer=t;dlUrl=BASE+'/h5/index-v7.html';
log('*** NEW VERSION: '+dlVer+' ***');document.getElementById('btnApply').disabled=false}
else log('up to date')})
.catch(e=>log('ERR: '+e.message))