dsh-rank-scan 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/lib/client.js +276 -122
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,7 +18,7 @@ DeepSeek Harness 扫榜插件:定时 + 按需采集多站小说榜单,算变
18
18
 
19
19
  ```sh
20
20
  dsh plugin --profile desktop add github:kilo-s/dsh-rank-scan
21
- # 钉版本:github:kilo-s/dsh-rank-scan#v0.4.1
21
+ # 钉版本:github:kilo-s/dsh-rank-scan#v0.5.0
22
22
  ```
23
23
 
24
24
  仓库不含编译产物,这条命令会在安装时现场构建 `lib/`。首次可能被 pnpm 拦下构建脚本(它会打印要放行的键,加进 `allowBuilds` 后重跑即可),细节见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。
@@ -37,14 +37,14 @@ dsh plugin --profile desktop add "<tgz 的完整路径>"
37
37
 
38
38
  ```sh
39
39
  dsh plugin --profile desktop add dsh-rank-scan
40
- # 钉版本:dsh-rank-scan@0.4.1
40
+ # 钉版本:dsh-rank-scan@0.5.0
41
41
  ```
42
42
 
43
43
  npm 上那份是 CI 从源码构建的(包内自带 `lib/`,发布带 `--provenance` 签名)——装的时候不用再编译,也不会被 pnpm 的 `allowBuilds` 拦下。面板的「检查更新」读的就是 npm 上的版本号。
44
44
 
45
45
  **验证**:重开 DSH 后左侧栏会话列表下方应出现「扫榜」入口;或访问 `http://127.0.0.1:19387/api/rank-scan/health`,返回 `{ok:true,...}` 即通。
46
46
 
