112 lines
5.9 KiB
HTML
112 lines
5.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Epic免费游戏</title>
|
|
<style>
|
|
*{margin:0;padding:0;box-sizing:border-box}
|
|
body{font-family:'KaiTi','楷体',serif;background:#f9fafb;color:#1f2937;line-height:1.6;min-height:100vh}
|
|
.header{background:linear-gradient(135deg,#065f46,#059669);color:#fff;padding:16px;display:flex;align-items:center;gap:12px;position:sticky;top:0;z-index:10}
|
|
.header h1{flex:1;font-size:16px;font-weight:700}.btn{width:36px;height:36px;border:none;border-radius:10px;background:rgba(255,255,255,.15);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:18px}.btn:hover{background:rgba(255,255,255,.25)}
|
|
.body{max-width:720px;margin:0 auto;padding:20px 16px 40px}
|
|
.rank-item{display:flex;align-items:stretch;gap:12px;padding:12px 14px;margin-bottom:6px;border-radius:12px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.04);transition:all .15s}
|
|
.rank-item:hover{box-shadow:0 3px 10px rgba(0,0,0,.08);transform:translateX(2px)}
|
|
.thumb-wrap{flex-shrink:0;width:120px;min-height:68px;border-radius:10px;overflow:hidden;background:#f3f4f6;align-self:center}
|
|
.thumb-wrap img{display:block;width:100%;height:100%;min-height:68px;object-fit:cover}
|
|
.rank-main{display:flex;align-items:flex-start;gap:10px;flex:1;min-width:0}
|
|
.badge{flex-shrink:0;width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:800;color:#9ca3af;background:#f3f4f6}
|
|
.badge.t1{color:#fff;background:linear-gradient(135deg,#ef4444,#dc2626)}.badge.t2{color:#fff;background:linear-gradient(135deg,#f97316,#ea580c)}.badge.t3{color:#fff;background:linear-gradient(135deg,#eab308,#ca8a04)}
|
|
.rank-body{flex:1;min-width:0}
|
|
.rank-title{font-size:14px;font-weight:500;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
.rank-title a{color:inherit;text-decoration:none}.rank-title a:hover{color:#059669}
|
|
.rank-meta{font-size:11px;color:#b0b0b0;margin-top:2px}
|
|
.loader{display:flex;flex-direction:column;align-items:center;padding:60px 0;color:#9ca3af;gap:10px;font-size:13px}
|
|
.spinner{width:24px;height:24px;border:3px solid #e5e7eb;border-top-color:#059669;border-radius:50%;animation:spin 1s linear infinite}
|
|
@keyframes spin{to{transform:rotate(360deg)}}
|
|
.err{text-align:center;padding:40px 16px;color:#ef4444;font-size:14px}
|
|
@media(max-width:640px){.thumb-wrap{width:88px;min-height:50px}.thumb-wrap img{min-height:50px}}
|
|
</style>
|
|
<script src="/60sapi/ig-embed.js"></script>
|
|
<script src="/60sapi/sixty-runtime.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<button class="btn" onclick="history.back()">←</button>
|
|
<h1>🎮 Epic免费游戏</h1>
|
|
<button class="btn" onclick="loadData()">↻</button>
|
|
</div>
|
|
<div class="body" id="content">
|
|
<div class="loader"><div class="spinner"></div><span>加载中...</span></div>
|
|
</div>
|
|
<script>
|
|
function safeHttpUrl(u){
|
|
if(!u||typeof u!=='string')return'';
|
|
const t=u.trim();
|
|
return /^https?:\/\//i.test(t)?t:'';
|
|
}
|
|
function escapeAttr(s){
|
|
return String(s).replace(/&/g,'&').replace(/"/g,'"');
|
|
}
|
|
function escapeHtml(s){
|
|
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
}
|
|
/** 从 Epic / 60s 多种字段里取封面图 */
|
|
function pickEpicCover(item){
|
|
if(!item)return'';
|
|
const tryKeys=['poster','cover','coverUrl','image','imageUrl','thumbnail','icon','logo'];
|
|
for(const k of tryKeys){
|
|
const v=item[k];
|
|
if(typeof v==='string'&&safeHttpUrl(v))return safeHttpUrl(v);
|
|
}
|
|
const imgs=item.keyImages||item.images;
|
|
if(Array.isArray(imgs)&&imgs.length){
|
|
const wide=imgs.find(function(k){return k&&(/wide|landscape|offerimagewide|diesel/i.test(String(k.type||'')));});
|
|
const first=imgs[0];
|
|
const url=(wide&&wide.url)||(first&&first.url)||'';
|
|
return safeHttpUrl(url);
|
|
}
|
|
return'';
|
|
}
|
|
function pickEpicList(d){
|
|
if(Array.isArray(d))return d;
|
|
if(!d||typeof d!=='object')return[];
|
|
const keys=['games','freeGames','items','list','data','elements'];
|
|
for(let i=0;i<keys.length;i++){
|
|
const v=d[keys[i]];
|
|
if(Array.isArray(v))return v;
|
|
}
|
|
return[];
|
|
}
|
|
async function loadData(){
|
|
const el=document.getElementById('content');
|
|
el.innerHTML='<div class="loader"><div class="spinner"></div><span>加载中...</span></div>';
|
|
try{
|
|
const res=await fetch(window.__SIXTY_API_BASE__+'/v2/epic?encoding=json',{headers:{Accept:'application/json'}});
|
|
const json=await res.json();
|
|
const d=json.data||json;
|
|
const list=pickEpicList(d);
|
|
if(!list.length)throw new Error('暂无数据');
|
|
let html='';
|
|
list.slice(0,50).forEach((item,i)=>{
|
|
const title=item.title||item.name||String(item);
|
|
const link=item.link||item.url||item.storeUrl||'';
|
|
const hot=item.hot||item.hotScore||item.heat||item.score||'';
|
|
const desc=item.desc||item.description||item.subtitle||'';
|
|
const img=pickEpicCover(item);
|
|
const cls=i===0?'t1':i===1?'t2':i===2?'t3':'';
|
|
html+='<div class="rank-item">';
|
|
if(img)html+=`<div class="thumb-wrap"><img src="${escapeAttr(img)}" alt="" loading="lazy" decoding="async" onerror="this.style.visibility='hidden'"/></div>`;
|
|
html+='<div class="rank-main"><div class="badge '+cls+'">'+(i+1)+'</div><div class="rank-body">';
|
|
html+=`<div class="rank-title">${link?`<a href="${escapeAttr(link)}" target="_blank" rel="noopener">${escapeHtml(title)} ↗</a>`:escapeHtml(title)}</div>`;
|
|
if(desc)html+=`<div class="rank-meta">${escapeHtml(desc.length>120?desc.slice(0,120)+'…':desc)}</div>`;
|
|
if(hot)html+=`<div class="rank-meta">🔥 ${typeof hot==='number'?hot.toLocaleString():hot}</div>`;
|
|
html+='</div></div></div>';
|
|
});
|
|
el.innerHTML=html;
|
|
}catch(e){el.innerHTML=`<div class="err">加载失败:${e.message}</div>`}
|
|
}
|
|
loadData();
|
|
</script>
|
|
</body>
|
|
</html>
|