dsh-rank-scan 0.5.1 → 0.5.2
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.
- package/README.md +3 -3
- package/lib/client.js +171 -22
- package/lib/index.js +13 -7
- package/lib/index.js.map +1 -1
- package/lib/scan/view.js +11 -0
- package/lib/scan/view.js.map +1 -1
- package/lib/types/scan/view.d.ts +8 -0
- 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.5.
|
|
21
|
+
# 钉版本:github:kilo-s/dsh-rank-scan#v0.5.2
|
|
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.5.
|
|
40
|
+
# 钉版本:dsh-rank-scan@0.5.2
|
|
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.5.
|
|
47
|
+
**更新**:重跑安装命令即可(链接直装取最新 `main`,registry 装取最新发布版;本版本为 **0.5.2**);面板「设置」页底部会读 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
|
@@ -232,6 +232,12 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
232
232
|
'.rs-toast-x:focus-visible{outline:2px solid ' + T.accent + ';outline-offset:1px}',
|
|
233
233
|
'[data-rank-scan-win] tbody tr:hover td{background:' + T.subtle + '}',
|
|
234
234
|
'[data-rank-scan-win] a:focus-visible{outline:2px solid ' + T.accent + ';outline-offset:1px}',
|
|
235
|
+
'.rs-th-sort{border:none;background:transparent;padding:0;font:inherit;font-weight:600;cursor:pointer;color:inherit;display:inline-flex;align-items:center;gap:3px}',
|
|
236
|
+
'.rs-th-sort:focus-visible{outline:2px solid ' + T.accent + ';outline-offset:1px}',
|
|
237
|
+
'.rs-sort-arrow{opacity:0;color:' + T.muted + ';font-size:10px;line-height:1}',
|
|
238
|
+
'.rs-th-sort:hover .rs-sort-arrow,.rs-th-sort:focus-visible .rs-sort-arrow{opacity:1}',
|
|
239
|
+
'.rs-sort-arrow.is-on{opacity:1;color:' + T.accent + ';font-weight:600}',
|
|
240
|
+
'[data-rank-scan-win] [data-row-idx]:focus-visible{outline:2px solid ' + T.accent + ';outline-offset:-2px}',
|
|
235
241
|
].join('\n')
|
|
236
242
|
document.head.appendChild(el)
|
|
237
243
|
}
|
|
@@ -2654,6 +2660,52 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2654
2660
|
* 70-board.js:榜单页:BoardTab(选择器、详情、操作条、本榜设置、日期回看)。依赖 20/55。不要放 Panel。
|
|
2655
2661
|
* 这个文件是同一闭包里的连续片段;顶层执行顺序由文件名排序保证。
|
|
2656
2662
|
*/
|
|
2663
|
+
/**
|
|
2664
|
+
* 第六步(0.5.2):榜单表头的排序 / 行键盘用的纯函数。
|
|
2665
|
+
* 只消费宿主已经给出的 columns / sortOptions,不做客户端排序,也不新增排序方式。
|
|
2666
|
+
*/
|
|
2667
|
+
const sortableCols = function (cols, sortOptions, defKey, defDir) {
|
|
2668
|
+
const values = (sortOptions || []).map(function (o) { return o && o.value }).filter(function (v) { return !!v })
|
|
2669
|
+
return (cols || []).filter(function (c) {
|
|
2670
|
+
return c && (values.indexOf(c.key) >= 0 || (!!defKey && c.key === defKey))
|
|
2671
|
+
}).map(function (c) {
|
|
2672
|
+
return { key: c.key, dir: c.key === defKey ? (defDir || 'descending') : 'descending' }
|
|
2673
|
+
})
|
|
2674
|
+
}
|
|
2675
|
+
const nextSort = function (cur, key, defKey) {
|
|
2676
|
+
if (key === defKey) return ''
|
|
2677
|
+
return cur === key ? '' : key
|
|
2678
|
+
}
|
|
2679
|
+
const normalizeSortPref = function (v) { return v === 'rank' ? '' : (v || '') }
|
|
2680
|
+
/** 只给行号,详情行不参与;n 是数据行数量 */
|
|
2681
|
+
const nextRowIdx = function (i, key, n) {
|
|
2682
|
+
const last = Math.max(0, Number(n) - 1)
|
|
2683
|
+
if (key === 'ArrowDown') return Math.min(last, i + 1)
|
|
2684
|
+
if (key === 'ArrowUp') return Math.max(0, i - 1)
|
|
2685
|
+
if (key === 'Home') return 0
|
|
2686
|
+
if (key === 'End') return last
|
|
2687
|
+
return null
|
|
2688
|
+
}
|
|
2689
|
+
const isRowControl = function (t) {
|
|
2690
|
+
if (!t || !t.tagName) return false
|
|
2691
|
+
const tag = String(t.tagName).toLowerCase()
|
|
2692
|
+
if (tag === 'a' || tag === 'button' || tag === 'input' || tag === 'textarea' || tag === 'select') return true
|
|
2693
|
+
if (t.isContentEditable === true) return true
|
|
2694
|
+
return !!(t.closest && t.closest('a,button,input,textarea,select,[contenteditable="true"]'))
|
|
2695
|
+
}
|
|
2696
|
+
const copyLink = function (url) {
|
|
2697
|
+
const text = url || ''
|
|
2698
|
+
const fail = function () { toast('warn', '复制链接失败,请手动复制:' + (text || '—')) }
|
|
2699
|
+
if (typeof navigator === 'undefined' || !navigator.clipboard || typeof navigator.clipboard.writeText !== 'function') {
|
|
2700
|
+
fail(); return
|
|
2701
|
+
}
|
|
2702
|
+
try {
|
|
2703
|
+
navigator.clipboard.writeText(text).then(function () { toast('success', '已复制链接') }).catch(fail)
|
|
2704
|
+
} catch (e) { fail() }
|
|
2705
|
+
}
|
|
2706
|
+
// 离线测试缝:只暴露第六步的纯函数,不改变运行路径
|
|
2707
|
+
window.__rankScanBoardTableTest = { sortableCols: sortableCols, nextSort: nextSort, nextRowIdx: nextRowIdx, normalizeSortPref: normalizeSortPref }
|
|
2708
|
+
|
|
2657
2709
|
function BoardTab(props) {
|
|
2658
2710
|
const ov = props.ov
|
|
2659
2711
|
/**
|
|
@@ -2666,9 +2718,15 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2666
2718
|
const sites = (ov && ov.sites) || []
|
|
2667
2719
|
// 收起面板会卸载 BoardTab ⇒ 站/榜选择要持久化;日期/排序按榜各记各的
|
|
2668
2720
|
const [stSite, setStSite] = React.useState(function () { return sel.get().site })
|
|
2721
|
+
const sortPref = function (board) {
|
|
2722
|
+
const raw = sel.pref(board, 'sort')
|
|
2723
|
+
const v = normalizeSortPref(raw)
|
|
2724
|
+
if (v !== raw) sel.setPref(board, 'sort', v)
|
|
2725
|
+
return v
|
|
2726
|
+
}
|
|
2669
2727
|
const [bt, setBt] = React.useState(function () { return sel.get().board })
|
|
2670
2728
|
const [sd, setSd] = React.useState(function () { return sel.pref(sel.get().board, 'date') })
|
|
2671
|
-
const [ss, setSs] = React.useState(function () { return
|
|
2729
|
+
const [ss, setSs] = React.useState(function () { return sortPref(sel.get().board) })
|
|
2672
2730
|
const [data, setData] = React.useState(null)
|
|
2673
2731
|
const [err, setErr] = React.useState(null)
|
|
2674
2732
|
const [pick, setPick] = React.useState(null)
|
|
@@ -2691,6 +2749,10 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2691
2749
|
// 读取序号:只有最后一次发起的请求允许写界面(防旧响应覆盖)
|
|
2692
2750
|
const loadSeqRef = React.useRef(0)
|
|
2693
2751
|
const catSeqRef = React.useRef(0)
|
|
2752
|
+
const listRef = React.useRef(null)
|
|
2753
|
+
const sortJumpRef = React.useRef(false)
|
|
2754
|
+
const pickIdxRef = React.useRef(null)
|
|
2755
|
+
const focusBackRef = React.useRef(null)
|
|
2694
2756
|
const curSite = stSite || (sites[0] && sites[0].site)
|
|
2695
2757
|
const curBoards = ((sites.filter(function (s) { return s.site === curSite })[0] || {}).boards) || []
|
|
2696
2758
|
const curBoard = bt || (curBoards[0] && curBoards[0].boardId)
|
|
@@ -2761,7 +2823,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2761
2823
|
h('select', { value: value, onChange: function (e) { onChange(e.target.value) }, style: C.input },
|
|
2762
2824
|
options.map(function (o) { return h('option', { key: o.value, value: o.value }, o.label) })))
|
|
2763
2825
|
}
|
|
2764
|
-
const pickBoard = function (v) { sel.set({ board: v }); setBt(v); setSd(sel.pref(v, 'date')); setSs(
|
|
2826
|
+
const pickBoard = function (v) { sel.set({ board: v }); setBt(v); setSd(sel.pref(v, 'date')); setSs(sortPref(v)); setPick(null); setDayOpen(false) }
|
|
2765
2827
|
const pickSite = function (v) { sel.set({ site: v, board: null }); setStSite(v); setBt(null); setSd(''); setSs(''); setPick(null); setDayOpen(false) }
|
|
2766
2828
|
const pickDate = function (v) { setSd(v); sel.setPref(curBoard, 'date', v) }
|
|
2767
2829
|
/** 「按上架日回看…」是动作项,不是日期值:不改当前选择,只在下面展开输入行 */
|
|
@@ -2770,7 +2832,57 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2770
2832
|
setDayOpen(false)
|
|
2771
2833
|
pickDate(v)
|
|
2772
2834
|
}
|
|
2773
|
-
const pickSort = function (v) {
|
|
2835
|
+
const pickSort = function (v) {
|
|
2836
|
+
if (v === ss) return
|
|
2837
|
+
setSs(v)
|
|
2838
|
+
sel.setPref(curBoard, 'sort', v)
|
|
2839
|
+
setPick(null) // 换排序 ⇒ 收起详情,避免详情还停在旧行
|
|
2840
|
+
pickIdxRef.current = null
|
|
2841
|
+
sortJumpRef.current = true
|
|
2842
|
+
}
|
|
2843
|
+
const closeDetail = function () {
|
|
2844
|
+
const idx = pickIdxRef.current
|
|
2845
|
+
setPick(null)
|
|
2846
|
+
if (idx != null) focusBackRef.current = idx
|
|
2847
|
+
}
|
|
2848
|
+
const toggleRow = function (r, i) {
|
|
2849
|
+
const opening = !(pick && pick.key === r.key)
|
|
2850
|
+
pickIdxRef.current = i
|
|
2851
|
+
if (!opening) focusBackRef.current = null
|
|
2852
|
+
setPick(opening ? r : null)
|
|
2853
|
+
}
|
|
2854
|
+
const onRowsKeyDown = function (e) {
|
|
2855
|
+
if (!e) return
|
|
2856
|
+
if (isRowControl(e.target)) return
|
|
2857
|
+
const row = e.target && e.target.closest ? e.target.closest('[data-row-idx]') : null
|
|
2858
|
+
if (!row || !e.currentTarget || !e.currentTarget.querySelectorAll) return
|
|
2859
|
+
const rows = e.currentTarget.querySelectorAll('[data-row-idx]')
|
|
2860
|
+
const i = Number(row.getAttribute('data-row-idx'))
|
|
2861
|
+
const next = nextRowIdx(i, e.key, rows.length)
|
|
2862
|
+
if (next == null) return
|
|
2863
|
+
e.preventDefault()
|
|
2864
|
+
const el = rows[next]
|
|
2865
|
+
if (!el) return
|
|
2866
|
+
try { el.focus({ preventScroll: true }) } catch (err) { try { el.focus() } catch (e2) {} }
|
|
2867
|
+
if (el.scrollIntoView) el.scrollIntoView({ block: 'nearest' })
|
|
2868
|
+
}
|
|
2869
|
+
React.useEffect(function () {
|
|
2870
|
+
if (!sortJumpRef.current) return
|
|
2871
|
+
sortJumpRef.current = false
|
|
2872
|
+
const el = listRef.current
|
|
2873
|
+
if (el && el.scrollIntoView) {
|
|
2874
|
+
try { el.scrollIntoView({ block: 'start' }) } catch (e) {}
|
|
2875
|
+
}
|
|
2876
|
+
}, [ss])
|
|
2877
|
+
React.useEffect(function () {
|
|
2878
|
+
if (pick || focusBackRef.current == null) return
|
|
2879
|
+
const idx = focusBackRef.current
|
|
2880
|
+
focusBackRef.current = null
|
|
2881
|
+
const el = listRef.current && listRef.current.querySelector('[data-row-idx="' + idx + '"]')
|
|
2882
|
+
if (!el) return
|
|
2883
|
+
try { el.focus({ preventScroll: true }) } catch (e) { try { el.focus() } catch (e2) {} }
|
|
2884
|
+
if (el.scrollIntoView) el.scrollIntoView({ block: 'nearest' })
|
|
2885
|
+
}, [pick])
|
|
2774
2886
|
/** 只保存条数(**不采集**);另有一个明确的「保存并扫描本榜」 */
|
|
2775
2887
|
const saveDepth = function (alsoScan) {
|
|
2776
2888
|
const n = Math.max(1, Math.min(info.max || 100, Number(depth) || 10))
|
|
@@ -2877,6 +2989,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2877
2989
|
boardId: curBoard,
|
|
2878
2990
|
columns: prev.columns || [],
|
|
2879
2991
|
sortOptions: prev.sortOptions || [],
|
|
2992
|
+
defaultSortKey: (r && r.defaultSortKey) || null,
|
|
2880
2993
|
rows: (r.rowsAll || []).map(function (x) { return { ...x, delta: null, days: null } }),
|
|
2881
2994
|
dates: ds,
|
|
2882
2995
|
dataDate: shown,
|
|
@@ -2895,7 +3008,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2895
3008
|
}).catch(function (e) { setNote(null); toast('error', '直查失败:' + e) }).then(function () { setBusy(false) })
|
|
2896
3009
|
}
|
|
2897
3010
|
// Esc:先关详情卡(面板本身由 Panel 那层关)
|
|
2898
|
-
useEscLayer(pick ? function () {
|
|
3011
|
+
useEscLayer(pick ? function () { closeDetail(); return true } : null)
|
|
2899
3012
|
/** 状态带:一行说清「你在看哪份数据、跟哪天比」 */
|
|
2900
3013
|
const band = (function () {
|
|
2901
3014
|
if (!data) return null
|
|
@@ -2934,6 +3047,12 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2934
3047
|
const dateOptsShown = canDay ? dateOpts.concat([{ value: '__day', label: '按上架日回看…' }]) : dateOpts
|
|
2935
3048
|
// 减掉正文左右 padding(20)、纵向滚动条与一点余量 ⇒ 表格不会溢出成横向滚动
|
|
2936
3049
|
const cols = fitColumns(data && data.columns, avail - 48)
|
|
3050
|
+
const defaultSort = (data && data.defaultSortKey && data.defaultSortKey.key)
|
|
3051
|
+
? data.defaultSortKey
|
|
3052
|
+
: { key: 'rank', dir: 'ascending' }
|
|
3053
|
+
const sortable = sortableCols(cols, sortOpts, defaultSort.key, defaultSort.dir)
|
|
3054
|
+
const sortableMap = {}
|
|
3055
|
+
sortable.forEach(function (c) { sortableMap[c.key] = c.dir })
|
|
2937
3056
|
const viewDate = (data && (data._queryDate || sd)) || ''
|
|
2938
3057
|
/* 0.4.2:本榜操作不再进「更多」——扫描/补全在操作条,条数在「本榜设置」,回看在日期行。 */
|
|
2939
3058
|
/**
|
|
@@ -2973,7 +3092,7 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2973
3092
|
*/
|
|
2974
3093
|
const detailCard = function (r) {
|
|
2975
3094
|
const ex = r.extra || {}
|
|
2976
|
-
return h('div', { style: { ...C.detail, marginTop: '4px' } },
|
|
3095
|
+
return h('div', { style: { ...C.detail, marginTop: '4px', boxShadow: 'inset 3px 0 0 ' + T.accent } },
|
|
2977
3096
|
h('div', { style: { fontWeight: 600 } }, dash(r.title)),
|
|
2978
3097
|
h('div', { style: C.muted }, '作者 ' + dash(r.author) + ' · 名次 ' + dash(r.rank) + ' · 字数 ' + fmtWords(ex.wordsText || ex.wordsCnt || ex.wordNumber || ex.words)),
|
|
2979
3098
|
h('div', { style: C.muted }, '更新 ' + fmtTime(ex.lastChapterUpdateTime)),
|
|
@@ -2984,10 +3103,10 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
2984
3103
|
h('div', { style: C.row },
|
|
2985
3104
|
h(BookmarkStar, { bookKey: bookKeyOf(curBoard, r.key), row: r, boardId: curBoard, dataDate: data && data.dataDate }),
|
|
2986
3105
|
h(DetailBookmarkEditor, { bookKey: bookKeyOf(curBoard, r.key) }),
|
|
2987
|
-
h('button', { className: 'rs-btn', onClick: function (e) { e.stopPropagation(); if (props.openLink) props.openLink(r.url); else window.open(r.url, '_blank', 'noopener,noreferrer') } }, '在 DSH 侧栏浏览器打开'),
|
|
3106
|
+
h('button', { className: 'rs-btn is-primary', onClick: function (e) { e.stopPropagation(); if (props.openLink) props.openLink(r.url); else window.open(r.url, '_blank', 'noopener,noreferrer') } }, '在 DSH 侧栏浏览器打开'),
|
|
3107
|
+
h('button', { className: 'rs-btn', onClick: function (e) { e.stopPropagation(); copyLink(r.url) } }, '复制链接'),
|
|
2988
3108
|
h('a', { href: r.url || '#', target: '_blank', rel: 'noreferrer', style: { color: 'inherit', padding: '3px 8px' }, onClick: function (e) { e.stopPropagation() } }, '新标签打开'),
|
|
2989
|
-
h('button', { className: 'rs-btn', onClick: function (e) { e.stopPropagation();
|
|
2990
|
-
h('button', { className: 'rs-btn', onClick: function (e) { e.stopPropagation(); setPick(null) } }, '关闭')),
|
|
3109
|
+
h('button', { className: 'rs-btn is-ghost', style: { marginLeft: 'auto' }, onClick: function (e) { e.stopPropagation(); closeDetail() } }, '关闭')),
|
|
2991
3110
|
ex.qidiantuUrl || ex.sourceUrl
|
|
2992
3111
|
? h('div', { style: C.row },
|
|
2993
3112
|
(ex.qidiantuUrl ? h('button', { className: 'rs-btn', onClick: function (e) { e.stopPropagation(); (props.openLink || window.open)(ex.qidiantuUrl) } }, '看起点图原始页') : null),
|
|
@@ -3011,11 +3130,17 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
3011
3130
|
return h('div', {
|
|
3012
3131
|
key: r.key || ('row' + i),
|
|
3013
3132
|
tabIndex: 0,
|
|
3133
|
+
'data-row-idx': i,
|
|
3134
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
3014
3135
|
style: { ...C.card, padding: '5px 8px', margin: '5px 0', cursor: 'pointer',
|
|
3015
3136
|
borderColor: open ? T.border : undefined,
|
|
3016
|
-
background: open ? T.subtle : undefined
|
|
3017
|
-
|
|
3018
|
-
|
|
3137
|
+
background: open ? T.subtle : undefined,
|
|
3138
|
+
boxShadow: open ? 'inset 3px 0 0 ' + T.accent : undefined },
|
|
3139
|
+
onClick: function () { toggleRow(r, i) },
|
|
3140
|
+
onKeyDown: function (e) {
|
|
3141
|
+
if (!e || isRowControl(e.target)) return
|
|
3142
|
+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggleRow(r, i) }
|
|
3143
|
+
},
|
|
3019
3144
|
},
|
|
3020
3145
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: '5px', minWidth: 0 } },
|
|
3021
3146
|
h('span', { style: { ...C.num, ...C.muted, flex: '0 0 auto', minWidth: '16px', textAlign: 'right' } }, dash(r.rank)),
|
|
@@ -3093,29 +3218,53 @@ const LS_OPEN = 'rank-scan-panel:open:v1'
|
|
|
3093
3218
|
note ? h('div', { style: C.muted }, note) : null,
|
|
3094
3219
|
data && data.rows && data.rows.length
|
|
3095
3220
|
? (cards
|
|
3096
|
-
? h('div',
|
|
3221
|
+
? h('div', { ref: listRef, onKeyDown: onRowsKeyDown }, data.rows.map(function (r, i) {
|
|
3097
3222
|
// 卡片行 + 展开时紧跟其后的详情卡(详情别再挂到列表末尾)
|
|
3098
3223
|
return h('div', { key: 'w' + (r.key || i) }, narrowRow(r, i), isOpen(r) ? detailCard(r) : null)
|
|
3099
3224
|
}))
|
|
3100
|
-
: h('table', { style: C.table },
|
|
3101
|
-
h('thead', null, h('tr', null, cols.map(function (c) {
|
|
3102
|
-
|
|
3225
|
+
: h('table', { ref: listRef, style: C.table },
|
|
3226
|
+
h('thead', null, h('tr', null, cols.map(function (c) {
|
|
3227
|
+
const dir = sortableMap[c.key]
|
|
3228
|
+
const active = (ss || defaultSort.key) === c.key
|
|
3229
|
+
const shownDir = active ? (ss ? dir : defaultSort.dir) : dir
|
|
3230
|
+
return h('th', {
|
|
3231
|
+
key: c.key, style: C.th, title: c.note || '',
|
|
3232
|
+
'aria-sort': active ? shownDir : undefined,
|
|
3233
|
+
}, dir
|
|
3234
|
+
? h('button', {
|
|
3235
|
+
className: 'rs-th-sort',
|
|
3236
|
+
title: active && !ss ? '当前为默认排序' : active ? '取消按 ' + c.label + ' 排序' : '按 ' + c.label + ' 排序',
|
|
3237
|
+
onClick: function (e) { e.stopPropagation(); pickSort(nextSort(ss, c.key, defaultSort.key)) },
|
|
3238
|
+
}, c.label, h('span', { className: 'rs-sort-arrow' + (active ? ' is-on' : ''), 'aria-hidden': 'true' }, shownDir === 'ascending' ? '↑' : '↓'))
|
|
3239
|
+
: c.label)
|
|
3240
|
+
}))),
|
|
3241
|
+
h('tbody', { onKeyDown: onRowsKeyDown }, data.rows.flatMap(function (r, i) {
|
|
3242
|
+
const open = isOpen(r)
|
|
3103
3243
|
const tr = h('tr', {
|
|
3104
3244
|
key: r.key || i,
|
|
3105
3245
|
tabIndex: 0,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3246
|
+
'data-row-idx': i,
|
|
3247
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
3248
|
+
style: { cursor: 'pointer', background: open ? T.subtle : undefined },
|
|
3249
|
+
onClick: function () { toggleRow(r, i) },
|
|
3250
|
+
onKeyDown: function (e) {
|
|
3251
|
+
if (!e || isRowControl(e.target)) return
|
|
3252
|
+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggleRow(r, i) }
|
|
3253
|
+
},
|
|
3254
|
+
}, cols.map(function (c, ci) {
|
|
3255
|
+
const baseStyle = isNumCol(c.key) ? { ...C.td, ...C.num } : C.td
|
|
3256
|
+
const style = open && ci === 0 ? { ...baseStyle, boxShadow: 'inset 3px 0 0 ' + T.accent } : baseStyle
|
|
3257
|
+
return h('td', { key: c.key, style }, cell(rowCellProps(r, c), r))
|
|
3111
3258
|
}))
|
|
3112
3259
|
// 详情卡作为紧跟那一行的一行(colSpan 占满),点哪一行就在哪一行下面展开
|
|
3113
|
-
return
|
|
3260
|
+
return open
|
|
3114
3261
|
? [tr, h('tr', { key: 'd' + (r.key || i) }, h('td', { colSpan: Math.max(1, cols.length), style: { padding: '0 0 4px' } }, detailCard(r)))]
|
|
3115
3262
|
: [tr]
|
|
3116
3263
|
}))))
|
|
3117
3264
|
: h('div', { style: C.muted }, data ? dash(data.note || '没有条目') : '加载中…'),
|
|
3118
|
-
h('
|
|
3265
|
+
h('details', { style: { ...C.muted, marginTop: '6px' } },
|
|
3266
|
+
h('summary', { style: { cursor: 'pointer' } }, '列说明'),
|
|
3267
|
+
h('div', { style: { marginTop: '3px' } }, '列随榜变化:该站没有的字段整列不出现;有字段但这条没抓到显示「—」(批次榜不出「变化」列)。面板变窄时列会按宽度自动收起(先收作者/分类/字数这类次级列,名次/书名与该榜主指标一直在),再窄就换成卡片行;点行看详情。')))
|
|
3119
3268
|
}
|
|
3120
3269
|
|
|
3121
3270
|
/**
|
package/lib/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import { FANQIE_MALE } from './sites/fanqie.js';
|
|
|
21
21
|
import { CATEGORIES as QIDIAN_CATEGORIES } from './sites/qidian-mobile.js';
|
|
22
22
|
import { deriveFanqieViews } from './scan/derive.js';
|
|
23
23
|
import { decodePua, hasPua, learnPair, loadFontMap, saveFontMap } from './scan/fontmap.js';
|
|
24
|
-
import { applyColumnPolicy, batchKeyOf, batchKindOf, batchLabelOf, boardMeta, columnsFor, compareDesc, defaultSortFor, enrichAttemptPolicy, enrichMissingCount, groupBySite, groupChanges, isBatchBoard, isEnrichableBoard, saleRangeOf, shouldShowDays, usesRankDelta, withFanqieCat } from './scan/view.js';
|
|
24
|
+
import { applyColumnPolicy, batchKeyOf, batchKindOf, batchLabelOf, boardMeta, columnsFor, compareDesc, defaultSortFor, defaultSortKeyFor, enrichAttemptPolicy, enrichMissingCount, groupBySite, groupChanges, isBatchBoard, isEnrichableBoard, saleRangeOf, shouldShowDays, usesRankDelta, withFanqieCat } from './scan/view.js';
|
|
25
25
|
import { BookmarkService, BookmarkStore } from './scan/bookmark.js';
|
|
26
26
|
import { parseBookInput } from './scan/bookmark-parse.js';
|
|
27
27
|
import { decodeIfPua } from './scan/fontmap.js';
|
|
@@ -1777,7 +1777,7 @@ export function apply(ctx, config) {
|
|
|
1777
1777
|
];
|
|
1778
1778
|
}
|
|
1779
1779
|
const main = mainLabelOf(boardId, meta);
|
|
1780
|
-
const opts = [{ value: '', label: '默认(名次)' }
|
|
1780
|
+
const opts = [{ value: '', label: '默认(名次)' }];
|
|
1781
1781
|
// 列名口径:番茄主指标列叫 read(不是 value),排序值必须对上列 key 才不会被客户端过滤掉
|
|
1782
1782
|
const mainKey = meta.site === 'fanqie' && !boardId.startsWith('fanqie.derived.') ? 'read' : 'value';
|
|
1783
1783
|
if (meta.metric === 'value')
|
|
@@ -1793,7 +1793,7 @@ export function apply(ctx, config) {
|
|
|
1793
1793
|
// ★ 兜底过滤(2026-10-15):排序项必须对应**该榜真实存在的列**,
|
|
1794
1794
|
// 否则列被口径改掉后(比如三江去掉「已结算天数」),下拉里还残留一个按不存在字段排的项。
|
|
1795
1795
|
const keys = new Set(applyColumnPolicy(columnsFor(meta, { hasBaseline: flags.hasHistory, hasHistory: flags.hasHistory }), boardId).map((c) => c.key));
|
|
1796
|
-
return opts.filter((o) => !o.value ||
|
|
1796
|
+
return opts.filter((o) => !o.value || keys.has(o.value));
|
|
1797
1797
|
}
|
|
1798
1798
|
/**
|
|
1799
1799
|
* ★ 2026-10-25(批次榜):把「数据日期」折成「批」。
|
|
@@ -1837,8 +1837,10 @@ export function apply(ctx, config) {
|
|
|
1837
1837
|
return out;
|
|
1838
1838
|
}
|
|
1839
1839
|
async function panelBoard(boardId, dateArg, sort, limit = 0) {
|
|
1840
|
+
const wantedSort = sort === 'rank' ? undefined : sort;
|
|
1840
1841
|
const { st, dates, latest } = panelCtx();
|
|
1841
1842
|
const meta = boardMeta(boardId);
|
|
1843
|
+
const defaultSortKey = defaultSortKeyFor(boardId);
|
|
1842
1844
|
const store = new FileStore(root);
|
|
1843
1845
|
/**
|
|
1844
1846
|
* ★ 日期下拉按**该榜自己有快照的日期**过滤(2026-10-15 使用反馈):
|
|
@@ -1865,7 +1867,7 @@ export function apply(ctx, config) {
|
|
|
1865
1867
|
// 使用者 2026-10-15 点名起点图不要这一列 ⇒ 改成按榜查精简索引里有没有它更早的记录。
|
|
1866
1868
|
if (!latest) {
|
|
1867
1869
|
const colsNone = applyColumnPolicy(columnsFor(meta, { hasBaseline: false, hasHistory: false }), boardId);
|
|
1868
|
-
return { boardId, meta, columns: colsNone, dataDate: null, dates: [], rows: [], note: '还没有任何快照:先点「立刻扫一次」' };
|
|
1870
|
+
return { boardId, meta, columns: colsNone, dataDate: null, dates: [], rows: [], defaultSortKey, note: '还没有任何快照:先点「立刻扫一次」' };
|
|
1869
1871
|
}
|
|
1870
1872
|
// 到这里 latest 一定非空 ⇒ 把日期收窄成非空的本地量(TS 不会因为 latest 非空就收窄 useDate)
|
|
1871
1873
|
const date = useDate;
|
|
@@ -1893,13 +1895,14 @@ export function apply(ctx, config) {
|
|
|
1893
1895
|
let rows = (v ? v.rows : []).map((r) => ({ ...r, days: r.extra && r.extra.inPoolDays != null ? r.extra.inPoolDays : null }));
|
|
1894
1896
|
// ★ 派生榜必须**自己**应用排序(2026-10-15 发现「按在读排序没反应」):
|
|
1895
1897
|
// 这个分支 return 在通用排序代码**之前**,所以 sort 参数到这里就丢了。
|
|
1896
|
-
const derivedSort =
|
|
1898
|
+
const derivedSort = wantedSort || defaultSortFor(boardId);
|
|
1897
1899
|
if (derivedSort)
|
|
1898
1900
|
rows = rows.slice().sort((a, b) => compareDesc(num(sortVal(a, derivedSort)), num(sortVal(b, derivedSort))));
|
|
1899
1901
|
return {
|
|
1900
1902
|
boardId,
|
|
1901
1903
|
meta: { ...meta, mainLabel: mainLabelOf(boardId, meta) },
|
|
1902
1904
|
columns,
|
|
1905
|
+
defaultSortKey,
|
|
1903
1906
|
sortOptions: sortOptionsFor(boardId, meta, { hasHistory }),
|
|
1904
1907
|
depth: (st.depths || {})[boardId] ?? 30,
|
|
1905
1908
|
dataDate: latest,
|
|
@@ -1926,7 +1929,7 @@ export function apply(ctx, config) {
|
|
|
1926
1929
|
}
|
|
1927
1930
|
}
|
|
1928
1931
|
if (!snap)
|
|
1929
|
-
return { boardId, meta, columns, dataDate: useDate, dates: shownDates, rows: [], note: '该榜在这天没有快照(也没找到更早的可用快照)' };
|
|
1932
|
+
return { boardId, meta, columns, dataDate: useDate, dates: shownDates, rows: [], defaultSortKey, note: '该榜在这天没有快照(也没找到更早的可用快照)' };
|
|
1930
1933
|
const effDate = fallbackFrom || date;
|
|
1931
1934
|
/**
|
|
1932
1935
|
* ★ 2026-10-25(批次榜):这一屏属于哪一批。面板据此把「数据日期 / 对比 YYYY-MM-DD」
|
|
@@ -1965,6 +1968,7 @@ export function apply(ctx, config) {
|
|
|
1965
1968
|
return {
|
|
1966
1969
|
boardId,
|
|
1967
1970
|
meta: { ...meta, mainLabel: mainLabelOf(boardId, meta) },
|
|
1971
|
+
defaultSortKey,
|
|
1968
1972
|
sortOptions: sortOptionsFor(boardId, meta, { hasHistory }),
|
|
1969
1973
|
depth: (st.depths || {})[boardId] ?? (meta.site === 'fanqie' ? 30 : 10),
|
|
1970
1974
|
columns,
|
|
@@ -2187,7 +2191,7 @@ export function apply(ctx, config) {
|
|
|
2187
2191
|
// ★ 排序一律**倒序**(使用者 2026-10-15:按字数/收藏/首订排序要「最大的在前」):
|
|
2188
2192
|
// num() 把缺失值统一成 +Infinity ⇒ 倒序时缺失值会被排到最后(不是最前),这正合口径。
|
|
2189
2193
|
// ★ 该榜有自己的「默认排序」时,未显式选排序也按它排(使用者 2026-10-15:三江默认按期初收藏)
|
|
2190
|
-
const effSort =
|
|
2194
|
+
const effSort = wantedSort || defaultSortFor(boardId);
|
|
2191
2195
|
if (effSort)
|
|
2192
2196
|
rows = rows.slice().sort((a, b) => compareDesc(num(sortVal(a, effSort)), num(sortVal(b, effSort))));
|
|
2193
2197
|
if (limit > 0)
|
|
@@ -2226,6 +2230,7 @@ export function apply(ctx, config) {
|
|
|
2226
2230
|
return {
|
|
2227
2231
|
boardId,
|
|
2228
2232
|
meta: { ...meta, mainLabel: mainLabelOf(boardId, meta) },
|
|
2233
|
+
defaultSortKey,
|
|
2229
2234
|
sortOptions: sortOptionsFor(boardId, meta, { hasHistory }),
|
|
2230
2235
|
depth: (st.depths || {})[boardId] ?? (meta.site === 'fanqie' ? 30 : 10),
|
|
2231
2236
|
columns,
|
|
@@ -3701,6 +3706,7 @@ export function apply(ctx, config) {
|
|
|
3701
3706
|
}
|
|
3702
3707
|
return send(200, {
|
|
3703
3708
|
ok: true, boardId, date, saved: !!body.save, contentDate: verdict.contentDate, expected: verdict.expected,
|
|
3709
|
+
defaultSortKey: defaultSortKeyFor(boardId),
|
|
3704
3710
|
rowsAll: res.rows,
|
|
3705
3711
|
count: res.rows.length,
|
|
3706
3712
|
note: (body.save ? '已抓取并存入本地快照' : '直查站点该日期(未落盘)') + (verdict.contentDate ? ';内容日期 ' + verdict.contentDate : ''),
|