fix: 删掉重复定义的旧 checkUpdate
旧版读 \upSrc.value,那个元素早就删了,null.value 抛 TypeError, 点「检查更新」什么都不发生(旧定义覆盖了新定义)。
This commit is contained in:
1 parent
cbd36445f0
commit
a2f4984ef7
1 file changed
+1
-57
@@ -1334,61 +1334,6 @@ async function updateMaster(){
|
||||
ticker('曲库已更新:' + r.new + ' 首' + (r.added > 0 ? '(新增 ' + r.added + ')' : ''), 'ok');
|
||||
}
|
||||
|
||||
const GH_KEY = 'maipulse.ghrepo';
|
||||
const GHT_KEY = 'maipulse.ghtoken';
|
||||
|
||||
async function checkGh(){
|
||||
const repo = ($('ghRepo').value || '').trim();
|
||||
const token = ($('ghToken').value || '').trim();
|
||||
if(!repo) return ticker('先填 owner/name', 'err');
|
||||
try{ localStorage.setItem(GH_KEY, repo); if(token) localStorage.setItem(GHT_KEY, token); }catch(e){}
|
||||
const out = $('upOut');
|
||||
out.textContent = '正在问 GitHub…';
|
||||
let q = '/api/update-gh?repo=' + encodeURIComponent(repo);
|
||||
if(token) q += '&token=' + encodeURIComponent(token);
|
||||
const r = await get(q);
|
||||
if(!r.ok){ out.textContent = r.error; return; }
|
||||
if(r.newer){
|
||||
let act = '';
|
||||
if(r.url){
|
||||
if(window.Maipulse && window.Maipulse.installApk){
|
||||
act = '<br><button class="ghost" onclick="Maipulse.installApk(\'' + r.url + '\')">立即下载并安装</button>';
|
||||
}else{
|
||||
act = '<br><a href="' + r.url + '" target="_blank">点这里下载</a>';
|
||||
}
|
||||
}
|
||||
out.innerHTML = '<b style="color:#c0392b">GitHub 上有新版本 ' + r.remote + '</b>(当前 ' + r.current + ')'
|
||||
+ (r.notes ? '<br>' + r.notes.slice(0, 300) : '') + act;
|
||||
}else{
|
||||
out.innerHTML = 'GitHub 上已经是最新的(' + r.current + ',远端 ' + r.remote + ')';
|
||||
}
|
||||
}
|
||||
|
||||
async function checkUpdate(){
|
||||
const src = ($('upSrc').value || '').trim();
|
||||
if(!src) return ticker('先填更新源地址', 'err');
|
||||
try{ localStorage.setItem(UP_SRC_KEY, src); }catch(e){}
|
||||
const out = $('upOut');
|
||||
out.textContent = '正在检查…';
|
||||
const r = await get('/api/update-check?source=' + encodeURIComponent(src));
|
||||
if(!r.ok){ out.textContent = r.error; return; }
|
||||
if(r.newer){
|
||||
let act = '';
|
||||
if(r.url){
|
||||
// Android 壳里直接走系统下载器 + 安装器;网页版给个普通链接
|
||||
if(window.Maipulse && window.Maipulse.installApk){
|
||||
act = '<br><button class="ghost" onclick="Maipulse.installApk(\'' + r.url + '\')">立即下载并安装</button>';
|
||||
}else{
|
||||
act = '<br><a href="' + r.url + '" target="_blank">点这里下载</a>';
|
||||
}
|
||||
}
|
||||
out.innerHTML = '<b style="color:#c0392b">有新版本 ' + r.remote + '</b>(当前 ' + r.current + ')'
|
||||
+ (r.notes ? '<br>' + r.notes : '') + act;
|
||||
}else{
|
||||
out.innerHTML = '已经是最新的(' + r.current + ',远端 ' + r.remote + ')';
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 旅行伙伴 ---------- */
|
||||
let charPicked = [];
|
||||
async function loadCharacters(){
|
||||
@@ -1970,7 +1915,6 @@ log('就绪。先扫码 → 登录 → 选功能。', 'dim');
|
||||
applyLook();
|
||||
loadVersion();
|
||||
confSummary();
|
||||
try{ const _u = localStorage.getItem(UP_SRC_KEY); if(_u && $('upSrc')) $('upSrc').value = _u; const _g = localStorage.getItem(GH_KEY); if(_g && $('ghRepo')) $('ghRepo').value = _g; const _t = localStorage.getItem(GHT_KEY); if(_t && $('ghToken')) $('ghToken').value = _t; }catch(e){}
|
||||
loadAccounts();
|
||||
// URL 带 ?uid= 时自动查这个账号的 B50 与推分(方便直接看别人的分)
|
||||
const uidParam = new URLSearchParams(location.search).get('uid');
|
||||
@@ -2039,4 +1983,4 @@ if(location.search.indexOf('dbg') >= 0){
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in new issue
Block a user