feat: 热更新v5→v6 — 新增渠道选择Stable/Beta/Nightly
This commit is contained in:
@@ -3,44 +3,61 @@
|
|||||||
<style>
|
<style>
|
||||||
body{font-family:monospace;background:#0f172a;color:#e2e8f0;padding:16px;margin:0}
|
body{font-family:monospace;background:#0f172a;color:#e2e8f0;padding:16px;margin:0}
|
||||||
h1{font-size:18px;color:#38bdf8}
|
h1{font-size:18px;color:#38bdf8}
|
||||||
|
.chip{display:inline-block;padding:8px 16px;margin:4px;border-radius:6px;font-size:13px;cursor:pointer;border:1px solid #334155}
|
||||||
|
.chip-on{background:#1e40af;color:#fff;border-color:#3b82f6}
|
||||||
|
.chip-off{background:#1e293b;color:#94a3b8}
|
||||||
.btn{display:block;width:100%;padding:14px;margin:8px 0;border:none;border-radius:8px;font-size:16px;cursor:pointer}
|
.btn{display:block;width:100%;padding:14px;margin:8px 0;border:none;border-radius:8px;font-size:16px;cursor:pointer}
|
||||||
.btn-check{background:#1e40af;color:#fff}
|
.btn-check{background:#1e40af;color:#fff}
|
||||||
.btn-download{background:#15803d;color:#fff}
|
.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}
|
.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}
|
.info{color:#94a3b8;font-size:12px;margin:4px 0}
|
||||||
.badge{display:inline-block;background:#15803d;color:#fff;padding:2px 8px;border-radius:4px;font-size:11px;margin-left:8px}
|
.badge{display:inline-block;background:#22c55e;color:#000;padding:2px 8px;border-radius:4px;font-size:11px;margin-left:8px}
|
||||||
</style></head><body>
|
</style></head><body>
|
||||||
<h1>Yuzu GCA <span class="badge">HOT UPDATED</span></h1>
|
<h1>Yuzu GCA <span class="badge">v6</span></h1>
|
||||||
<div class="info">version <span id="ver">0.1.0-dav-android-6</span></div>
|
<div class="info">version <span id="ver">0.1.0-dav-android-6</span></div>
|
||||||
|
|
||||||
|
<div style="margin:12px 0">
|
||||||
|
<span id="ch-stable" class="chip chip-on" onclick="selectCh('stable')">Stable</span>
|
||||||
|
<span id="ch-beta" class="chip chip-off" onclick="selectCh('beta')">Beta</span>
|
||||||
|
<span id="ch-nightly" class="chip chip-off" onclick="selectCh('nightly')">Nightly</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-check" onclick="checkUpdate()">检查更新</button>
|
<button class="btn btn-check" onclick="checkUpdate()">检查更新</button>
|
||||||
<button class="btn btn-download" onclick="applyUpdate()" id="btnApply" disabled>下载更新</button>
|
<button class="btn btn-download" onclick="applyUpdate()" id="btnApply" disabled>下载更新</button>
|
||||||
<div class="log" id="log"></div>
|
<div class="log" id="log"></div>
|
||||||
<script>
|
<script>
|
||||||
var dlUrl='',dlVer='';
|
var dlUrl='',dlVer='',channel='stable';
|
||||||
|
var BASE='https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota';
|
||||||
|
|
||||||
|
function selectCh(ch){
|
||||||
|
channel=ch;
|
||||||
|
document.querySelectorAll('.chip').forEach(c=>c.className='chip chip-off');
|
||||||
|
document.getElementById('ch-'+ch).className='chip chip-on';
|
||||||
|
log('channel → '+ch)
|
||||||
|
}
|
||||||
|
|
||||||
function log(m){document.getElementById('log').innerText+=m+'\n'}
|
function log(m){document.getElementById('log').innerText+=m+'\n'}
|
||||||
|
|
||||||
function checkUpdate(){
|
function checkUpdate(){
|
||||||
log('正在检查...');
|
var url=BASE+'/version.txt?t='+Date.now();
|
||||||
fetch('https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/version.txt')
|
if(channel!=='stable') url=BASE+'/version-'+channel+'.txt?t='+Date.now();
|
||||||
.then(r=>{if(!r.ok)throw Error('网络错误');return r.text()})
|
log('checking '+url+' ...');
|
||||||
.then(t=>{t=t.trim();log('远程: '+t);
|
fetch(url,{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;
|
var local=document.getElementById('ver').innerText;
|
||||||
if(t!==local){dlVer=t;dlUrl='https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html';
|
if(t!==local&&t!=='v'+local&&'v'+t!==local){dlVer=t;dlUrl=BASE+'/h5/index-v7.html';
|
||||||
log('🆕 有新版本!');document.getElementById('btnApply').disabled=false}
|
log('*** NEW VERSION ***');document.getElementById('btnApply').disabled=false}
|
||||||
else log('✅ 已是最新')})
|
else log('up to date')})
|
||||||
.catch(e=>log('❌ 失败: '+e.message))
|
.catch(e=>log('ERR: '+e.message))
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyUpdate(){
|
function applyUpdate(){
|
||||||
log('下载中...');
|
log('downloading...');
|
||||||
fetch(dlUrl).then(r=>{if(!r.ok)throw Error('下载失败 '+r.status);return r.text()})
|
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);
|
.then(t=>{localStorage.setItem('gca_html',t);localStorage.setItem('gca_ver',dlVer);
|
||||||
log('✅ 下载完成,正在刷新...');setTimeout(function(){location.reload()},500)})
|
log('OK reloading...');setTimeout(function(){location.reload()},300)})
|
||||||
.catch(e=>log('❌ 失败: '+e.message))
|
.catch(e=>log('ERR: '+e.message))
|
||||||
}
|
|
||||||
window.onload=function(){
|
|
||||||
var b=localStorage.getItem('gca_html'),v=localStorage.getItem('gca_ver');
|
|
||||||
if(b&&v){
|
|
||||||
document.getElementById('ver').innerText=v;
|
|
||||||
document.write(b);document.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script></body></html>
|
</script></body></html>
|
||||||
|
|||||||
Reference in New Issue
Block a user