feat: 热更新架构 — Android Bridge存文件, MainActivity启动时检查缓存
v5: 嵌入式页面(蓝黑主题,简单按钮) v6: 完全不同的页面(紫色渐变,卡片布局,渠道选择器) 通过Android.saveCache存HTML文件,重启App自动加载
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><script>
|
||||
(function(){
|
||||
var b=localStorage.getItem('gca_html');
|
||||
if(b){
|
||||
var blob=new Blob([b],{type:'text/html'});
|
||||
location.replace(URL.createObjectURL(blob));
|
||||
return
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
|
||||
<style>
|
||||
body{font-family:monospace;background:#0f172a;color:#e2e8f0;padding:16px;margin:0}
|
||||
h1{font-size:18px;color:#38bdf8}
|
||||
@@ -17,7 +8,6 @@ h1{font-size:18px;color:#38bdf8}
|
||||
.btn-download{background:#15803d;color:#fff}
|
||||
.log{background:#1e293b;padding:12px;border-radius:8px;margin-top:12px;max-height:300px;overflow-y:auto;font-size:12px;white-space:pre-wrap}
|
||||
.info{color:#94a3b8;font-size:12px;margin:4px 0}
|
||||
.badge{display:inline-block;background:#22c55e;color:#000;padding:2px 8px;border-radius:4px;font-size:11px;margin-left:8px}
|
||||
</style></head><body>
|
||||
<h1>Yuzu GCA</h1>
|
||||
<div class="info">version <span id="ver">v0.1.0-dav-android-5</span></div>
|
||||
@@ -44,8 +34,8 @@ function applyUpdate(){
|
||||
log('downloading...');
|
||||
fetch(dlUrl+'?t='+Date.now(),{cache:'no-store'})
|
||||
.then(r=>{if(!r.ok)throw Error('HTTP '+r.status);return r.text()})
|
||||
.then(t=>{localStorage.setItem('gca_html',t);localStorage.setItem('gca_ver',dlVer);
|
||||
log('OK reloading...');setTimeout(function(){location.reload()},300)})
|
||||
.then(t=>{Android.saveCache(t);log('OK! restart app to apply');
|
||||
document.getElementById('btnApply').disabled=true})
|
||||
.catch(e=>log('ERR: '+e.message))
|
||||
}
|
||||
</script></body></html>
|
||||
|
||||
Reference in New Issue
Block a user