56 lines
3.3 KiB
HTML
56 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>随机段子</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;display:flex;align-items:center;justify-content:center;min-height:calc(100vh - 68px)}
|
|
.quote{background:linear-gradient(135deg,#f0fdf4,#ecfdf5);border-radius:20px;padding:36px 28px;text-align:center;border:1px solid rgba(34,197,94,.12);position:relative;width:100%}
|
|
.quote::before{content:'"';position:absolute;top:10px;left:20px;font-size:60px;color:rgba(34,197,94,.15);font-family:serif;line-height:1}
|
|
.quote-text{font-size:18px;line-height:2;color:#374151;font-weight:500}
|
|
.quote-src{font-size:12px;color:#9ca3af;margin-top:16px}
|
|
.loader{display:flex;flex-direction:column;align-items:center;padding:60px 0;color:#9ca3af;gap:10px;font-size:13px;width:100%}
|
|
.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;width:100%}
|
|
@media(max-width:640px){.quote-text{font-size:15px}.quote{padding:28px 20px}}
|
|
</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>😂 随机段子</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>
|
|
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/duanzi?encoding=json',{headers:{Accept:'application/json'}});
|
|
const json=await res.json();
|
|
const d=json.data!==undefined?json.data:json;
|
|
let text='',source='';
|
|
if(typeof d==='string'){text=d}
|
|
else if(d&&typeof d==='object'){
|
|
for(const k of['content','text','hitokoto','duanzi','joke','saying','answer','kfc','data']){if(typeof d[k]==='string'){text=d[k];break}}
|
|
if(!text){for(const v of Object.values(d)){if(typeof v==='string'&&v.length>5){text=v;break}}}
|
|
if(!text)text=JSON.stringify(d,null,2);
|
|
source=d.from||d.source||d.author||'';
|
|
}else{text=String(d??'')}
|
|
el.innerHTML=`<div class="quote"><div class="quote-text">${text}</div>${source?`<div class="quote-src">—— ${source}</div>`:''}</div>`;
|
|
}catch(e){el.innerHTML=`<div class="err">加载失败:${e.message}</div>`}
|
|
}
|
|
loadData();
|
|
</script>
|
|
</body>
|
|
</html> |