106 lines
5.8 KiB
HTML
106 lines
5.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>AI资讯快报</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;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
.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}
|
|
.date{display:flex;align-items:center;gap:6px;font-size:13px;color:#6b7280;padding-bottom:12px;border-bottom:1px solid #e5e7eb;margin-bottom:16px}
|
|
.item{display:flex;gap:10px;padding:11px 0;border-bottom:1px solid #f3f4f6}.item:last-child{border-bottom:none}
|
|
.num{flex-shrink:0;width:24px;height:24px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;margin-top:1px;color:#9ca3af;background:#f3f4f6}
|
|
.num.t1{color:#fff;background:#ef4444}.num.t2{color:#fff;background:#f97316}.num.t3{color:#fff;background:#eab308}
|
|
.text{flex:1;font-size:14px;line-height:1.7}
|
|
.tip{margin-top:20px;padding:14px 16px;border-radius:12px;font-size:13px;line-height:1.6;color:#6b7280;background:#f0fdf4;border:1px solid rgba(34,197,94,.1);font-style:italic}
|
|
.cover{margin-top:16px;text-align:center}.cover img{max-width:100%;border-radius:10px;box-shadow:0 2px 10px rgba(0,0,0,.08)}
|
|
.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){.body{padding:16px 12px 32px}.text{font-size:13px}.header h1{font-size:14px}}
|
|
</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>🤖 AI资讯快报</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>
|
|
const API=window.__SIXTY_API_BASE__+'/v2/ai-news?encoding=json';
|
|
function escapeHtml(s){
|
|
if(s==null)return'';
|
|
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
|
}
|
|
function pickNewsList(d){
|
|
if(!d||typeof d!=='object')return[];
|
|
if(Array.isArray(d))return d;
|
|
const keys=['news','items','list','data','content'];
|
|
for(const k of keys){
|
|
const v=d[k];
|
|
if(Array.isArray(v))return v;
|
|
}
|
|
return [];
|
|
}
|
|
function renderNewsItem(t,i){
|
|
const cls=i===0?'t1':i===1?'t2':i===2?'t3':'';
|
|
if(typeof t==='string'){
|
|
return `<div class="item"><div class="num ${cls}">${i+1}</div><div class="text">${escapeHtml(t)}</div></div>`;
|
|
}
|
|
if(t&&typeof t==='object'){
|
|
const title=t.title||t.name||'';
|
|
const link=t.link||t.url||'';
|
|
const detail=(t.detail||t.desc||t.description||'').trim();
|
|
const source=t.source||'';
|
|
const short=detail.length>220?detail.slice(0,220)+'…':detail;
|
|
let titleHtml=escapeHtml(title);
|
|
if(link)titleHtml=`<a href="${escapeHtml(link)}" target="_blank" rel="noopener" style="color:#059669;font-weight:600;text-decoration:none">${titleHtml} ↗</a>`;
|
|
let body=`<div class="text"><div style="margin-bottom:6px">${titleHtml}</div>`;
|
|
if(short)body+=`<div style="font-size:13px;color:#6b7280;line-height:1.65">${escapeHtml(short)}</div>`;
|
|
if(source)body+=`<div style="font-size:12px;color:#9ca3af;margin-top:6px">来源 · ${escapeHtml(source)}</div>`;
|
|
body+='</div>';
|
|
return `<div class="item"><div class="num ${cls}">${i+1}</div>${body}</div>`;
|
|
}
|
|
return `<div class="item"><div class="num ${cls}">${i+1}</div><div class="text">${escapeHtml(String(t))}</div></div>`;
|
|
}
|
|
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(API,{headers:{Accept:'application/json'}});
|
|
const json=await res.json();
|
|
if(json.code!=null&&json.code!==200&&json.code!==0){
|
|
throw new Error(json.message||('接口 code '+json.code));
|
|
}
|
|
const d=json.data||json;
|
|
let html='';
|
|
if(d.date)html+=`<div class="date">🕐 ${escapeHtml(d.date)} ${escapeHtml(d.day_of_week||'')}</div>`;
|
|
const news=pickNewsList(d);
|
|
if(news.length===0){
|
|
html+=`<div class="tip" style="margin-top:0;font-style:normal">
|
|
<strong>当日暂无 AI 资讯条目</strong><br><br>
|
|
官方说明:数据源并非每日更新,重大资讯也可能集中在晚间。建议 <strong>22:00 后</strong> 再试,或在接口中传入 <code style="background:#fff;padding:2px 6px;border-radius:6px">?date=2025-11-11</code> 查看历史日期。
|
|
</div>`;
|
|
}else{
|
|
news.forEach((t,i)=>{html+=renderNewsItem(t,i);});
|
|
}
|
|
if(d.tip)html+=`<div class="tip">💡 ${escapeHtml(d.tip)}</div>`;
|
|
if(d.image)html+=`<div class="cover"><img src="${escapeHtml(d.image)}" alt="封面" loading="lazy"></div>`;
|
|
el.innerHTML=html||'<div class="err">暂无数据</div>';
|
|
}catch(e){el.innerHTML=`<div class="err">加载失败:${escapeHtml(e.message)}</div>`}
|
|
}
|
|
loadData();
|
|
</script>
|
|
</body>
|
|
</html>
|