47
- **更新**:重跑安装命令即可(链接直装取最新 `main`,registry 装取最新发布版;本版本为 **0.4.1**);面板「设置」页底部会读 npm 上的版本号提示有没有新版,装了 [dsh-market](https://github.com/dsh-market/dsh-market) 的话还能就地更新。
47
+ **更新**:重跑安装命令即可(链接直装取最新 `main`,registry 装取最新发布版;本版本为 **0.5.0**);面板「设置」页底部会读 npm 上的版本号提示有没有新版,装了 [dsh-market](https://github.com/dsh-market/dsh-market) 的话还能就地更新。
48
48
 
49
49
  **卸载**:`dsh plugin --profile desktop remove dsh-rank-scan`。数据目录 `~/.dsh/data/rank-scan` 会保留,要彻底清理自行删除;脚本化卸载与 patch 安全口径见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。
50
50
 
package/lib/client.js CHANGED
@@ -17,7 +17,10 @@ window.__ModuleLoader__.load({
17
17
  const readResponse = async (response) => {
18
18
  const data = await response.json()
19
19
  if (response.ok === false || (data && (data.ok === false || data.error))) {
20
- throw new Error((data && (data.error || data.note)) || ('请求失败:' + response.status))
20
+ const err = new Error((data && (data.error || data.note)) || ('请求失败:' + response.status))
21
+ err.status = response.status
22
+ if (data && data.code) err.code = data.code
23
+ throw err
21
24
  }
22
25
  return data
23
26
  }
@@ -208,6 +211,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
208
211
  '.rs-banner.is-error{border-color:' + T.bad + ';background:' + wash(T.bad, 8) + '}',
209
212
  '.rs-banner .rs-banner-body{flex:1 1 100%;min-width:0}',
210
213
  '.rs-toasts{position:absolute;right:12px;top:64px;bottom:auto;z-index:95;display:flex;flex-direction:column;gap:6px;max-width:min(380px,calc(100% - 24px));max-height:calc(100% - 80px);overflow:auto;pointer-events:none}',
214
+ '.rs-statcard:focus-visible{outline:2px solid ' + T.accent + ';outline-offset:1px}',
211
215
  '.rs-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:8px;padding:7px 9px;border-radius:' + T.r.s + ';border:1px solid;border-left-width:3px;background:' + T.surface + ';color:' + T.fg + ';box-shadow:' + T.shadowMenu + ';font-size:' + T.fs.s + ';line-height:1.45}',
212
216
  '.rs-toast.is-info{border-color:' + T.accent + ';background-image:linear-gradient(' + wash(T.accent, 10) + ',' + wash(T.accent, 10) + ')}',
213
217
  '.rs-toast.is-warn{border-color:' + T.warn + ';background-image:linear-gradient(' + wash(T.warn, 12) + ',' + wash(T.warn, 12) + ')}',
@@ -1037,6 +1041,74 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1037
1041
  * ③ 全部榜单(可折叠;逐榜状态 + 涨/新/退;同站抓取时刻一致时只写一次)
1038
1042
  * ★ 2026-10-22(简明性 B):存储/保留/诊断移到「设置」页 —— 采集管理不再占首屏。
1039
1043
  */
1044
+ /**
1045
+ * 概览数字卡(0.5.0):值大、标签小;tone 只影响左色条与数字颜色,文字本身必须能读懂状态。
1046
+ * 有 onClick 时渲染成 button(Tab 可聚焦,focus-visible 蓝框),没有时是 div。
1047
+ */
1048
+ function StatCard(props) {
1049
+ const tone = props.tone || 'muted'
1050
+ const color = tone === 'ok' ? T.ok : tone === 'warn' ? T.warn : tone === 'bad' ? T.bad : T.muted
1051
+ const body = h('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px', minWidth: 0, textAlign: 'left' } },
1052
+ h('div', { style: { ...C.muted, fontSize: T.fs.s, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, props.label),
1053
+ h('div', { style: { fontSize: T.fs.l, fontWeight: 700, fontVariantNumeric: 'tabular-nums', color, lineHeight: 1.2, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, props.value),
1054
+ props.sub ? h('div', { style: { ...C.muted, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }, title: String(props.sub) }, props.sub) : null)
1055
+ const style = {
1056
+ display: 'flex', flexDirection: 'column', gap: '2px', minWidth: 0, boxSizing: 'border-box', textAlign: 'left',
1057
+ padding: '8px 10px', paddingLeft: '12px', border: '1px solid ' + T.border, borderLeft: '3px solid ' + color,
1058
+ borderRadius: T.r.s, background: T.surface, color: T.fg, font: 'inherit',
1059
+ cursor: props.onClick ? 'pointer' : 'default',
1060
+ }
1061
+ if (props.onClick) {
1062
+ return h('button', { type: 'button', className: 'rs-statcard', style: Object.assign({ appearance: 'none' }, style), onClick: props.onClick, title: props.title || props.label },
1063
+ body)
1064
+ }
1065
+ return h('div', { className: 'rs-statcard', style: style, title: props.title || '' }, body)
1066
+ }
1067
+ /** 概览区块小标题:标题 + 右侧计数 + 可选操作;innerRef 供数字卡 scrollIntoView 用 */
1068
+ function SectionHeader(props) {
1069
+ return h('div', { ref: props.innerRef, style: { display: 'flex', alignItems: 'baseline', gap: '8px', minWidth: 0, margin: props.first ? '8px 0 4px' : '12px 0 6px' } },
1070
+ h('div', { style: { fontWeight: 600, fontSize: T.fs.m, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, props.title),
1071
+ h('div', { style: { marginLeft: 'auto', display: 'flex', alignItems: 'baseline', gap: '6px', flex: '0 0 auto' } },
1072
+ props.count != null && props.count !== '' ? h('span', { style: C.muted }, '(' + props.count + ')') : null,
1073
+ props.action || null))
1074
+ }
1075
+
1076
+ const SITE_LABELS = { qidian: '起点', qidiantu: '起点图', ciweimao: '刺猬猫', sfacg: '菠萝包', fanqie: '番茄' }
1077
+ const siteLabelOf = function (ov, s) {
1078
+ const hit = ((ov && ov.sites) || []).filter(function (x) { return x.site === s })[0]
1079
+ return hit ? hit.siteName : (SITE_LABELS[s] || String(s))
1080
+ }
1081
+ /**
1082
+ * 下次计划(0.5.0 验收修正):
1083
+ * · waiting 里最近站点的时刻 → 中性色;
1084
+ * · 今天全跑完(无 waiting/fallback)→ 取已启用站 siteTimes 的最早时刻,写「明天 HH:mm」;
1085
+ * · siteTimes 也为空 → label 改成「上次扫描」,避免把过去的时刻说成将来的计划;
1086
+ * · 定时关闭/只剩兜底 → warn。
1087
+ */
1088
+ function nextPlanOf(plan, ov, scan, total) {
1089
+ if (!plan) return { label: '下次计划', value: '—', sub: '计划读取中', tone: 'muted' }
1090
+ if (plan.enabled === false) return { label: '下次计划', value: '已关闭', sub: '定时扫描', tone: 'warn' }
1091
+ if (typeof total === 'number' && total === 0) return { label: '下次计划', value: '—', sub: '还没有勾选要扫的榜', tone: 'muted' }
1092
+ const times = plan.siteTimes || {}
1093
+ const waiting = (plan.waiting || []).filter(function (s) { return times[s] })
1094
+ if (waiting.length) {
1095
+ const order = waiting.slice().sort(function (a, b) { return String(times[a]).localeCompare(String(times[b])) })
1096
+ return { label: '下次计划', value: times[order[0]], sub: siteLabelOf(ov, order[0]), tone: 'muted' }
1097
+ }
1098
+ if ((plan.fallback || []).length) {
1099
+ return { label: '下次计划', value: plan.fallbackTime || '22:30', sub: siteLabelOf(ov, plan.fallback[0]), tone: 'warn' }
1100
+ }
1101
+ const enabled = ((ov && ov.sites) || []).map(function (s) { return s.site }).filter(function (s) { return times[s] })
1102
+ const nextTimes = enabled.slice().sort(function (a, b) { return String(times[a]).localeCompare(String(times[b])) })
1103
+ if (nextTimes.length) {
1104
+ const s = nextTimes[0]
1105
+ return { label: '下次计划', value: '明天 ' + times[s], sub: siteLabelOf(ov, s), tone: 'muted' }
1106
+ }
1107
+ const last = scan && (scan.startedAt || scan.at)
1108
+ if (last) return { label: '上次扫描', value: fmtLocalHM(last), sub: '最近一次', tone: 'muted' }
1109
+ return { label: '下次计划', value: '—', sub: '暂时算不出下次', tone: 'muted' }
1110
+ }
1111
+
1040
1112
  function Overview(props) {
1041
1113
  const ov = props.ov
1042
1114
  /**
@@ -1060,6 +1132,9 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1060
1132
  const allS = React.useState(true)
1061
1133
  const showAll = allS[0]
1062
1134
  const setShowAll = allS[1]
1135
+ const allRef = React.useRef(null)
1136
+ const issuesRef = React.useRef(null)
1137
+ const changesRef = React.useRef(null)
1063
1138
  const rev = props.rev || revOf(ov)
1064
1139
  /**
1065
1140
  * ★ 2026-10-22(同日刷新):依赖**修订号**而不是 dataDate。
@@ -1094,15 +1169,15 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1094
1169
  id = setInterval(tick, 5000)
1095
1170
  return function () { alive = false; if (id) clearInterval(id) }
1096
1171
  }, [])
1097
- if (!ov) return h('div', { style: C.muted }, '加载中…')
1098
- const c = ov.counts || {}
1172
+ // 0.5.0:/overview 未到时不再整页「加载中…」——四张卡先占位「—」,版面不跳
1173
+ const c = (ov && ov.counts) || {}
1099
1174
  const total = (c.ok || 0) + (c.missing || 0) + (c.stale || 0) + (c.login_required || 0) + (c.truncated || 0)
1100
- const rows = (ov.sites || []).flatMap(function (s) { return (s.boards || []).map(function (b) { return { ...b, siteName: s.siteName } }) })
1175
+ const rows = ((ov && ov.sites) || []).flatMap(function (s) { return (s.boards || []).map(function (b) { return { ...b, siteName: s.siteName } }) })
1101
1176
 
1102
- const scan = ov.scan || null
1103
- const plan = (ov.services && ov.services.schedule) || null
1177
+ const scan = (ov && ov.scan) || null
1178
+ const plan = (ov && ov.services && ov.services.schedule) || null
1104
1179
  const staleIds = plan && plan.staleFlag
1105
- ? Object.keys(plan.staleFlag).filter(function (k) { return plan.staleFlag[k] && plan.staleFlag[k].date === ov.dataDate })
1180
+ ? Object.keys(plan.staleFlag).filter(function (k) { return plan.staleFlag[k] && plan.staleFlag[k].date === (ov && ov.dataDate) })
1106
1181
  : []
1107
1182
  /**
1108
1183
  * ★ Spec S3(2026-10-22):「未到计划」和「待补跑」不是失败。
@@ -1124,7 +1199,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1124
1199
  }
1125
1200
  const plannedTimeOf = function (b) {
1126
1201
  if (b.plannedTime) return String(b.plannedTime)
1127
- const times = (plan && plan.siteTimes) || (ov.defaults && ov.defaults.siteTimes) || {}
1202
+ const times = (plan && plan.siteTimes) || (ov && ov.defaults && ov.defaults.siteTimes) || {}
1128
1203
  return times[siteOfBoardId(b.boardId)] || ''
1129
1204
  }
1130
1205
  const waitingRows = rows.filter(function (b) { return scheduleStateOf(b) === 'waiting' })
@@ -1216,38 +1291,89 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1216
1291
  if (last && last.site === e.site) last.items.push(e)
1217
1292
  else shownBySite.push({ site: e.site, siteName: e.siteName, items: [e] })
1218
1293
  })
1294
+ const collectSub = [
1295
+ waitingRows.length ? '未到计划 ' + waitingRows.length : '',
1296
+ dueRows.length ? '待补跑 ' + dueRows.length : '',
1297
+ ].filter(Boolean).join(' · ')
1298
+ const collectSubText = collectSub || (badRows.length ? '有榜没抓到' : (ov && total > 0 && (c.ok || 0) === total ? '全部采集完成' : ''))
1299
+ const collectTone = badRows.length ? 'bad' : dueRows.length ? 'warn' : (ov && total > 0 && (c.ok || 0) === total ? 'ok' : 'muted')
1300
+ const issuesTone = !issues.length ? 'ok' : (issues.some(function (it) { return it.status !== 'stale' && it.status !== 'enrich' }) ? 'bad' : 'warn')
1301
+ const changesSub = Object.keys(chgTotals).slice(0, 2).map(function (g) { return g + ' ' + chgTotals[g] }).join(' · ')
1302
+ const nextPlan = nextPlanOf(plan, ov, scan, total)
1303
+ const noData = !!(ov && (c.ok || 0) === 0 && chgRealTotal === 0)
1304
+ const noChanges = !!(ov && (c.ok || 0) > 0 && chg && chgRealTotal === 0)
1305
+ const jump = function (ref) {
1306
+ const el = ref && ref.current
1307
+ if (el && typeof el.scrollIntoView === 'function') { try { el.scrollIntoView({ block: 'nearest' }) } catch (e) {} }
1308
+ }
1309
+ const goAll = function () {
1310
+ setShowAll(true)
1311
+ setTimeout(function () { jump(allRef) }, 0)
1312
+ }
1219
1313
  return h('div', null,
1220
- /* ① 摘要带:日期 + 采集/待处理(文字,不靠颜色) */
1221
- h('div', { style: C.row },
1222
- h('span', { title: '扫描开始时刻的本地自然日', style: { fontWeight: 600 } }, '数据日期 ' + dash(ov.dataDate)),
1223
- h('span', { style: C.muted }, '·'),
1224
- h('span', null, '已采集 ' + (c.ok || 0) + '/' + total),
1225
- waitingRows.length ? h('span', { style: C.muted, title: '这些站今天还没到自己的抓取时刻:不是失败' }, '· 未到计划 ' + waitingRows.length) : null,
1226
- dueRows.length ? h('span', { style: { color: T.warn }, title: '已过计划时刻但还没抓到:等兜底,或点「扫描已选榜」马上跑' }, '· 待补跑 ' + dueRows.length) : null,
1227
- h('span', { style: issues.length ? { color: T.warn, fontWeight: 600 } : { color: T.ok } },
1228
- issues.length ? '待处理 ' + issues.length + ' 项' : '无待处理'),
1229
- ov.hiddenCount ? h('span', { style: C.muted }, '· 未显示 ' + ov.hiddenCount + ' 个榜') : null),
1230
- /* ② 主动作:扫描(联网)与重新载入(只读本地)分开写清 */
1231
- h('div', { style: C.row },
1314
+ /* ① 数据日期小字 */
1315
+ h('div', { style: { ...C.muted, display: 'flex', gap: '6px', flexWrap: 'wrap', marginBottom: '6px' } },
1316
+ h('span', { title: '扫描开始时刻的本地自然日' }, '数据日期 ' + dash(ov && ov.dataDate)),
1317
+ ov && ov.hiddenCount ? h('span', null, '· 未显示 ' + ov.hiddenCount + ' 个榜') : null),
1318
+ /* ② 四张数字卡:先回答「今天怎么样」 */
1319
+ // 480px 面板内宽约 455px:140px 会挤成 3 列,180px 才能落到验收要求的 2×2
1320
+ h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(180px, 1fr))', gap: '8px' } },
1321
+ h(StatCard, {
1322
+ label: '已采集', value: ov ? (c.ok || 0) + '/' + total : '—',
1323
+ sub: ov ? (collectSubText || (total ? '—' : '还没有采集')) : '读取中', tone: collectTone,
1324
+ onClick: goAll, title: '展开全部榜单并滚到那里',
1325
+ }),
1326
+ h(StatCard, {
1327
+ label: '待处理', value: !ov ? '—' : (issues.length ? String(issues.length) : '无'),
1328
+ sub: !ov ? '读取中' : (issues.length ? '需要你动手' : '没有要处理的'), tone: !ov ? 'muted' : issuesTone,
1329
+ onClick: issues.length ? function () { jump(issuesRef) } : undefined,
1330
+ title: issues.length ? '滚到「需要处理」' : '当前没有问题',
1331
+ }),
1332
+ h(StatCard, {
1333
+ label: '今日变化', value: chg ? String(chgRealTotal) : '—',
1334
+ sub: !chg ? '读取中' : (changesSub || (chgRealTotal ? '' : '今天没有变化')),
1335
+ tone: chgRealTotal ? 'ok' : 'muted',
1336
+ onClick: chg ? function () { jump(changesRef) } : undefined,
1337
+ title: '滚到「今天的变化」',
1338
+ }),
1339
+ h(StatCard, {
1340
+ label: nextPlan.label, value: nextPlan.value, sub: nextPlan.sub, tone: nextPlan.tone,
1341
+ onClick: plan && plan.enabled === false && props.onOpenSettings ? props.onOpenSettings : undefined,
1342
+ title: plan && plan.enabled === false ? '定时已关闭,点这里去设置' : '下一次站点计划',
1343
+ })),
1344
+ /* ③ 主动作:扫描(联网)与重新载入(只读本地)分开写清 */
1345
+ h('div', { style: { ...C.row, marginTop: '8px' } },
1232
1346
  h('button', {
1233
1347
  className: 'rs-btn is-primary',
1234
- disabled: scanBusy,
1235
- title: '按「设置 → 抓取范围」里勾选的榜逐个扫描(会联网)',
1348
+ disabled: scanBusy || !ov || total === 0,
1349
+ title: total === 0 ? '还没有勾选要扫的榜,先去「设置 → 抓取范围」勾选' : '按「设置 → 抓取范围」里勾选的榜逐个扫描(联网)',
1236
1350
  onClick: function () { props.act('/scan') },
1237
1351
  }, scanBtnText),
1238
1352
  scanBusy ? h('button', { className: 'rs-btn is-danger', onClick: function () { props.act('/cancel') } }, '停止本次(保留已完成)') : null,
1239
- badRows.length ? h('button', { className: 'rs-btn', disabled: scanBusy, onClick: function () { props.act('/retry') } }, '重试失败 ' + badRows.length + ' 个榜') : null,
1353
+ badRows.length ? h('button', { className: 'rs-btn', disabled: scanBusy, onClick: function () { props.act('/retry') }, title: '只重试失败的榜(联网)' }, '重试失败 ' + badRows.length + ' 个榜') : null,
1240
1354
  h('button', { className: 'rs-btn is-ghost', onClick: props.reload, title: '只重新读取本地数据:不联网、不采集' }, '重新载入'),
1241
1355
  // 运行中不显示「上次 …」:那一轮还没结束,进度只放在主按钮一处(否则会同时出现两条「扫描中」)
1242
1356
  scanRunning ? null : h('span', { style: C.muted }, '上次 ' + scanLabel(scan))),
1243
- /* 补全进度:面板顶部只有这一条(三态:跑着 / 还能续跑 / 当日已试满) */
1357
+ /* ④ 需要处理:要用户动手的排后台补全前面 */
1358
+ issues.length ? h('div', { ref: issuesRef },
1359
+ h(Banner, { tone: issues.some(function (it) { return it.status !== 'stale' && it.status !== 'enrich' }) ? 'error' : 'warn', title: '需要处理' },
1360
+ h('div', { className: 'rs-banner-body', style: { display: 'flex', flexDirection: 'column', gap: '2px' } }, issues.map(function (it) {
1361
+ return h('div', { key: it.key, style: { ...C.row, alignItems: 'baseline' } },
1362
+ h('span', { style: C.dot(it.status === 'stale' || it.status === 'enrich' ? 'warn' : 'bad') }),
1363
+ h('span', { style: { fontWeight: 600 } }, it.name),
1364
+ it.at ? h('span', { style: C.muted }, fmtLocalHM(it.at)) : null,
1365
+ h('span', null, it.why),
1366
+ it.detail ? h('span', { style: C.muted }, '(' + String(it.detail).slice(0, 80) + ')') : null,
1367
+ it.boardId ? h('button', { className: 'rs-btn', disabled: props.busy, onClick: function () { props.onOpenBoard && props.onOpenBoard(it.boardId) }, title: '在「榜单」页打开这一榜(保上下文)' }, '查看本榜') : null,
1368
+ it.boardId ? h('button', { className: 'rs-btn', disabled: props.busy, onClick: function () { props.onRescanBoard && props.onRescanBoard(it.boardId) }, title: '只重扫这一榜(联网)' }, '重扫本榜') : null)
1369
+ })))) : null,
1370
+ /* ⑤ 补全进度:面板顶部只有这一条(三态:跑着 / 还能续跑 / 当日已试满) */
1244
1371
  (function () {
1245
1372
  if (!enrichStatus) return null
1246
1373
  const run = enrichStatus.enrichRun
1247
1374
  const active = !!(run && run.active === true)
1248
1375
  const left = typeof enrichStatus.pending === 'number' ? enrichStatus.pending : 0
1249
1376
  if (!active && !left) return null
1250
- // 「还能不能续跑」用宿主的 retryable 判(0 = 当日已试满),前端不自己猜
1251
1377
  const retryable = typeof enrichStatus.retryable === 'number' ? enrichStatus.retryable : null
1252
1378
  const label = active
1253
1379
  ? '补全中 ' + ((run && run.done) || 0) + '/' + ((run && run.total) || 0) + ' 个榜(可以先浏览,不用等)'
@@ -1256,27 +1382,16 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1256
1382
  : '补全未完成:还缺 ' + left + ' 个榜(后台会继续补,也可进榜点「补全缺失字段」)'
1257
1383
  return h(Banner, { tone: active ? 'info' : 'warn', live: false }, label)
1258
1384
  })(),
1259
- /* ③ 需要处理:仅有问题时出现 */
1260
- issues.length ? h(Banner, { tone: issues.some(function (it) { return it.status !== 'stale' && it.status !== 'enrich' }) ? 'error' : 'warn', title: '需要处理' },
1261
- h('div', { className: 'rs-banner-body', style: { display: 'flex', flexDirection: 'column', gap: '2px' } }, issues.map(function (it) {
1262
- /**
1263
- * Spec S5:一条问题要给「榜名 + 发生时间 + 影响 + 可执行动作」。
1264
- * 以前只有一个泛化「重试失败 N 个榜」,看不出是哪次尝试、也没法直接进榜看。
1265
- */
1266
- return h('div', { key: it.key, style: { ...C.row, alignItems: 'baseline' } },
1267
- h('span', { style: C.dot(it.status === 'stale' || it.status === 'enrich' ? 'warn' : 'bad') }),
1268
- h('span', { style: { fontWeight: 600 } }, it.name),
1269
- it.at ? h('span', { style: C.muted }, fmtLocalHM(it.at)) : null,
1270
- h('span', null, it.why),
1271
- it.detail ? h('span', { style: C.muted }, '(' + String(it.detail).slice(0, 80) + ')') : null,
1272
- it.boardId ? h('button', { className: 'rs-btn', disabled: props.busy, onClick: function () { props.onOpenBoard && props.onOpenBoard(it.boardId) }, title: '在「榜单」页打开这一榜(保上下文)' }, '查看本榜') : null,
1273
- it.boardId ? h('button', { className: 'rs-btn', disabled: props.busy, onClick: function () { props.onRescanBoard && props.onRescanBoard(it.boardId) }, title: '只重扫这一榜(会联网)' }, '重扫本榜') : null)
1274
- }))) : null,
1275
1385
  /* ④ 今天的变化 */
1276
- h('div', { style: C.siteBar }, '今天的变化' + (chgRealTotal ? '(' + chgRealTotal + ' 条)' : '')),
1386
+ h(SectionHeader, { innerRef: changesRef, title: '今天的变化', count: chgRealTotal ? chgRealTotal + ' 条' : '' }),
1277
1387
  chg && chg.note ? h('div', { style: C.muted }, chg.note) : null,
1278
1388
  previewLimited ? h('div', { style: C.muted }, '下表每榜每类最多列 20 条(本次 ' + chgEntries.length + ' 条,共 ' + chgRealTotal + ' 条);点行到榜页看全部。') : null,
1279
- chg && chg.count === 0 ? h('div', { style: C.muted }, '没有变化条目(或还没有可比基准)') : null,
1389
+ total === 0 ? h('div', { style: { ...C.row, alignItems: 'center' } },
1390
+ h('span', { style: C.muted }, '还没有勾选要扫的榜'),
1391
+ props.onOpenSettings ? h('button', { className: 'rs-btn is-ghost', onClick: props.onOpenSettings }, '去设置勾选') : null) : null,
1392
+ total === 0 ? null : noData ? h('div', { style: C.muted }, '今天还没有采集结果,到计划时刻会自动跑,也可以点「扫描已选榜」') : null,
1393
+ noChanges ? h('div', { style: C.muted }, '今天没有榜单变化') : null,
1394
+ ov && !chg && !noData ? h('div', { style: C.muted }, '正在读取今天的变化…') : null,
1280
1395
  chgEntries.length ? h('div', { style: C.row },
1281
1396
  [{ label: '全部', value: '' }].concat(groupNames.map(function (g) { return { label: g, value: g } })).map(function (o) {
1282
1397
  return h('button', {
@@ -1335,15 +1450,17 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1335
1450
  return [head].concat(body)
1336
1451
  })))) : null,
1337
1452
  /* ⑤ 全部榜单(可折叠) */
1338
- h('div', { style: { ...C.row, marginTop: '8px' } },
1339
- h('button', {
1453
+ h(SectionHeader, {
1454
+ innerRef: allRef, title: '全部榜单', count: total,
1455
+ action: h('button', {
1340
1456
  className: 'rs-btn is-ghost',
1341
1457
  'aria-expanded': showAll ? 'true' : 'false',
1342
1458
  onClick: function () { setShowAll(!showAll) },
1343
- }, (showAll ? '▾ ' : '▸ ') + '全部榜单(' + total + ')')),
1344
- showAll ? h('table', { style: C.table },
1459
+ }, showAll ? '收起' : '展开'),
1460
+ }),
1461
+ showAll && total > 0 ? h('table', { style: C.table },
1345
1462
  h('thead', null, h('tr', null, ['榜(按站)', '涨 / 新 / 退', '状态'].concat(hasNoteCol && !chgNarrow ? ['备注'] : []).map(function (t) { return h('th', { key: t, style: C.th }, t) }))),
1346
- h('tbody', null, (ov.sites || []).flatMap(function (s) {
1463
+ h('tbody', null, ((ov && ov.sites) || []).flatMap(function (s) {
1347
1464
  const okN = s.boards.filter(function (b) { return b.status === 'ok' }).length
1348
1465
  const times = s.boards.map(function (b) { return b.lastCapture ? fmtLocalHM(b.lastCapture) : '' })
1349
1466
  const sameTime = times.length > 0 && times.every(function (t) { return t === times[0] })
@@ -1448,7 +1565,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1448
1565
  * 设置页保存语义(0.4.1):
1449
1566
  * · 即时生效:只有「定时扫描」开关(乐观置位 + 失败回滚,结果走 Toast)。
1450
1567
  * · 草稿 + 底栏保存:抓取范围、自动补全、起点收藏补全、请求间隔、各站计划时刻、兜底时刻、保留天数。
1451
- * · 动作按钮(不是设置,点了就做):补全起点收藏、清空书页缓存、补齐该站缺失字段、复制诊断、检查更新;
1568
+ * · 动作按钮(不是设置,点了就做):补全起点收藏、清空书页缓存、补齐缺失(按站批量)、复制诊断、检查更新;
1452
1569
  * 保持原行为,结果走 Toast。
1453
1570
  */
1454
1571
  function SettingsTab(props) {
@@ -1796,9 +1913,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1796
1913
  h('span', { style: C.muted }, siteNameOf(s) + ' ' + pickedOf(s) + '/' + siteTotal(s)),
1797
1914
  h('button', { className: 'rs-btn is-ghost', onClick: function () { setAll(s, true) } }, '全选'),
1798
1915
  h('button', { className: 'rs-btn is-ghost', onClick: function () { setAll(s, false) } }, '全不选'),
1799
- h(PopMenu, { label: '更多', width: 190, items: [
1800
- { label: '补齐该站缺失字段', onClick: function () { enrichSite(s) }, title: '把该站已勾选的榜逐个补全(逐本 1 请求,很慢)' },
1801
- ] }))
1916
+ h('button', { className: 'rs-btn is-ghost', disabled: busy, onClick: function () { enrichSite(s) }, title: '把该站已勾选的榜逐个补全(联网:逐本 1 请求,很慢)' }, '补齐缺失'))
1802
1917
  })),
1803
1918
  groups.map(function (g) {
1804
1919
  const derived = g.items.length > 0 && String(g.items[0].boardId).indexOf('fanqie.derived.') === 0
@@ -1876,7 +1991,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
1876
1991
  h('span', { style: C.muted }, '起点收藏补全'),
1877
1992
  h('input', { type: 'checkbox', checked: qdEnrich, onChange: function (e) { setQdEnrich(e.target.checked); setBarNote('') } }),
1878
1993
  h('span', { style: C.muted }, qdEnrich ? '已开启' : '已关闭(默认关)'),
1879
- h('button', { className: 'rs-btn', disabled: busy, onClick: function () { setBusy(true); jpost('/qidianEnrich').then(function (r) { toast('success', (r && r.note) || '起点补全完成'); return refreshQd() }).catch(function (e) { toast('error', String(e)) }).then(function () { setBusy(false) }) } }, '补全起点收藏'),
1994
+ h('button', { className: 'rs-btn', disabled: busy, title: '补全起点收藏页缺失的字段(联网:逐本 1 请求)', onClick: function () { setBusy(true); jpost('/qidianEnrich').then(function (r) { toast('success', (r && r.note) || '起点补全完成'); return refreshQd() }).catch(function (e) { toast('error', String(e)) }).then(function () { setBusy(false) }) } }, '补全起点收藏'),
1880
1995
  h('button', { className: 'rs-btn', disabled: busy, onClick: function () { setBusy(true); jpost('/qidianCache', { clear: true }).then(function (r) { toast('success', (r && r.note) || '缓存已清'); return refreshQd() }).catch(function (e) { toast('error', String(e)) }).then(function () { setBusy(false) }) } }, '清空书页缓存')),
1881
1996
  h('div', { style: C.muted }, '起点书页缓存 ' + (qdCache && qdCache.cache ? qdCache.cache.books : 0) + ' 本 · 有效期 ' + ((qdCache && qdCache.ttlDays) || 7) + ' 天' +
1882
1997
  (cat.bookCache ? ' · 通用书页缓存 ' + ((cat.bookCache.stat && cat.bookCache.stat.entries) || 0) + ' 本 · 有效期 ' + (cat.bookCache.ttlDays || 7) + ' 天' : '')),
@@ -2510,8 +2625,10 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2510
2625
  const [depth, setDepth] = React.useState('')
2511
2626
  const [info, setInfo] = React.useState({ max: 100, can: true, hint: '' })
2512
2627
  const [busy, setBusy] = React.useState(false)
2628
+ const [scanning, setScanning] = React.useState(false)
2513
2629
  const [note, setNote] = React.useState(null)
2514
2630
  const [qDate, setQDate] = React.useState('')
2631
+ const [dayOpen, setDayOpen] = React.useState(false)
2515
2632
  /**
2516
2633
  * ★ Spec A/B(2026-10-24 审查):
2517
2634
  * · loadNonce —— 即使 sd/ss 本来就是空的,「回到最新」也必须真的重发一次 GET;
@@ -2594,9 +2711,15 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2594
2711
  h('select', { value: value, onChange: function (e) { onChange(e.target.value) }, style: C.input },
2595
2712
  options.map(function (o) { return h('option', { key: o.value, value: o.value }, o.label) })))
2596
2713
  }
2597
- const pickBoard = function (v) { sel.set({ board: v }); setBt(v); setSd(sel.pref(v, 'date')); setSs(sel.pref(v, 'sort')); setPick(null) }
2598
- const pickSite = function (v) { sel.set({ site: v, board: null }); setStSite(v); setBt(null); setSd(''); setSs(''); setPick(null) }
2714
+ const pickBoard = function (v) { sel.set({ board: v }); setBt(v); setSd(sel.pref(v, 'date')); setSs(sel.pref(v, 'sort')); setPick(null); setDayOpen(false) }
2715
+ const pickSite = function (v) { sel.set({ site: v, board: null }); setStSite(v); setBt(null); setSd(''); setSs(''); setPick(null); setDayOpen(false) }
2599
2716
  const pickDate = function (v) { setSd(v); sel.setPref(curBoard, 'date', v) }
2717
+ /** 「按上架日回看…」是动作项,不是日期值:不改当前选择,只在下面展开输入行 */
2718
+ const pickDateSel = function (v) {
2719
+ if (v === '__day') { setDayOpen(true); return }
2720
+ setDayOpen(false)
2721
+ pickDate(v)
2722
+ }
2600
2723
  const pickSort = function (v) { setSs(v); sel.setPref(curBoard, 'sort', v) }
2601
2724
  /** 只保存条数(**不采集**);另有一个明确的「保存并扫描本榜」 */
2602
2725
  const saveDepth = function (alsoScan) {
@@ -2605,40 +2728,62 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2605
2728
  setNote('正在保存每榜取数 ' + n + ' 条…')
2606
2729
  jpost('/depth', { boardId: curBoard, depth: n })
2607
2730
  .then(function (r) {
2608
- setNote((r && r.note) || ('已保存:每榜取 ' + n + ' 条'))
2731
+ setNote(null)
2732
+ toast('success', (r && r.note) || ('已保存:每榜取 ' + n + ' 条'))
2609
2733
  if (!alsoScan) return null
2734
+ setScanning(true)
2735
+ if (props.onScanStart) props.onScanStart()
2610
2736
  setNote('已保存 ' + n + ' 条,正在扫描本榜…')
2611
2737
  return jpost('/scan', { boards: curBoard }).then(function (rr) {
2612
2738
  const got = ((rr && rr.boards) || []).map(function (x) { return x.boardId + ' ' + x.rows + ' 条' }).join('')
2613
- setNote('已保存并扫描:' + (got || '完成'))
2614
- return reloadBoard(true)
2739
+ setNote(null)
2740
+ toast('success', '已保存并扫描:' + (got || '完成'))
2741
+ reloadBoard(true)
2742
+ if (props.onScanned) props.onScanned()
2615
2743
  }).catch(function (e2) {
2616
2744
  // ★ 保存成功、采集失败要**分开说**,否则用户会以为设置没存住、反复点
2617
- setNote('条数已保存,但扫描失败:' + e2 + '(可稍后重试扫描)')
2618
- })
2745
+ setNote(null)
2746
+ if (isScanBusyError(e2)) toast('warn', '已有扫描在进行,请等它跑完')
2747
+ else toast('error', '条数已保存,但扫描失败:' + e2 + '(可稍后重试扫描)')
2748
+ }).then(function () { if (props.onScanEnd) props.onScanEnd() })
2619
2749
  })
2620
- .catch(function (e) { setNote('保存失败:' + e) })
2621
- .then(function () { setBusy(false) })
2750
+ .catch(function (e) { setNote(null); toast('error', '保存失败:' + e) })
2751
+ .then(function () { setScanning(false); setBusy(false) })
2752
+ }
2753
+ /** 409 = 已有扫描(host 互斥):不是错误,用 warn 提醒等一下 */
2754
+ const isScanBusyError = function (e) {
2755
+ return !!(e && (e.status === 409 || e.code === 'scan_in_flight' || /409|已有扫描/.test(String(e))))
2756
+ }
2757
+ const toastScanError = function (e) {
2758
+ setNote(null)
2759
+ if (isScanBusyError(e)) { toast('warn', '已有扫描在进行,请等它跑完'); return }
2760
+ toast('error', '扫描失败:' + e)
2622
2761
  }
2623
2762
  const scanBoard = function () {
2763
+ if (props.scanBusy || busy) return
2764
+ if (props.onScanStart) props.onScanStart()
2624
2765
  setBusy(true)
2766
+ setScanning(true)
2625
2767
  setNote('正在扫描本榜…')
2626
2768
  jpost('/scan', { boards: curBoard })
2627
2769
  .then(function (rr) {
2628
2770
  const b0 = ((rr && rr.boards) || [])[0]
2629
- setNote(b0 ? '已扫描:' + b0.boardId + ' ' + b0.rows + ' 条' : '已扫描')
2630
- return reloadBoard(true)
2771
+ setNote(null)
2772
+ toast('success', b0 ? '已扫描:' + b0.boardId + ' ' + b0.rows + ' 条' : '已扫描')
2773
+ reloadBoard(true)
2774
+ if (props.onScanned) props.onScanned()
2631
2775
  })
2632
- .catch(function (e) { setNote('扫描失败:' + e) })
2633
- .then(function () { setBusy(false) })
2776
+ .catch(function (e) { toastScanError(e) })
2777
+ .then(function () { if (props.onScanEnd) props.onScanEnd(); setScanning(false); setBusy(false) })
2634
2778
  }
2635
2779
  const doEnrich = function () {
2636
2780
  setBusy(true)
2637
2781
  setNote('补全中(逐本请求 + ' + fmtIntervalText() + ',可能要几十秒)…')
2638
2782
  jpost('/enrich?boardId=' + encodeURIComponent(curBoard)).then(function (r) {
2639
- setNote(r && r.note ? r.note : '补全完成')
2783
+ setNote(null)
2784
+ toast('success', r && r.note ? r.note : '补全完成')
2640
2785
  return reloadBoard(true)
2641
- }).catch(function (e) { setNote('补全失败:' + e) }).then(function () { setBusy(false) })
2786
+ }).catch(function (e) { setNote(null); toast('error', '补全失败:' + e) }).then(function () { setBusy(false) })
2642
2787
  }
2643
2788
  /**
2644
2789
  * 按日期回看:只在**支持核对的榜**出现(能力驱动)。
@@ -2646,21 +2791,23 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2646
2791
  * 这里把两者分开写,不让用户以为选的是同一个日子。
2647
2792
  */
2648
2793
  const queryDay = function (save) {
2649
- if (!qDate) { setNote('先选上架日'); return }
2794
+ if (!qDate) { toast('warn', '先选上架日'); return }
2650
2795
  // ★ 上架日 X ⇒ 数据日期 X+1(首订按 n-1 锚;适配器 contentDateFor(数据日) = 数据日-1)
2651
2796
  const dDate = addDaysStr(qDate, 1)
2652
- if (!dDate) { setNote('日期格式不对:应为 YYYY-MM-DD'); return }
2797
+ if (!dDate) { toast('warn', '日期格式不对:应为 YYYY-MM-DD'); return }
2653
2798
  const my = ++loadSeqRef.current
2654
2799
  setBusy(true)
2655
2800
  setNote((save ? '抓取' : '查看') + '上架日 ' + qDate + '(数据日期 ' + dDate + ')…')
2656
2801
  jpost('/day', { boardId: curBoard, date: dDate, save: !!save }).then(function (r) {
2657
2802
  if (my !== loadSeqRef.current) return null
2658
2803
  if (r && (r.ok === false || r.code)) {
2659
- setNote('已拒绝:' + (r.error || '站点给不出这一天可核对的数据'))
2804
+ setNote(null)
2805
+ toast('warn', '已拒绝:' + (r.error || '站点给不出这一天可核对的数据'))
2660
2806
  return null
2661
2807
  }
2662
2808
  const shown = (r && r.date) || dDate
2663
- setNote(r && r.note ? r.note : (save ? '已抓取:上架日 ' + qDate + ' 存为数据日期 ' + dDate + ' 的快照' : '已查看(未落盘)'))
2809
+ setNote(null)
2810
+ toast('success', r && r.note ? r.note : (save ? '已抓取:上架日 ' + qDate + ' 存为数据日期 ' + dDate + ' 的快照' : '已查看(未落盘)'))
2664
2811
  if (save) { setDirectQ(null); setSd(shown); sel.setPref(curBoard, 'date', shown); setLoadNonce(function (n) { return n + 1 }); return null }
2665
2812
  /**
2666
2813
  * ★ Spec B(2026-10-24):直查视图是一份**独立**数据。
@@ -2695,7 +2842,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2695
2842
  _contentDate: (r && r.contentDate) || null,
2696
2843
  })
2697
2844
  setDirectQ({ date: shown })
2698
- }).catch(function (e) { setNote('直查失败:' + e) }).then(function () { setBusy(false) })
2845
+ }).catch(function (e) { setNote(null); toast('error', '直查失败:' + e) }).then(function () { setBusy(false) })
2699
2846
  }
2700
2847
  // Esc:先关详情卡(面板本身由 Panel 那层关)
2701
2848
  useEscLayer(pick ? function () { setPick(null); return true } : null)
@@ -2733,47 +2880,12 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2733
2880
  return bits.join(' · ')
2734
2881
  })()
2735
2882
  const enrichMissing = data && data.enrich && data.enrich.missing > 0 ? data.enrich.missing : 0
2883
+ const canDay = canDayQuery(curBoard)
2884
+ const dateOptsShown = canDay ? dateOpts.concat([{ value: '__day', label: '按上架日回看…' }]) : dateOpts
2736
2885
  // 减掉正文左右 padding(20)、纵向滚动条与一点余量 ⇒ 表格不会溢出成横向滚动
2737
2886
  const cols = fitColumns(data && data.columns, avail - 48)
2738
2887
  const viewDate = (data && (data._queryDate || sd)) || ''
2739
- const menuItems = [
2740
- { label: '扫描本榜(联网)', disabled: busy, onClick: scanBoard, title: '只抓当前这一榜,不动其它榜' },
2741
- { sep: true },
2742
- {
2743
- rows: h('div', null,
2744
- h('div', { style: { ...C.muted, marginBottom: '3px' } }, '每榜取多少条'),
2745
- h('div', { style: C.row },
2746
- h('input', {
2747
- type: 'number', min: 1, max: info.max, value: depth, placeholder: String(info.max), disabled: !info.can,
2748
- title: info.hint, onChange: function (e) { setDepth(e.target.value) },
2749
- style: { width: '58px', fontSize: '12px', padding: '2px 4px' },
2750
- }),
2751
- h('span', { style: C.muted }, info.can ? '条(上限 ' + info.max + ')' : '条 · ' + info.hint),
2752
- h('button', { className: 'rs-btn', disabled: !info.can || busy, onClick: function () { saveDepth(false) }, title: '只保存,下次扫描生效' }, '保存'),
2753
- h('button', { className: 'rs-btn', disabled: !info.can || busy, onClick: function () { saveDepth(true) }, title: '保存后立刻抓一次这一榜(会联网)' }, '保存并扫描本榜'))),
2754
- },
2755
- { sep: true },
2756
- {
2757
- label: enrichMissing ? '补全缺失字段(' + enrichMissing + ' 条)' : '补全缺失字段(当前没有待补)',
2758
- disabled: busy || !enrichMissing,
2759
- onClick: doEnrich,
2760
- title: '只补当前这一榜还没取到的字段(收藏/字数等),可能走书页缓存',
2761
- },
2762
- // 补全没跑完必须可见(别让「有行但字段空」静默)
2763
- enrichMissing ? { rows: h('div', { style: C.muted }, '补全未完成:还缺 ' + enrichMissing + ' 条(补全没跑完或被中断;点上面重试,或等定时续跑)') } : null,
2764
- ]
2765
- if (canDayQuery(curBoard)) {
2766
- menuItems.push({ sep: true })
2767
- menuItems.push({
2768
- rows: h('div', null,
2769
- h('div', { style: { ...C.muted, marginBottom: '3px' } }, '按上架日回看(仅本榜支持核对)'),
2770
- h('div', { style: C.row },
2771
- h('input', { type: 'date', value: qDate, onChange: function (e) { setQDate(e.target.value) }, style: { fontSize: '12px', padding: '2px 4px' } }),
2772
- h('button', { className: 'rs-btn', disabled: busy || !qDate, onClick: function () { queryDay(false) } }, '查看'),
2773
- h('button', { className: 'rs-btn', disabled: busy || !qDate, onClick: function () { queryDay(true) }, title: '抓取该上架日并存为本地快照(已有快照不覆盖)' }, '存入本地')),
2774
- h('div', { style: { ...C.muted, marginTop: '2px' } }, '首订按 n-1 锚:选上架日 X ⇒ 请求数据日期 X+1(页面内容日期就是 X);保存后快照记在 X+1 名下。站点给的日期对不上会被拒绝,不写任何文件。')),
2775
- })
2776
- }
2888
+ /* 0.4.2:本榜操作不再进「更多」——扫描/补全在操作条,条数在「本榜设置」,回看在日期行。 */
2777
2889
  /**
2778
2890
  * ★ 2026-10-23(窄面板「作品只显示书名前面的信息,后面一大片空白」):
2779
2891
  * 以前窄的时候是把次级列**整列删掉**、再让表格 width:100% 铺满 ⇒ 每行只剩名次 + 书名,
@@ -2867,18 +2979,43 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
2867
2979
  chips.length ? h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '4px', marginTop: '3px' } }, chips) : null)
2868
2980
  }
2869
2981
  return h('div', null,
2870
- h('div', { style: C.row },
2982
+ h('div', { style: { ...C.row, flexWrap: 'wrap' } },
2871
2983
  selXS('站', curSite || '', sites.map(function (s) { return { value: s.site, label: s.siteName } }), pickSite),
2872
2984
  selXS('榜', curBoard || '', curBoards.map(function (b) { return { value: b.boardId, label: b.name } }), pickBoard),
2873
- isDerived ? null : selXS('日期', sd, dateOpts, pickDate),
2874
- selXS('排序', ss, sortOpts, pickSort),
2875
- h(PopMenu, { label: '更多', items: menuItems, width: 260, title: '采集与详情(低频操作)' })),
2985
+ isDerived ? null : selXS('日期', sd, dateOptsShown, pickDateSel),
2986
+ selXS('排序', ss, sortOpts, pickSort)),
2987
+ dayOpen && canDay ? h('div', { style: { ...C.row, marginTop: '2px', flexWrap: 'wrap' } },
2988
+ h('span', { style: C.muted }, '上架日'),
2989
+ h('input', { type: 'date', value: qDate, onChange: function (e) { setQDate(e.target.value) }, style: { ...C.input, width: 'auto' } }),
2990
+ h('button', { className: 'rs-btn', disabled: busy || !qDate, onClick: function () { queryDay(false) }, title: '直查站点这一上架日的数据(联网,不落盘)' }, '查看'),
2991
+ h('button', { className: 'rs-btn', disabled: busy || !qDate, onClick: function () { queryDay(true) }, title: '抓取该上架日并存为本地快照(联网)' }, '存入本地'),
2992
+ h('button', { className: 'rs-btn is-ghost', onClick: function () { setDayOpen(false) } }, '收起'),
2993
+ h('div', { style: { ...C.muted, flex: '1 1 100%' } }, '首订按 n-1 锚:选上架日 X ⇒ 请求数据日期 X+1(页面内容日期就是 X);保存后快照记在 X+1 名下。站点给的日期对不上会被拒绝,不写任何文件。')) : null,
2994
+ h('div', { style: { ...C.row, marginTop: '4px', flexWrap: 'wrap' } },
2995
+ h('button', {
2996
+ className: 'rs-btn',
2997
+ disabled: props.scanBusy || busy,
2998
+ onClick: scanBoard,
2999
+ title: props.scanBusy ? '全局扫描进行中;请到概览点「停止本次」后再扫本榜' : '只抓当前这一榜,不动其它榜(联网)',
3000
+ }, scanning ? '扫描本榜中…' : (props.scanBusy ? '全局扫描进行中…' : '扫描本榜(联网)')),
3001
+ enrichMissing ? h('button', { className: 'rs-btn', disabled: busy || props.scanBusy, onClick: doEnrich, title: '补全当前榜缺失字段(联网:逐本进书页取,可能走缓存)' }, '补全缺失 ' + enrichMissing + ' 条') : null,
3002
+ h('span', { style: C.muted }, '只抓当前这一榜;全局扫描/停止在概览')),
3003
+ enrichMissing ? h(Banner, { tone: 'warn', live: false },
3004
+ h('span', null, '补全未完成:还缺 ' + enrichMissing + ' 条字段'),
3005
+ h('span', { style: C.muted }, '(榜页没给收藏/字数,要进书页取;点上面的「补全缺失」重试,或等定时续跑)')) : null,
3006
+ h(Section, { title: '本榜设置', defaultOpen: false, summary: '每榜 ' + (depth || info.max || '—') + ' 条(上限 ' + (info.max || '—') + ')' },
3007
+ h('div', { style: { ...C.row, flexWrap: 'wrap' } },
3008
+ h('span', { style: C.muted }, '每榜取多少条'),
3009
+ h('input', {
3010
+ type: 'number', min: 1, max: info.max, value: depth, placeholder: String(info.max), disabled: !info.can || busy,
3011
+ title: info.hint, onChange: function (e) { setDepth(e.target.value) },
3012
+ style: { ...C.input, width: '58px' },
3013
+ }),
3014
+ h('span', { style: C.muted }, info.can ? '条(上限 ' + info.max + ')' : '条 · ' + info.hint),
3015
+ h('button', { className: 'rs-btn', disabled: !info.can || busy, onClick: function () { saveDepth(false) }, title: '只保存,下次扫描生效' }, '保存'),
3016
+ h('button', { className: 'rs-btn', disabled: !info.can || busy || props.scanBusy, onClick: function () { saveDepth(true) }, title: '保存后立刻抓一次这一榜(联网)' }, '保存并扫描本榜')),
3017
+ info.hint ? h('div', { style: C.muted }, info.hint) : null),
2876
3018
  band ? h('div', { style: { ...C.muted, marginTop: '2px' } }, band) : null,
2877
- /* Spec 4.2:补全缺多少条要**就近可见**,别只藏在「更多」菜单里 */
2878
- enrichMissing ? h('div', { style: { ...C.row, marginTop: '2px' } },
2879
- h('span', { style: { color: T.warn } }, '补全未完成:还缺 ' + enrichMissing + ' 条字段'),
2880
- h('button', { className: 'rs-btn', disabled: busy, onClick: doEnrich }, '补全'),
2881
- h('span', { style: C.muted }, '(榜页没给收藏/字数,要进书页取;1 秒/本)')) : null,
2882
3019
  viewDate ? h(Banner, { tone: 'warn' },
2883
3020
  h('span', { style: { fontWeight: 600 } }, '正在查看历史:' + viewDate),
2884
3021
  h('span', { style: C.muted }, data && data._queryDate ? '(直查站点,未落盘)' : '(本地快照)'),
@@ -3021,6 +3158,14 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
3021
3158
  // label「扫榜面板」,重复啰嗦。改为**纯图标**:文字由宿主那行自己的 label 提供。
3022
3159
  }
3023
3160
 
3161
+ /**
3162
+ * 入口分工(0.4.2):
3163
+ * · 概览 = 全局扫描:主按钮「扫描已选榜」、运行中「停止本次」、有失败时「重试失败 N 个榜」;
3164
+ * 问题行里的「查看本榜 / 重扫本榜」保留,不增删。
3165
+ * · 榜单页 = 只对当前这一榜:扫描本榜、补全缺失、本榜设置、按上架日回看。
3166
+ * · 设置页 = 设置与按站批量动作(补齐缺失),不放单榜扫描。
3167
+ * 扫描忙态 scanBusy 由本层统一算,传给 BoardTab,避免榜单页和概览两处并发。
3168
+ */
3024
3169
  function Panel(props) {
3025
3170
  const [open, setOpen] = panelOpen.use()
3026
3171
  // 收起面板会卸载 Panel ⇒ 用持久化的 tab(否则每次打开都跳回「概览」)
@@ -3097,6 +3242,8 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
3097
3242
  /** act 的 then 里要读「此刻是否还在跑」,用 ref 拿最新值(闭包里的 scanLive 是旧渲染的) */
3098
3243
  const scanLiveRef = React.useRef(false)
3099
3244
  scanLiveRef.current = scanLive
3245
+ /** 全局扫描忙态:定时/手动在跑,或扫描类 POST 还在路上 */
3246
+ const scanBusy = scanLive || scanActBusy
3100
3247
  React.useEffect(function () {
3101
3248
  if (!open) return undefined
3102
3249
  if (polledOnce.current) reload()
@@ -3185,8 +3332,14 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
3185
3332
  scanStarting: scanActBusy && !scanLive,
3186
3333
  onOpenBoard: openBoard,
3187
3334
  onRescanBoard: function (boardId) { act('/scan', { boards: String(boardId) }) },
3335
+ onOpenSettings: function () { switchTab('pick') },
3188
3336
  })
3189
- : tab === 'board' ? h(BoardTab, { ov: ov, openLink: props.openLink, narrow: narrow, width: rect.w, rev: rev })
3337
+ : tab === 'board' ? h(BoardTab, {
3338
+ ov: ov, openLink: props.openLink, narrow: narrow, width: rect.w, rev: rev, scanBusy: scanBusy,
3339
+ onScanned: reload,
3340
+ onScanStart: function () { postInFlightRef.current += 1; setScanActBusy(true) },
3341
+ onScanEnd: function () { postInFlightRef.current = Math.max(0, postInFlightRef.current - 1); if (!scanLiveRef.current && postInFlightRef.current === 0) setScanActBusy(false) },
3342
+ })
3190
3343
  : tab === 'bm' ? h(BookmarksTab, { openLink: props.openLink })
3191
3344
  : h(SettingsTab, { ov: ov, onSaved: reload }))),
3192
3345
  h(ToastHost, null),
@@ -3309,7 +3462,8 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
3309
3462
  return { name: 'dsh-rank-scan', inject: inject, apply: apply, __test: {
3310
3463
  metricChipText: metricChipText,
3311
3464
  helpers: { revOf: revOf, statusText: statusText, scanLabel: scanLabel, pollDelay: pollDelay, canDayQuery: canDayQuery, fitColumns: fitColumns, colPrio: colPrio, mdOf: mdOf, boardLabel: boardLabel, rememberBoardNames: rememberBoardNames },
3312
- components: { Overview: Overview, BoardTab: BoardTab, BookmarksTab: BookmarksTab, SettingsTab: SettingsTab, PopMenu: PopMenu, Panel: Panel, ToastHost: ToastHost },
3465
+ components: { Overview: Overview, BoardTab: BoardTab, BookmarksTab: BookmarksTab, SettingsTab: SettingsTab, PopMenu: PopMenu, Panel: Panel, ToastHost: ToastHost, StatCard: StatCard, SectionHeader: SectionHeader },
3466
+ nextPlanOf: nextPlanOf,
3313
3467
  toast: toast, toastStore: toastStore, lastNote: lastNote, settingsDiff: settingsDiff,
3314
3468
  } }
3315
3469
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-rank-scan",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "DSH 扫榜插件:多站小说榜单采集 + 本地变化分析 + 面板;零运行时依赖",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",