mirror of
https://github.com/KarnerF/SMPlusGui.git
synced 2026-10-06 08:00:19 +02:00
Show images directly as games when SM games DB empty; no more retry loop
This commit is contained in:
1 parent
991f419f60
commit
984dc7150e
1 file changed
+30
-9
@@ -1777,16 +1777,37 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
"Promise.all([gp,ip]).then(function(res){"
|
||||
"var gd=res[0],id=res[1];"
|
||||
"if(!gl)return;"
|
||||
"if(!gd||gd.error||gd.status){"
|
||||
"gl.innerHTML='<p class=\"hint\" style=\"color:#f87171;\">SM API nicht erreichbar — l\\u00e4uft ShadowMountPlus?</p>';}"
|
||||
"else if(!gd.games||!gd.games.length){"
|
||||
"if(_gpR<4){"
|
||||
"gl.innerHTML='<p class=\"hint\">Warte auf SM... ('+(_gpR+1)+'/4)</p>';"
|
||||
"setTimeout(function(){loadGamePanel(_gpR+1);},4000);"
|
||||
"var imgs=id&&id.images?id.images:[];"
|
||||
/* if SM games API works and has data, show it; otherwise fall back to images */
|
||||
"if(gd&&!gd.error&&!gd.status&&gd.games&&gd.games.length){"
|
||||
"_gpR=0;renderGamesList(gl,gd.games);"
|
||||
"}else if(imgs.length){"
|
||||
/* SM games DB empty: build game cards directly from the images list */
|
||||
"var h='';"
|
||||
"imgs.forEach(function(img){"
|
||||
"var parts=(img.path||'').split('/');"
|
||||
"var fn=parts.pop()||img.path;"
|
||||
"var mn=img.mounted"
|
||||
"?'<span style=\"color:#10b981;font-size:.75rem;\">● aktiv</span>'"
|
||||
":'<span style=\"color:var(--dim);font-size:.75rem;\">○ inaktiv</span>';"
|
||||
"var ba=img.mounted"
|
||||
"?(img.title_id?'<button onclick=\"unmountGame(\\\''+img.title_id+'\\\')\" style=\"background:transparent;border:1px solid #f87171;border-radius:4px;color:#f87171;padding:3px 10px;cursor:pointer;font-size:.75rem;\">Unmount</button>':'')"
|
||||
":'<button onclick=\"manualMount(\\\''+img.path+'\\\')\" style=\"background:transparent;border:1px solid var(--accent);border-radius:4px;color:var(--accent);padding:3px 10px;cursor:pointer;font-size:.75rem;white-space:nowrap;\">Mount</button>';"
|
||||
"var tid=img.title_id||'';"
|
||||
"h+='<div style=\"display:flex;align-items:center;gap:10px;padding:8px 4px;border-bottom:1px solid var(--border);\">';"
|
||||
"h+=(tid?'<img src=\"/api/game/icon?title_id='+tid+'\" width=\"48\" height=\"48\" style=\"border-radius:8px;object-fit:cover;flex-shrink:0;background:#1e2a42;\" onerror=\"this.style.display=\\'none\\'\">':\"\");"
|
||||
"h+='<div style=\"flex:1;min-width:0;\">';"
|
||||
"h+='<div style=\"font-size:.83rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;\">'+fn+'</div>';"
|
||||
"h+=(tid?'<div style=\"font-family:var(--mono);font-size:.7rem;color:var(--dim);\">'+tid+'</div>':'');"
|
||||
"h+='<div style=\"font-family:var(--mono);font-size:.65rem;color:var(--dim);\">'+img.path+'</div>';"
|
||||
"h+='</div>';"
|
||||
"h+='<div style=\"display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0;\">'+mn+ba+'</div></div>';"
|
||||
"});gl.innerHTML=h;"
|
||||
"}else if(!gd||gd.error||gd.status){"
|
||||
"gl.innerHTML='<p class=\"hint\" style=\"color:#f87171;\">SM API nicht erreichbar</p>';"
|
||||
"}else{"
|
||||
"gl.innerHTML='<p class=\"hint\">Keine Spiele — SM scan noch aktiv oder keine Spiele gemountet.<br>Images unten mounten → dann Refresh.</p>';"
|
||||
"}}"
|
||||
"else{_gpR=0;renderGamesList(gl,gd.games);}"
|
||||
"gl.innerHTML='<p class=\"hint\">Keine Spiele gefunden</p>';"
|
||||
"}"
|
||||
"if(!il)return;"
|
||||
"if(!id||id.error||id.status){"
|
||||
"il.innerHTML='<p class=\"hint\" style=\"color:#f87171;font-size:.78rem;\">'+(id&&id.error?id.error:'nicht erreichbar')+'</p>';return;}"
|
||||
|
||||
Reference in new issue
Block a user