fix: H5缓存命中时替换body内容而非仅显示徽章
- 使用createHTMLDocument解析缓存HTML - innerHTML替换body以显示完整热更新页面(含渠道选择器等)
This commit is contained in:
@@ -45,10 +45,10 @@ function applyUpdate(){
|
|||||||
(function(){
|
(function(){
|
||||||
var b=localStorage.getItem('gca_html'),v=localStorage.getItem('gca_ver');
|
var b=localStorage.getItem('gca_html'),v=localStorage.getItem('gca_ver');
|
||||||
if(b&&v&&v!==document.getElementById('ver').innerText){
|
if(b&&v&&v!==document.getElementById('ver').innerText){
|
||||||
// Show badge but don't rewrite page (avoids double-render)
|
var d=document.implementation.createHTMLDocument();
|
||||||
var el=document.createElement('span');el.className='badge';el.style.cssText='background:#22c55e;color:#000';
|
d.documentElement.innerHTML=b;
|
||||||
el.innerText='CACHED v'+v.replace('0.1.0-dav-android-','');document.querySelector('h1').appendChild(el);
|
var newBody=d.body.innerHTML;
|
||||||
document.getElementById('ver').innerText=v
|
if(newBody){document.body.innerHTML=newBody;document.title=d.title}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script></body></html>
|
</script></body></html>
|
||||||
|
|||||||
Reference in New Issue
Block a user