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