Spaces:
Running
Running
新增:清洗进度看板页面 + /api/clean/progress|materials 路由(原有功能保持不变)
Browse files- public/progress.html +234 -0
- server.js +17 -0
public/progress.html
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="zh-CN">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 6 |
+
<title>清洗进度看板 · 小说素材库</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root{--bg:#0b0f14;--card:#131a22;--card2:#18222c;--line:#243040;--tx:#e6edf3;--dim:#8b9bad;--acc:#f97316;--blue:#3b82f6;--grn:#22c55e;--red:#ef4444;--yel:#eab308}
|
| 9 |
+
*{box-sizing:border-box}
|
| 10 |
+
body{margin:0;background:var(--bg);color:var(--tx);font:14px/1.6 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
| 11 |
+
a{color:var(--blue)}
|
| 12 |
+
.wrap{max-width:1180px;margin:0 auto;padding:20px 16px 60px}
|
| 13 |
+
h1{font-size:20px;margin:0}
|
| 14 |
+
.top{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px}
|
| 15 |
+
.sub{color:var(--dim);font-size:12px}
|
| 16 |
+
button{background:var(--card2);color:var(--tx);border:1px solid var(--line);border-radius:8px;padding:6px 12px;cursor:pointer;font-size:13px}
|
| 17 |
+
button:hover{border-color:var(--acc)}
|
| 18 |
+
button.pri{background:var(--acc);border-color:var(--acc);color:#111;font-weight:600}
|
| 19 |
+
input{background:#0f1620;border:1px solid var(--line);color:var(--tx);border-radius:8px;padding:7px 10px;font-size:13px;outline:none}
|
| 20 |
+
input:focus{border-color:var(--acc)}
|
| 21 |
+
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin-bottom:16px}
|
| 22 |
+
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:14px}
|
| 23 |
+
.k{color:var(--dim);font-size:12px;margin-bottom:4px}
|
| 24 |
+
.v{font-size:24px;font-weight:700;letter-spacing:.5px}
|
| 25 |
+
.v small{font-size:12px;color:var(--dim);font-weight:400}
|
| 26 |
+
.bar{height:10px;background:#0f1620;border-radius:99px;overflow:hidden;border:1px solid var(--line)}
|
| 27 |
+
.bar>i{display:block;height:100%;background:linear-gradient(90deg,#f97316,#facc15);min-width:2px}
|
| 28 |
+
.sec{margin:26px 0 10px;font-size:16px;font-weight:700;display:flex;align-items:center;gap:8px}
|
| 29 |
+
.sec .n{color:var(--dim);font-size:12px;font-weight:400}
|
| 30 |
+
table{width:100%;border-collapse:collapse;font-size:13px}
|
| 31 |
+
th,td{text-align:left;padding:7px 8px;border-bottom:1px solid var(--line);vertical-align:top}
|
| 32 |
+
th{color:var(--dim);font-weight:500;font-size:12px;position:sticky;top:0;background:var(--card)}
|
| 33 |
+
tbody tr:hover{background:#161f29}
|
| 34 |
+
.num{font-variant-numeric:tabular-nums}
|
| 35 |
+
.keep{color:var(--grn)}.drop{color:var(--dim)}.rw{color:var(--yel)}
|
| 36 |
+
.scroll{max-height:520px;overflow:auto;border:1px solid var(--line);border-radius:12px;background:var(--card)}
|
| 37 |
+
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px}
|
| 38 |
+
.chrow{display:flex;align-items:center;gap:10px;padding:7px 10px;border-bottom:1px solid var(--line);font-size:13px}
|
| 39 |
+
.chrow:last-child{border-bottom:0}
|
| 40 |
+
.chrow .nm{width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 41 |
+
.chrow .bb{flex:1;height:6px;background:#0f1620;border-radius:99px;overflow:hidden}
|
| 42 |
+
.chrow .bb>i{display:block;height:100%;background:var(--blue)}
|
| 43 |
+
.chrow .st{width:120px;text-align:right;color:var(--dim);font-size:12px;font-variant-numeric:tabular-nums}
|
| 44 |
+
.chrow.done .bb>i{background:var(--grn)}
|
| 45 |
+
.mgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:12px}
|
| 46 |
+
.m{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:12px;display:flex;flex-direction:column;gap:8px}
|
| 47 |
+
.m .hd{display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--dim)}
|
| 48 |
+
.m .tx{white-space:pre-wrap;max-height:150px;overflow:hidden;font-size:13px;line-height:1.65;position:relative}
|
| 49 |
+
.m.open .tx{max-height:none}
|
| 50 |
+
.m .nt{font-size:12px;color:var(--dim);border-top:1px dashed var(--line);padding-top:7px}
|
| 51 |
+
.tag{display:inline-block;background:#1d2836;border:1px solid var(--line);border-radius:6px;padding:1px 7px;font-size:11px;color:var(--dim)}
|
| 52 |
+
.overlay{position:fixed;inset:0;background:rgba(5,8,12,.92);display:flex;align-items:center;justify-content:center;z-index:99}
|
| 53 |
+
.overlay .box{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:24px;width:330px;text-align:center}
|
| 54 |
+
.overlay h2{margin:0 0 6px;font-size:17px}
|
| 55 |
+
.overlay p{color:var(--dim);font-size:12px;margin:0 0 14px}
|
| 56 |
+
.err{color:var(--red);font-size:12px;min-height:16px;margin-top:8px}
|
| 57 |
+
.pg{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:10px 0}
|
| 58 |
+
.pg span{color:var(--dim);font-size:12px}
|
| 59 |
+
</style>
|
| 60 |
+
</head>
|
| 61 |
+
<body>
|
| 62 |
+
<div class="wrap">
|
| 63 |
+
<div class="top">
|
| 64 |
+
<div>
|
| 65 |
+
<h1>🧹 素材清洗进度看板</h1>
|
| 66 |
+
<div class="sub" id="updated">加载中…</div>
|
| 67 |
+
</div>
|
| 68 |
+
<div style="display:flex;gap:8px;align-items:center">
|
| 69 |
+
<a href="/" class="sub">← 返回素材库</a>
|
| 70 |
+
<button onclick="loadAll(true)">刷新</button>
|
| 71 |
+
<button onclick="logout()">退出</button>
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<div class="card" style="margin-bottom:16px">
|
| 76 |
+
<div style="display:flex;justify-content:space-between;font-size:12px;color:var(--dim);margin-bottom:6px">
|
| 77 |
+
<span>逐条通读进度(目标:全库)</span><span id="pct">—</span>
|
| 78 |
+
</div>
|
| 79 |
+
<div class="bar"><i id="pbar" style="width:0"></i></div>
|
| 80 |
+
<div class="sub" id="pline" style="margin-top:8px"></div>
|
| 81 |
+
</div>
|
| 82 |
+
|
| 83 |
+
<div class="grid" id="stats"></div>
|
| 84 |
+
|
| 85 |
+
<div class="sec">📦 频道进度 <span class="n">按剩余量排序</span></div>
|
| 86 |
+
<div class="scroll" id="channels"></div>
|
| 87 |
+
|
| 88 |
+
<div class="sec">🗂 批次记录 <span class="n">最近 60 批</span></div>
|
| 89 |
+
<div class="scroll" id="batches"></div>
|
| 90 |
+
|
| 91 |
+
<div class="sec">✨ 处理后的素材 <span class="n" id="mtotal"></span></div>
|
| 92 |
+
<div class="pg">
|
| 93 |
+
<input id="q" placeholder="在本页内搜索关键词…" style="flex:1;min-width:200px" oninput="renderMats()" />
|
| 94 |
+
<button onclick="pageGo(-1)">上一页</button>
|
| 95 |
+
<span id="pinfo">—</span>
|
| 96 |
+
<button onclick="pageGo(1)">下一页</button>
|
| 97 |
+
<button onclick="pageGo(0)">首页</button>
|
| 98 |
+
</div>
|
| 99 |
+
<div class="mgrid" id="mats"></div>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<div class="overlay" id="gate">
|
| 103 |
+
<div class="box">
|
| 104 |
+
<h2>🔒 需要访问密码</h2>
|
| 105 |
+
<p>请输入访问密码后查看清洗进度</p>
|
| 106 |
+
<input id="pw" type="password" placeholder="访问密码" style="width:100%" onkeydown="if(event.key==='Enter')unlock()" />
|
| 107 |
+
<div class="err" id="gerr"></div>
|
| 108 |
+
<button class="pri" style="width:100%;margin-top:6px" onclick="unlock()">进入</button>
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
<script>
|
| 113 |
+
const LS='xs_progress_pw';
|
| 114 |
+
let PW=localStorage.getItem(LS)||'';
|
| 115 |
+
let PROG=null, MATS=null, PAGE=0;
|
| 116 |
+
|
| 117 |
+
function fmt(n){return (n==null?'—':Number(n).toLocaleString('en-US'))}
|
| 118 |
+
function wc(n){n=Number(n||0);return n>=10000?(n/10000).toFixed(1)+' 万':fmt(n)}
|
| 119 |
+
|
| 120 |
+
async function api(path){
|
| 121 |
+
const r=await fetch(path,{headers:{'x-app-password':encodeURIComponent(PW)}});
|
| 122 |
+
if(r.status===401) throw new Error('401');
|
| 123 |
+
if(!r.ok) throw new Error('HTTP '+r.status);
|
| 124 |
+
return r.json();
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function logout(){localStorage.removeItem(LS);PW='';location.reload()}
|
| 128 |
+
|
| 129 |
+
async function unlock(){
|
| 130 |
+
const v=document.getElementById('pw').value.trim();
|
| 131 |
+
if(!v) return;
|
| 132 |
+
PW=v;
|
| 133 |
+
try{
|
| 134 |
+
await api('/api/clean/progress');
|
| 135 |
+
localStorage.setItem(LS,v);
|
| 136 |
+
document.getElementById('gate').style.display='none';
|
| 137 |
+
loadAll();
|
| 138 |
+
}catch(e){
|
| 139 |
+
document.getElementById('gerr').textContent = e.message==='401'?'密码不对,再试一次':'连接失败:'+e.message;
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
function renderStats(s){
|
| 144 |
+
const cards=[
|
| 145 |
+
['已通读',fmt(s.read)+' <small>/ '+fmt(s.total)+'</small>',''],
|
| 146 |
+
['已完成批次',fmt(s.batches),''],
|
| 147 |
+
['处理后素材',fmt(s.materials)+' <small>条</small>',''],
|
| 148 |
+
['素材总字数',wc(s.chars_out)+' <small>字</small>',''],
|
| 149 |
+
['保留',fmt(s.kept),'keep'],
|
| 150 |
+
['改写后保留',fmt(s.rewritten),'rw'],
|
| 151 |
+
['剔除',fmt(s.dropped),'drop'],
|
| 152 |
+
];
|
| 153 |
+
document.getElementById('stats').innerHTML=cards.map(c=>`<div class="card"><div class="k">${c[0]}</div><div class="v ${c[2]}">${c[1]}</div></div>`).join('');
|
| 154 |
+
document.getElementById('pct').textContent=s.percent+'%';
|
| 155 |
+
document.getElementById('pbar').style.width=Math.max(0.4,s.percent)+'%';
|
| 156 |
+
const left=s.total-s.read;
|
| 157 |
+
document.getElementById('pline').textContent=`已完成 ${fmt(s.batches)} 批 · 剩余 ${fmt(Math.ceil(left/100))} 批 · 全库剩余 ${fmt(left)} 条`;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
function renderChannels(rows){
|
| 161 |
+
document.getElementById('channels').innerHTML=rows.map(c=>{
|
| 162 |
+
const p=c.total?Math.min(100,c.read/c.total*100):0;
|
| 163 |
+
return `<div class="chrow ${c.read>=c.total?'done':''}">
|
| 164 |
+
<div class="nm" title="${c.title}">${c.title}</div>
|
| 165 |
+
<div class="mono" style="width:130px;color:var(--dim)">${c.channel}</div>
|
| 166 |
+
<div class="bb"><i style="width:${p.toFixed(2)}%"></i></div>
|
| 167 |
+
<div class="st">${fmt(c.read)} / ${fmt(c.total)}</div>
|
| 168 |
+
<div class="st" style="width:80px">素材 ${fmt(c.materials)}</div>
|
| 169 |
+
</div>`;
|
| 170 |
+
}).join('');
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
function renderBatches(bs){
|
| 174 |
+
const rows=[...bs].reverse();
|
| 175 |
+
document.getElementById('batches').innerHTML=`<table><thead><tr>
|
| 176 |
+
<th style="width:60px">批次</th><th style="width:230px">范围</th>
|
| 177 |
+
<th style="width:52px">保留</th><th style="width:52px">改写</th><th style="width:52px">剔除</th>
|
| 178 |
+
<th>本批精选</th></tr></thead><tbody>`+rows.map(b=>{
|
| 179 |
+
const keeps=(b.keeps||[]).map(k=>`<span class="tag" title="${(k.note||'').replace(/"/g,'')}">${k.key}${k.verdict==='rewrite'?'(改写)':''}</span>`).join(' ');
|
| 180 |
+
return `<tr><td class="mono">${b.no}</td>
|
| 181 |
+
<td class="mono" style="color:var(--dim)">${(b.from||'').replace(/^/,'')} → ${b.to||''}</td>
|
| 182 |
+
<td class="num keep">${b.kept||0}</td><td class="num rw">${b.rewritten||0}</td><td class="num drop">${b.dropped||0}</td>
|
| 183 |
+
<td>${keeps||'<span class="drop">—</span>'}</td></tr>`;
|
| 184 |
+
}).join('')+'</tbody></table>';
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function renderMats(){
|
| 188 |
+
if(!MATS) return;
|
| 189 |
+
const q=(document.getElementById('q').value||'').trim().toLowerCase();
|
| 190 |
+
const items=q?MATS.items.filter(m=>(m.text||'').toLowerCase().includes(q)||(m.key||'').toLowerCase().includes(q)||(m.category||'').includes(q)):MATS.items;
|
| 191 |
+
document.getElementById('mats').innerHTML=items.map((m,i)=>`
|
| 192 |
+
<div class="m" id="m${i}">
|
| 193 |
+
<div class="hd"><span class="mono">${m.key}</span><span>${m.category||'—'} · ${fmt(m.chars)} 字</span></div>
|
| 194 |
+
<div class="tx" id="tx${i}">${(m.text||'').replace(/[<>&]/g,c=>({'<':'<','>':'>','&':'&'}[c]))}</div>
|
| 195 |
+
<div style="display:flex;gap:8px;align-items:center">
|
| 196 |
+
<button onclick="document.getElementById('m${i}').classList.toggle('open')">展开/收起</button>
|
| 197 |
+
${m.verdict==='rewrite'?'<span class="tag" style="color:var(--yel)">改写后保留</span>':''}
|
| 198 |
+
</div>
|
| 199 |
+
${m.note?`<div class="nt">保留理由:${m.note}</div>`:''}
|
| 200 |
+
</div>`).join('')||'<div class="sub" style="padding:12px">本页没有匹配内容</div>';
|
| 201 |
+
document.getElementById('pinfo').textContent=`第 ${MATS.page+1} / ${MATS.pages} 页`;
|
| 202 |
+
document.getElementById('mtotal').textContent=`共 ${fmt(MATS.total)} 条 · 每页 100 条`;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
async function pageGo(d){
|
| 206 |
+
if(!MATS) return;
|
| 207 |
+
let p=d===0?0:MATS.page+d;
|
| 208 |
+
p=Math.max(0,Math.min(MATS.pages-1,p));
|
| 209 |
+
if(p===MATS.page) return;
|
| 210 |
+
PAGE=p;
|
| 211 |
+
MATS=await api('/api/clean/materials?page='+p);
|
| 212 |
+
document.getElementById('q').value='';
|
| 213 |
+
renderMats();
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
async function loadAll(manual){
|
| 217 |
+
try{
|
| 218 |
+
PROG=await api('/api/clean/progress');
|
| 219 |
+
}catch(e){
|
| 220 |
+
if(e.message==='401'){document.getElementById('gate').style.display='flex';return}
|
| 221 |
+
document.getElementById('updated').textContent='加载失败:'+e.message;return;
|
| 222 |
+
}
|
| 223 |
+
document.getElementById('gate').style.display='none';
|
| 224 |
+
const s=PROG.stats;
|
| 225 |
+
document.getElementById('updated').textContent=`最后同步:${new Date(PROG.updated_at).toLocaleString('zh-CN')} · 数据来自 Cloudflare R2`;
|
| 226 |
+
renderStats(s); renderChannels(PROG.channels||[]); renderBatches(PROG.batches||[]);
|
| 227 |
+
if(!MATS){ try{ MATS=await api('/api/clean/materials?page='+PAGE); renderMats(); }catch(e){} }
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
if(PW){ document.getElementById('pw').value=PW; unlock(); }
|
| 231 |
+
setInterval(()=>{ if(PW && document.getElementById('gate').style.display==='none') loadAll(); },30000);
|
| 232 |
+
</script>
|
| 233 |
+
</body>
|
| 234 |
+
</html>
|
server.js
CHANGED
|
@@ -84237,6 +84237,23 @@ app.post("/api/discover/run", guarded(discoverRun));
|
|
| 84237 |
app.post("/api/discover/stop", guarded(() => discoverStop()));
|
| 84238 |
app.post("/api/discover/update", guarded(discoverUpdate));
|
| 84239 |
app.post("/api/discover/clear", guarded(() => discoverClear()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84240 |
app.all("/api/*", async (req, res) => {
|
| 84241 |
if (!passwordOk(req)) return res.status(401).json({ error: "password required" });
|
| 84242 |
const url = new URL(req.originalUrl, "http://x");
|
|
|
|
| 84237 |
app.post("/api/discover/stop", guarded(() => discoverStop()));
|
| 84238 |
app.post("/api/discover/update", guarded(discoverUpdate));
|
| 84239 |
app.post("/api/discover/clear", guarded(() => discoverClear()));
|
| 84240 |
+
/* ===== [新增] 素材清洗进度看板 API —— 由 materials/sync_progress.py 同步数据,不影响原有任何功能 ===== */
|
| 84241 |
+
const __cleanProgressRead = (rel) => new Promise((ok, no) => process.getBuiltinModule("fs").readFile(import_path.default.join(PUBLIC, rel), "utf8", (e, d) => e ? no(e) : ok(d)));
|
| 84242 |
+
app.get("/api/clean/progress", async (req, res) => {
|
| 84243 |
+
if (!passwordOk(req)) return res.status(401).json({ error: "password required" });
|
| 84244 |
+
try { res.setHeader("Cache-Control", "no-cache"); res.type("application/json").send(await __cleanProgressRead("progress.json")); }
|
| 84245 |
+
catch (e) { res.status(404).json({ error: "progress not synced yet" }); }
|
| 84246 |
+
});
|
| 84247 |
+
app.get("/api/clean/materials", async (req, res) => {
|
| 84248 |
+
if (!passwordOk(req)) return res.status(401).json({ error: "password required" });
|
| 84249 |
+
const url = new URL(req.originalUrl, "http://x");
|
| 84250 |
+
let pg = parseInt(url.searchParams.get("page") || "0", 10);
|
| 84251 |
+
if (!Number.isFinite(pg) || pg < 0) pg = 0;
|
| 84252 |
+
if (pg > 9999) pg = 9999;
|
| 84253 |
+
try { res.setHeader("Cache-Control", "no-cache"); res.type("application/json").send(await __cleanProgressRead("materials/page-" + String(pg).padStart(3, "0") + ".json")); }
|
| 84254 |
+
catch (e) { res.status(404).json({ error: "no such page" }); }
|
| 84255 |
+
});
|
| 84256 |
+
/* ===== [新增结束] ===== */
|
| 84257 |
app.all("/api/*", async (req, res) => {
|
| 84258 |
if (!passwordOk(req)) return res.status(401).json({ error: "password required" });
|
| 84259 |
const url = new URL(req.originalUrl, "http://x");
|