dsh-pick 0.7.0 → 0.7.1
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 -1
- package/data/catalog.json +1 -1
- package/lib/engine.js +14 -1
- package/lib/overall.js +4 -0
- package/package.json +1 -1
- package/web/panel.html +22 -0
- package/web/panel.js +323 -33
package/web/panel.js
CHANGED
|
@@ -99,7 +99,7 @@ function askCands() {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function askVerdict() {
|
|
102
|
-
const rows = picked.map(
|
|
102
|
+
const rows = picked.map(cmpRec).filter(Boolean)
|
|
103
103
|
const rule = $('#verdicts').innerText.trim().replace(/\n+/g, ' / ')
|
|
104
104
|
return [
|
|
105
105
|
`帮我在这几个 DSH 插件里做个选择${dataAsOf()}。`,
|
|
@@ -409,6 +409,8 @@ function bindEvents() {
|
|
|
409
409
|
const t = b.dataset.tab
|
|
410
410
|
// 每个标签一块内容:tab-pick / tab-rank / tab-watch
|
|
411
411
|
document.querySelectorAll('#tabs button').forEach(x => $('#tab-' + x.dataset.tab).classList.toggle('hidden', x.dataset.tab !== t))
|
|
412
|
+
// 打开「我的监控」时,数据超过 6 小时没刷新就自动刷新一次
|
|
413
|
+
if (t === 'watch' && watch().length && (!LIVE.at || Date.now() - Date.parse(LIVE.at) > 6 * 3600 * 1000) && !$('#btnWatchRefresh').disabled) refreshWatch()
|
|
412
414
|
})
|
|
413
415
|
})
|
|
414
416
|
|
|
@@ -426,6 +428,11 @@ function bindEvents() {
|
|
|
426
428
|
})
|
|
427
429
|
})
|
|
428
430
|
$('#rankCat').addEventListener('change', renderRank)
|
|
431
|
+
$('#rankBody').addEventListener('click', e => {
|
|
432
|
+
if (!e.target.closest('[data-rank-more]')) return
|
|
433
|
+
RANK_LIMIT += RANK_STEP
|
|
434
|
+
renderRank()
|
|
435
|
+
})
|
|
429
436
|
|
|
430
437
|
$('#aiCands').addEventListener('click', () => cands.length && askAI(askCands()))
|
|
431
438
|
$('#aiVerdict').addEventListener('click', () => picked.length >= 2 && askAI(askVerdict()))
|
|
@@ -520,6 +527,7 @@ function togglePick(name) {
|
|
|
520
527
|
renderPickBar()
|
|
521
528
|
renderAi()
|
|
522
529
|
renderCompare()
|
|
530
|
+
fillCompareLive()
|
|
523
531
|
}
|
|
524
532
|
|
|
525
533
|
/* ---------------- 比较清单:搜索结果之外的插件也能加进来 ---------------- */
|
|
@@ -625,6 +633,7 @@ const ROWS = [
|
|
|
625
633
|
{ k: 'cad', label: '版本节奏', get: r => r.deep && r.deep.cadence, fmt: r => r == null ? '—' : r + ' 天/版', best: 'min' },
|
|
626
634
|
{ k: 'age', label: '最近更新', get: r => r.deep && r.deep.age, fmt: r => r == null ? '—' : r + ' 天前', best: 'min' },
|
|
627
635
|
{ k: 's', label: '健康度', get: r => r.deep && r.deep.s, fmt: num, best: 'max' },
|
|
636
|
+
{ k: 'tot', label: '累计下载', get: r => r.total, fmt: num, best: 'max' },
|
|
628
637
|
{ k: 'gs', label: 'GitHub 星标', get: r => r.gh && r.gh.s, fmt: num, best: 'max' },
|
|
629
638
|
{ k: 'gp', label: '最近提交', get: r => r.gh && daysSince(r.gh.p), fmt: r => r == null ? '—' : ageText(r), best: 'min' },
|
|
630
639
|
]
|
|
@@ -638,11 +647,11 @@ function renderCompare() {
|
|
|
638
647
|
return
|
|
639
648
|
}
|
|
640
649
|
|
|
641
|
-
const rows = picked.map(
|
|
650
|
+
const rows = picked.map(cmpRec).filter(Boolean)
|
|
642
651
|
const missingDeep = rows.filter(r => !r.deep).length
|
|
643
652
|
|
|
644
653
|
$('#cmpHead').innerHTML = '<tr><th>指标</th>' +
|
|
645
|
-
rows.map((r, i) => `<th><i style="background:${colorOf(picked.indexOf(r.n))}"></i>${esc(r.n)}</th>`).join('') +
|
|
654
|
+
rows.map((r, i) => `<th><i style="background:${colorOf(picked.indexOf(r.n))}"></i>${esc(r.n)}${r.live ? ' <span class="srcchip" title="指标是刚从 npm 实时算的">实时</span>' : ''}</th>`).join('') +
|
|
646
655
|
'</tr>'
|
|
647
656
|
|
|
648
657
|
let body = ''
|
|
@@ -662,7 +671,9 @@ function renderCompare() {
|
|
|
662
671
|
|
|
663
672
|
$('#cmpNote').innerHTML =
|
|
664
673
|
`健康度 = 日常基线 40% + 增速 25% + 新鲜度 20% + 版本节奏 15%,满分 100。` +
|
|
665
|
-
(
|
|
674
|
+
(rows.some(r => r.live) ? `<br>${rows.filter(r => r.live).map(r => esc(r.n)).join('、')} 不在每日构建的去噪范围(周下载前 300 多名)里,这些指标是刚从 npm 实时算的。` : '') +
|
|
675
|
+
(CMP_PENDING.size ? `<br><span style="color:var(--t3)">正在从 npm 实时计算 ${[...CMP_PENDING].map(esc).join('、')} 的指标…</span>` : '') +
|
|
676
|
+
(missingDeep && !CMP_PENDING.size ? `<br><span style="color:var(--warn-text)">${rows.filter(r => !r.deep).map(r => esc(r.n)).join('、')} 实时也没算出去噪指标(npm 上数据太少或这次没查到),无法参与健康度比较。</span>` : '')
|
|
666
677
|
|
|
667
678
|
sec.classList.remove('hidden')
|
|
668
679
|
renderVerdict()
|
|
@@ -670,7 +681,7 @@ function renderCompare() {
|
|
|
670
681
|
|
|
671
682
|
/* ---------------- 第 4 步:结论 ---------------- */
|
|
672
683
|
function renderVerdict() {
|
|
673
|
-
const rows = picked.map(
|
|
684
|
+
const rows = picked.map(cmpRec).filter(Boolean)
|
|
674
685
|
const withDeep = rows.filter(r => r.deep)
|
|
675
686
|
const noDeep = rows.filter(r => !r.deep)
|
|
676
687
|
|
|
@@ -749,7 +760,63 @@ function rankBoard() {
|
|
|
749
760
|
return document.querySelector('#rankBoard button.on').dataset.b
|
|
750
761
|
}
|
|
751
762
|
|
|
752
|
-
|
|
763
|
+
/* ---------- 排行榜统一出表 ---------- */
|
|
764
|
+
// 每个榜都先排出完整名次,只画前 RANK_LIMIT 名,下面「显示更多」再加一页
|
|
765
|
+
const RANK_STEP = 50
|
|
766
|
+
let RANK_LIMIT = RANK_STEP
|
|
767
|
+
let RANK_SIG = ''
|
|
768
|
+
|
|
769
|
+
/** 换了榜单、角度或分类:回到第一页 */
|
|
770
|
+
function rankSig(sig) {
|
|
771
|
+
if (sig !== RANK_SIG) { RANK_SIG = sig; RANK_LIMIT = RANK_STEP }
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/** 名字:npm 包名,或 gh:owner/repo 的仓库名 */
|
|
775
|
+
function watchName(k) {
|
|
776
|
+
return k.startsWith('gh:') ? k.slice(3).split('/').pop() : k
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** 不在这个榜的通用原因:目录里没有、分类对不上 */
|
|
780
|
+
function missCommon(k, cat) {
|
|
781
|
+
const rec = CAT.packages[k]
|
|
782
|
+
if (!k.startsWith('gh:') && !rec) return '插件目录里没有它(还没被收录,或不是 DSH 插件)'
|
|
783
|
+
if (cat && rec && rec.cat !== cat) return `它的分类是「${rec.cat || '未分类'}」,不在「${cat}」里`
|
|
784
|
+
return ''
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* all:这个榜(当前角度、分类下)的完整排名;row(x, i, on) 画一行,i 是在完整排名里的下标。
|
|
789
|
+
* keysOf(x):这一行对应的监控名(GitHub 榜一行代表一个仓库,可能对应好几个插件)。
|
|
790
|
+
* 我的监控里的插件:在画出来的前几名里就高亮;不在就追加到最下面,标出它在完整排名里的名次;
|
|
791
|
+
* 完整排名里也没有的,写明为什么不在这个榜
|
|
792
|
+
*/
|
|
793
|
+
function paintRank({ all, row, keysOf, cols, empty, miss }) {
|
|
794
|
+
const watched = watch()
|
|
795
|
+
const wset = new Set(watched)
|
|
796
|
+
const shown = all.slice(0, RANK_LIMIT)
|
|
797
|
+
const isOn = x => keysOf(x).some(k => wset.has(k))
|
|
798
|
+
let html = all.length ? shown.map((x, i) => row(x, i, isOn(x))).join('') : `<tr><td colspan="${cols}" class="empty">${empty}</td></tr>`
|
|
799
|
+
if (all.length > shown.length) {
|
|
800
|
+
html += `<tr class="more"><td colspan="${cols}"><button class="btn ghost" data-rank-more>显示更多 · 还有 ${num(all.length - shown.length)} 个(共 ${num(all.length)})</button></td></tr>`
|
|
801
|
+
}
|
|
802
|
+
const shownKeys = new Set(shown.flatMap(keysOf))
|
|
803
|
+
const extra = watched.filter(k => !shownKeys.has(k))
|
|
804
|
+
if (extra.length) {
|
|
805
|
+
const seen = new Set()
|
|
806
|
+
const found = extra.map(k => ({ k, i: all.findIndex(x => keysOf(x).includes(k)) }))
|
|
807
|
+
.filter(({ i }) => i < 0 || (!seen.has(i) && seen.add(i)))
|
|
808
|
+
.sort((a, b) => (a.i < 0) - (b.i < 0) || a.i - b.i)
|
|
809
|
+
html += `<tr class="wsep"><td colspan="${cols}">我的监控 · 不在上面前 ${num(shown.length)} 名里的,排在这里</td></tr>`
|
|
810
|
+
html += found.map(({ k, i }) => (i >= 0 ? row(all[i], i, true)
|
|
811
|
+
: `<tr class="watched miss"><td class="rk">—</td><td class="nm" colspan="${cols - 2}">${esc(watchName(k))}` +
|
|
812
|
+
`<div class="sub">不在这个榜:${esc(miss(k) || '这个榜没收录它')}</div></td><td class="lks">${watchBtn(k)}</td></tr>`)).join('')
|
|
813
|
+
}
|
|
814
|
+
$('#rankBody').innerHTML = html
|
|
815
|
+
}
|
|
816
|
+
const trOpen = on => `<tr${on ? ' class="watched"' : ''}>`
|
|
817
|
+
const rankCell = i => `<td class="rk">${i + 1}</td>`
|
|
818
|
+
|
|
819
|
+
/** 官方 / 社区 / 商店榜:数据来自别人维护的目录 */
|
|
753
820
|
function renderOuterBoard(board) {
|
|
754
821
|
const data = CAT.boards && CAT.boards[board]
|
|
755
822
|
const CAPS = {
|
|
@@ -769,15 +836,27 @@ function renderOuterBoard(board) {
|
|
|
769
836
|
(!r.n ? '<div class="sub">只在 GitHub,没发到 npm</div>' : '') +
|
|
770
837
|
(r.d ? `<div class="sub desc" title="${esc(r.d)}">${esc(r.d)}</div>` : '') + `</td>`
|
|
771
838
|
const actions = r => `<td class="lks">${watchBtn(watchKey(r))}${linkBtns({ n: r.n || '', ghUrl: r.repo || '' }, { icon: true })}</td>`
|
|
839
|
+
const marketName = { official: 'DeepSeek 官方', community: '社区目录', shop: '这个商店' }[board]
|
|
840
|
+
const keysOf = r => [watchKey(r)].filter(Boolean)
|
|
841
|
+
// 社区目录、商店的榜只存了头部(比如社区一万多个只存前两百多):没存下来不等于没收录,
|
|
842
|
+
// 综合榜那边记着每个插件被哪些市场收录了(rec.src),用它分辨
|
|
843
|
+
const srcKey = { official: 'official', community: 'dshmarket', shop: 'shop' }[board]
|
|
844
|
+
const miss = k => {
|
|
845
|
+
const rec = CAT.packages[k]
|
|
846
|
+
if (rec && (rec.src || []).includes(srcKey)) return `${marketName}收录了它,但这个榜只存了前 ${num(data.rows.length)} 个(共 ${num(data.total || data.rows.length)}),它排在后面,具体名次没存`
|
|
847
|
+
return `${marketName}没收录它`
|
|
848
|
+
}
|
|
772
849
|
|
|
773
850
|
if (board === 'official') {
|
|
851
|
+
rankSig(board)
|
|
774
852
|
const rows = data.rows.slice().sort((x, y) => (y.w || 0) - (x.w || 0))
|
|
775
853
|
$('#rankHead').innerHTML = '<tr><th style="width:44px">#</th><th>插件</th><th class="r">周下载</th><th></th></tr>'
|
|
776
|
-
|
|
854
|
+
paintRank({ all: rows, keysOf, cols: 4, empty: '', miss, row: (r, i, on) => `${trOpen(on)}${rankCell(i)}${nameCell(r)}<td class="r"><b>${num(r.w)}</b></td>${actions(r)}</tr>` })
|
|
777
855
|
return
|
|
778
856
|
}
|
|
779
857
|
|
|
780
858
|
const metric = document.querySelector(`#rankFilters .chip.on[data-board="${board}"]`).dataset.m
|
|
859
|
+
rankSig(board + '|' + metric)
|
|
781
860
|
let rows = data.rows.filter(r => r[metric] != null)
|
|
782
861
|
.sort((x, y) => (y[metric] > x[metric] ? 1 : y[metric] < x[metric] ? -1 : 0))
|
|
783
862
|
// 按星标排时一个仓库只留一行(优先留发到 npm 的那条),不然同仓库的条目数字一样、刷屏
|
|
@@ -790,15 +869,20 @@ function renderOuterBoard(board) {
|
|
|
790
869
|
const keep = new Set(best.values())
|
|
791
870
|
rows = rows.filter(r => keep.has(r))
|
|
792
871
|
}
|
|
793
|
-
rows = rows.slice(0, 40)
|
|
794
872
|
const hasDl = board === 'community'
|
|
795
873
|
$('#rankHead').innerHTML = '<tr><th style="width:44px">#</th><th>插件</th><th class="r">★ 星标</th>' +
|
|
796
874
|
(hasDl ? '<th class="r" title="近 30 天">下载</th>' : '') + '<th class="r">收录</th><th></th></tr>'
|
|
797
875
|
const strong = (on, t) => (on ? `<b>${t}</b>` : t)
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
876
|
+
const metricName = { s: '星标', dl: '下载量', added: '收录日期' }[metric]
|
|
877
|
+
const inBoard = new Set(data.rows.flatMap(keysOf))
|
|
878
|
+
paintRank({
|
|
879
|
+
all: rows, keysOf, cols: hasDl ? 6 : 5, empty: '这个榜还没有数据。',
|
|
880
|
+
miss: k => (inBoard.has(k) ? `${marketName}收录了它,但它${metric === 's' ? '和同仓库的另一个条目只列一行,或' : ''}没有${metricName}数据` : miss(k)),
|
|
881
|
+
row: (r, i, on) => `${trOpen(on)}${rankCell(i)}${nameCell(r)}` +
|
|
882
|
+
`<td class="r">${strong(metric === 's', num(r.s))}</td>` +
|
|
883
|
+
(hasDl ? `<td class="r">${strong(metric === 'dl', num(r.dl))}</td>` : '') +
|
|
884
|
+
`<td class="r">${strong(metric === 'added', r.added ? esc(r.added.slice(5)) : '—')}</td>${actions(r)}</tr>`,
|
|
885
|
+
})
|
|
802
886
|
}
|
|
803
887
|
|
|
804
888
|
/** 「收录于」的市场名 */
|
|
@@ -826,6 +910,44 @@ const ANGLE_INFO = {
|
|
|
826
910
|
new: { label: '收录', cap: () => '新上架:最近 30 天才被插件市场收录的,越新越靠前,同一天的按使用量排。' },
|
|
827
911
|
}
|
|
828
912
|
|
|
913
|
+
const OV_ANGLES = ['rec', 'use', 'rep', 'stable', 'rise', 'new']
|
|
914
|
+
// 在综合榜里、但这个角度不参与的原因(规则见 lib/overall.js)
|
|
915
|
+
const OV_MISS = {
|
|
916
|
+
use: '没有去噪后的日常基线(下载太少,没进深挖),不参与「使用」',
|
|
917
|
+
rep: '没有 GitHub 星标,也没被精选或官方收录,不参与「口碑」',
|
|
918
|
+
stable: '上架不满 60 天,或很久没维护,不参与「稳定」',
|
|
919
|
+
rise: '日常基线不到每天 20 次,不参与「增速」',
|
|
920
|
+
new: '被收录超过 30 天,不算新上架',
|
|
921
|
+
}
|
|
922
|
+
let hasOA = false
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* 综合榜参与排名的全部插件:每日目录只把每个角度的头部存成完整的行,
|
|
926
|
+
* 其余 npm 插件的六个角度分数存在各自的记录上(rec.oa),这里补成行,分类筛选、算名次都在全部插件里排。
|
|
927
|
+
* 旧目录没有 rec.oa,就只有存下来的那些
|
|
928
|
+
*/
|
|
929
|
+
function overallPool(data) {
|
|
930
|
+
const angles = data.angles || OV_ANGLES
|
|
931
|
+
const seen = new Set(data.rows.map(r => r.k))
|
|
932
|
+
const pool = data.rows.slice()
|
|
933
|
+
hasOA = false
|
|
934
|
+
for (const rec of Object.values(CAT.packages)) {
|
|
935
|
+
if (!rec.oa) continue
|
|
936
|
+
hasOA = true
|
|
937
|
+
if (seen.has(rec.n)) continue
|
|
938
|
+
const d = rec.deep
|
|
939
|
+
const a = Object.fromEntries(angles.map((k, i) => [k, rec.oa[i] ?? null]))
|
|
940
|
+
const row = { k: rec.n, n: rec.n, sc: a.rec, a, src: rec.src || [] }
|
|
941
|
+
if (rec.ad) row.added = rec.ad
|
|
942
|
+
if (rec.gh && rec.gh.s != null) row.s = rec.gh.s
|
|
943
|
+
if (d && Number.isFinite(d.growth)) row.g = Math.round(d.growth * 100) / 100
|
|
944
|
+
const last = (d && d.lastRelease) || (rec.t ? String(rec.t).slice(0, 10) : '')
|
|
945
|
+
if (last) row.last = last
|
|
946
|
+
pool.push(row)
|
|
947
|
+
}
|
|
948
|
+
return pool
|
|
949
|
+
}
|
|
950
|
+
|
|
829
951
|
/**
|
|
830
952
|
* 综合榜:几个插件市场合成一个榜(每日构建时算好,见 lib/overall.js),一个插件一行。
|
|
831
953
|
* 顶部选角度;npm 上的插件能直接装,只在 GitHub 上的先只展示
|
|
@@ -847,22 +969,32 @@ function renderOverall() {
|
|
|
847
969
|
return
|
|
848
970
|
}
|
|
849
971
|
const cat = $('#rankCat').value
|
|
972
|
+
rankSig(`overall|${angle}|${cat}`)
|
|
850
973
|
const valueOf = r => (hasAngles ? r.a[angle] : r.sc)
|
|
851
|
-
|
|
974
|
+
const pool = overallPool(data)
|
|
975
|
+
const rows = pool
|
|
852
976
|
.filter(r => valueOf(r) != null)
|
|
853
977
|
.map(r => ({ r, rec: r.n ? CAT.packages[r.n] : null }))
|
|
854
978
|
.filter(({ rec }) => !cat || (rec && rec.cat === cat))
|
|
855
979
|
rows.sort((x, y) => angle === 'new'
|
|
856
980
|
? String(y.r.added || '').localeCompare(String(x.r.added || '')) || valueOf(y.r) - valueOf(x.r)
|
|
857
|
-
: valueOf(y.r) - valueOf(x.r))
|
|
858
|
-
|
|
981
|
+
: valueOf(y.r) - valueOf(x.r) || (y.rec ? y.rec.w || 0 : 0) - (x.rec ? x.rec.w || 0 : 0))
|
|
982
|
+
const inPool = new Map(pool.map(r => [r.k, r]))
|
|
859
983
|
// 固定列宽(table.ov):数字列和操作列宽度固定,插件名占剩下的;不然简介把名字一列撑得很宽,
|
|
860
984
|
// 右边固定的操作列正好盖住数字
|
|
861
|
-
$('#rankHead').innerHTML = '<tr><th style="width:
|
|
985
|
+
$('#rankHead').innerHTML = '<tr><th style="width:34px">#</th><th>插件</th>' +
|
|
862
986
|
`<th class="r" style="width:38px" title="这个角度的分数 0~100">${info.label}</th><th class="r" style="width:44px">周下载</th>` +
|
|
863
987
|
'<th class="r" style="width:38px" title="GitHub 星标">★</th><th class="r" style="width:46px" title="最近一次发版或提交">最近</th>' +
|
|
864
988
|
'<th style="width:112px"></th></tr>'
|
|
865
|
-
|
|
989
|
+
const miss = k => {
|
|
990
|
+
const common = missCommon(k, cat)
|
|
991
|
+
if (common) return common
|
|
992
|
+
const r = inPool.get(k)
|
|
993
|
+
if (r) return OV_MISS[angle] || '这个角度不参与'
|
|
994
|
+
if (k.startsWith('gh:')) return '只在 GitHub 上、排名靠后的插件综合榜没有存'
|
|
995
|
+
return CAT.packages[k].oa ? '' : hasOA ? '没进综合榜:仓库已归档、没声明 dsh.bundle,或是终端版插件' : '不在综合榜存下来的前列里(每日目录更新后能看到完整名次)'
|
|
996
|
+
}
|
|
997
|
+
paintRank({ all: rows, cols: 7, keysOf: ({ r }) => [r.k], miss, empty: '这个角度下没有插件(或这个分类里没有)。', row: ({ r, rec }, i, on) => {
|
|
866
998
|
const name = r.n || r.name
|
|
867
999
|
const v = rec ? rec.v : r.v
|
|
868
1000
|
const w = rec ? rec.w : r.w
|
|
@@ -878,7 +1010,7 @@ function renderOverall() {
|
|
|
878
1010
|
// 能装的:目录里的 npm 包按装前检查给按钮;官方插件不在目录里,名字核对过,也能装
|
|
879
1011
|
const inst = r.n ? installArea(rec || { n: r.n }, { icon: true }) : ''
|
|
880
1012
|
const links = linkBtns(rec || { n: r.n || '', ghUrl: r.repo || '' }, { icon: true })
|
|
881
|
-
return
|
|
1013
|
+
return `${trOpen(on)}${rankCell(i)}` +
|
|
882
1014
|
`<td class="nm"><div class="nmline" title="${esc(name)}${v ? ' v' + esc(v) : ''}">${esc(name)}${v ? ` <span style="color:var(--t3);font-weight:400;font-size:11px">v${esc(v)}</span>` : ''}</div>` +
|
|
883
1015
|
`<div class="chips">${srcChips(r.src, { short: true })}${r.n ? '' : '<span class="srcchip gh" title="只在 GitHub,没发到 npm">GitHub</span>'}</div>` +
|
|
884
1016
|
(desc ? `<div class="sub desc" title="${esc(desc)}">${esc(desc)}</div>` : '') + `</td>` +
|
|
@@ -887,7 +1019,7 @@ function renderOverall() {
|
|
|
887
1019
|
`<td class="r">${r.s != null ? short(r.s) : '—'}</td>` +
|
|
888
1020
|
`<td class="r" title="${esc(r.last || '')}"><span${age != null && age > 90 ? ' class="stale"' : ''}>${age != null ? ageText(age) : '—'}</span></td>` +
|
|
889
1021
|
`<td class="lks">${watchBtn(r.k)}${inst}${links}</td></tr>`
|
|
890
|
-
})
|
|
1022
|
+
} })
|
|
891
1023
|
}
|
|
892
1024
|
|
|
893
1025
|
function renderRank() {
|
|
@@ -913,6 +1045,7 @@ function renderRank() {
|
|
|
913
1045
|
return
|
|
914
1046
|
}
|
|
915
1047
|
|
|
1048
|
+
rankSig(`${board}|${metric}|${cat}`)
|
|
916
1049
|
if (board === 'gh') {
|
|
917
1050
|
$('#rankCap').textContent = '按 GitHub 仓库数据:星标看关注度,最近提交看还有没有人在维护。一个仓库只列一行;仓库填成 DSH 本体的不算。'
|
|
918
1051
|
const val = r => metric === 'gs' ? r.gh.s
|
|
@@ -930,14 +1063,25 @@ function renderRank() {
|
|
|
930
1063
|
else { cur.n++; if (r.w > cur.r.w) cur.r = r }
|
|
931
1064
|
}
|
|
932
1065
|
const shared = new Map([...byRepo.values()].map(x => [x.r.n, x.n]))
|
|
933
|
-
|
|
1066
|
+
// 一行代表一个仓库:这个仓库里的插件都算这一行(监控了其中任何一个,都高亮这一行)
|
|
1067
|
+
const repoKeys = new Map()
|
|
1068
|
+
for (const r of Object.values(CAT.packages)) {
|
|
1069
|
+
if (!r.gh) continue
|
|
1070
|
+
const k = r.gh.repo.toLowerCase()
|
|
1071
|
+
if (!repoKeys.has(k)) repoKeys.set(k, [])
|
|
1072
|
+
repoKeys.get(k).push(r.n)
|
|
1073
|
+
}
|
|
1074
|
+
const rows = [...byRepo.values()].map(x => x.r).sort((x, y) => val(y) - val(x))
|
|
934
1075
|
$('#rankHead').innerHTML = '<tr><th style="width:44px">#</th><th>插件</th><th>分类</th>' +
|
|
935
1076
|
'<th class="r">★ 星标</th><th class="r">Fork</th><th class="r" title="未关闭的 issue 与 PR">讨论</th>' +
|
|
936
1077
|
'<th class="r" title="仓库最近一次提交">最近提交</th><th></th></tr>'
|
|
937
|
-
|
|
1078
|
+
paintRank({
|
|
1079
|
+
all: rows, cols: 8, empty: '目录里还没有 GitHub 数据(每日更新取到后就有)。',
|
|
1080
|
+
keysOf: r => repoKeys.get(r.gh.repo.toLowerCase()) || [r.n],
|
|
1081
|
+
miss: k => missCommon(k, cat) || '目录里没有它的 GitHub 仓库数据(没填仓库地址,或仓库填成了 DSH 本体)',
|
|
1082
|
+
row: (r, i, on) => {
|
|
938
1083
|
const age = daysSince(r.gh.p)
|
|
939
|
-
return
|
|
940
|
-
`<td style="color:var(--t3)">${i + 1}</td>` +
|
|
1084
|
+
return trOpen(on) + rankCell(i) +
|
|
941
1085
|
`<td class="nm">${esc(r.n)} <span style="color:var(--t3);font-weight:400;font-size:11px">v${esc(r.v)}</span>` +
|
|
942
1086
|
(shared.get(r.n) > 1 ? `<div class="sub" title="仓库 ${esc(r.gh.repo)} 里有 ${shared.get(r.n)} 个插件,数据相同,只列一行">等 ${shared.get(r.n)} 个插件共用这个仓库</div>` : '') +
|
|
943
1087
|
`</td>` +
|
|
@@ -948,7 +1092,7 @@ function renderRank() {
|
|
|
948
1092
|
`<td class="r" title="${esc(r.gh.p || '')}">${r.gh.a ? '<span class="arch">已归档</span>' : `<span${age != null && age > 90 ? ' class="stale"' : ''}>${b(metric === 'gp', ageText(age))}</span>`}</td>` +
|
|
949
1093
|
`<td class="lks">${watchBtn(r.n)}${linkBtns(r, { icon: true })}</td>` +
|
|
950
1094
|
`</tr>`
|
|
951
|
-
})
|
|
1095
|
+
} })
|
|
952
1096
|
return
|
|
953
1097
|
}
|
|
954
1098
|
|
|
@@ -958,15 +1102,17 @@ function renderRank() {
|
|
|
958
1102
|
: metric === 'growth' ? (r.deep.growth === null ? -Infinity : r.deep.growth)
|
|
959
1103
|
: metric === 's' ? r.deep.s
|
|
960
1104
|
: r.w
|
|
961
|
-
const rows = Object.values(CAT.packages).filter(r => inCat(r) && (!onlyDeep || r.deep)).sort((x, y) => val(y) - val(x))
|
|
1105
|
+
const rows = Object.values(CAT.packages).filter(r => inCat(r) && (!onlyDeep || r.deep)).sort((x, y) => val(y) - val(x))
|
|
962
1106
|
$('#rankHead').innerHTML = '<tr><th style="width:44px">#</th><th>插件</th><th>分类</th>' +
|
|
963
1107
|
`<th class="r">基线</th><th class="r">周下载</th><th class="r">环比</th>${metric === 's' ? '<th class="r">健康度</th>' : ''}` +
|
|
964
1108
|
'<th class="r" title="最近一次发版 · 平均几天发一个版本">更新</th><th></th></tr>'
|
|
965
|
-
|
|
1109
|
+
paintRank({
|
|
1110
|
+
all: rows, cols: metric === 's' ? 9 : 8, empty: '这个分类里没有插件。', keysOf: r => [r.n],
|
|
1111
|
+
miss: k => missCommon(k, cat) || (k.startsWith('gh:') ? '只在 GitHub 上,没发到 npm' : '没有去噪数据(下载太少,没进深挖),这一项排不了;切到「周下载」能看到它的名次'),
|
|
1112
|
+
row: (r, i, on) => {
|
|
966
1113
|
const d = r.deep
|
|
967
1114
|
const g = d ? d.growth : null
|
|
968
|
-
return
|
|
969
|
-
`<td style="color:var(--t3)">${i + 1}</td>` + nameCell(r) +
|
|
1115
|
+
return trOpen(on) + rankCell(i) + nameCell(r) +
|
|
970
1116
|
`<td><span class="catpill">${esc(r.cat)}</span></td>` +
|
|
971
1117
|
`<td class="r">${b(metric === 'base', d ? num(d.base) : '—')}</td>` +
|
|
972
1118
|
`<td class="r">${b(metric === 'w', num(r.w))}</td>` +
|
|
@@ -975,7 +1121,7 @@ function renderRank() {
|
|
|
975
1121
|
maintCell(d) +
|
|
976
1122
|
`<td class="lks">${watchBtn(r.n)}${linkBtns(r, { icon: true })}</td>` +
|
|
977
1123
|
`</tr>`
|
|
978
|
-
})
|
|
1124
|
+
} })
|
|
979
1125
|
}
|
|
980
1126
|
|
|
981
1127
|
/* ---------------- 我的监控 ---------------- */
|
|
@@ -1014,6 +1160,9 @@ function toggleWatch(key) {
|
|
|
1014
1160
|
b.textContent = now ? '✓' : '+'
|
|
1015
1161
|
b.title = now ? '已在我的监控里,点一下移除' : '加入我的监控'
|
|
1016
1162
|
b.setAttribute('aria-label', now ? '移出我的监控' : '加入我的监控')
|
|
1163
|
+
// 排行榜里这一行跟着高亮(不重画整张表,免得滚动位置跳走)
|
|
1164
|
+
const tr = b.closest('table.rank tr')
|
|
1165
|
+
if (tr) tr.classList.toggle('watched', now)
|
|
1017
1166
|
})
|
|
1018
1167
|
}
|
|
1019
1168
|
|
|
@@ -1046,24 +1195,162 @@ function watchRec(n) {
|
|
|
1046
1195
|
const gh = live && live.found ? live.gh : (inBoard && inBoard.s != null ? { repo, s: inBoard.s, f: null, i: null, p: null, a: false } : null)
|
|
1047
1196
|
return { n: '', label: repo, cat: '只在 GitHub', w: null, m: null, deep: null, ghUrl: url, gh, live: Boolean(live && live.found) }
|
|
1048
1197
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1198
|
+
return mergeLive(CAT.packages[n], LIVE.rows[n], n)
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* 目录记录 + 实时查到的数据(/live 的一行)→ 一条记录,字段用目录的短名,后面的代码不用分两套。
|
|
1203
|
+
* 实时的覆盖目录的;npm 下载接口偶尔限流查不到时,保留目录里的指标,别把有的数据冲掉
|
|
1204
|
+
*/
|
|
1205
|
+
function mergeLive(base, live, n) {
|
|
1051
1206
|
if (!live || !live.found) return base || null
|
|
1052
1207
|
const d = live.deep
|
|
1053
1208
|
return {
|
|
1054
1209
|
...(base || { n, cat: '(目录外)' }),
|
|
1055
1210
|
n,
|
|
1056
1211
|
v: live.latest || (base && base.v),
|
|
1212
|
+
d: (base && base.d) || live.description || '',
|
|
1057
1213
|
w: live.weekly,
|
|
1058
1214
|
m: live.monthly,
|
|
1059
|
-
// npm 下载接口偶尔限流查不到:保留目录里的指标,别把有的数据冲掉
|
|
1060
1215
|
deep: d ? { base: d.baseline, growth: d.growth, cadence: d.cadence, age: d.ageDays, lastRelease: d.lastRelease, versions: d.versions, s: d.score } : (base && base.deep) || null,
|
|
1061
1216
|
gh: live.gh || (base && base.gh) || null,
|
|
1217
|
+
total: live.total ?? null,
|
|
1218
|
+
daily: live.daily || null,
|
|
1219
|
+
dailyStart: live.dailyStart || null,
|
|
1062
1220
|
live: true,
|
|
1063
1221
|
catalogW: base ? base.w : null,
|
|
1064
1222
|
}
|
|
1065
1223
|
}
|
|
1066
1224
|
|
|
1225
|
+
/* ---------------- 比较里的插件:没有去噪数据的,实时算一份 ---------------- */
|
|
1226
|
+
// 去噪指标每日构建时只给周下载前 300 多名算;自己加进比较的插件多半在这之外,就去 npm 当场算
|
|
1227
|
+
const CMP_LIVE = new Map() // 包名 → /live 的一行
|
|
1228
|
+
const CMP_PENDING = new Set()
|
|
1229
|
+
function cmpRec(n) {
|
|
1230
|
+
return CMP_LIVE.has(n) ? mergeLive(CAT.packages[n], CMP_LIVE.get(n), n) : CAT.packages[n]
|
|
1231
|
+
}
|
|
1232
|
+
async function fillCompareLive() {
|
|
1233
|
+
const need = picked.filter(n => CAT.packages[n] && !CAT.packages[n].deep && !CMP_LIVE.has(n) && !CMP_PENDING.has(n))
|
|
1234
|
+
if (!need.length) return
|
|
1235
|
+
need.forEach(n => CMP_PENDING.add(n))
|
|
1236
|
+
renderCompare()
|
|
1237
|
+
try {
|
|
1238
|
+
const r = await fetch(`${P.live}?names=${encodeURIComponent(need.join(','))}`, { cache: 'no-store' })
|
|
1239
|
+
const j = await r.json()
|
|
1240
|
+
if (r.ok) for (const row of j.rows || []) if (row.found) CMP_LIVE.set(row.name, row)
|
|
1241
|
+
} catch { /* 查不到就按目录里的显示 */ }
|
|
1242
|
+
need.forEach(n => CMP_PENDING.delete(n))
|
|
1243
|
+
renderCompare()
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/* ---------------- 监控详情:快照历史、走势图、各项数据 ---------------- */
|
|
1247
|
+
// 每次刷新在本机存一份快照(每个插件最多 30 份),「较上次」就是和上一份比
|
|
1248
|
+
const HIST_KEY = 'dsh-pick-watch-history-v1'
|
|
1249
|
+
function loadHistory() {
|
|
1250
|
+
try { return JSON.parse(localStorage.getItem(HIST_KEY)) || {} } catch { return {} }
|
|
1251
|
+
}
|
|
1252
|
+
function saveSnapshots(at) {
|
|
1253
|
+
const hist = loadHistory()
|
|
1254
|
+
for (const n of watch()) {
|
|
1255
|
+
const r = watchRec(n)
|
|
1256
|
+
if (!r || !r.live) continue
|
|
1257
|
+
const snap = { t: at, w: r.w ?? null, base: r.deep ? r.deep.base : null, s: r.gh ? r.gh.s : null, rank: r.rank ?? null, sc: r.sc ?? null }
|
|
1258
|
+
const list = (hist[n] || []).filter(x => x.t !== at)
|
|
1259
|
+
list.push(snap)
|
|
1260
|
+
hist[n] = list.slice(-30)
|
|
1261
|
+
}
|
|
1262
|
+
try { localStorage.setItem(HIST_KEY, JSON.stringify(hist)) } catch { /* 存不下就不记 */ }
|
|
1263
|
+
}
|
|
1264
|
+
/** 和上一份快照比:返回「较上次」的小字 */
|
|
1265
|
+
function changeOf(n, key, now, { lowerIsBetter = false, asPct = true } = {}) {
|
|
1266
|
+
const list = loadHistory()[n] || []
|
|
1267
|
+
const prev = list.length >= 2 ? list[list.length - 2] : null
|
|
1268
|
+
if (!prev || prev[key] == null || now == null) return ''
|
|
1269
|
+
const diff = now - prev[key]
|
|
1270
|
+
const when = new Date(prev.t).toLocaleDateString()
|
|
1271
|
+
if (diff === 0) return `<span class="ch flat" title="和 ${esc(when)} 刷新时一样">较上次持平</span>`
|
|
1272
|
+
const good = lowerIsBetter ? diff < 0 : diff > 0
|
|
1273
|
+
// 排名数字越小越好:用「升 / 降 几名」说,正负号容易看反
|
|
1274
|
+
const txt = lowerIsBetter ? `${diff < 0 ? '升' : '降'} ${num(Math.abs(diff))} 名`
|
|
1275
|
+
: asPct && prev[key] ? `${diff > 0 ? '+' : ''}${Math.round(diff / prev[key] * 100)}%` : `${diff > 0 ? '+' : ''}${num(diff)}`
|
|
1276
|
+
return `<span class="ch ${good ? 'up' : 'down'}" title="和 ${esc(when)} 刷新时相比">较上次 ${txt}</span>`
|
|
1277
|
+
}
|
|
1278
|
+
/** 30 天每日下载的走势小图(缺数据的日子断开) */
|
|
1279
|
+
function sparkSvg(daily, color) {
|
|
1280
|
+
if (!daily || !daily.some(v => v != null)) return ''
|
|
1281
|
+
const W = 120, H = 30
|
|
1282
|
+
const max = Math.max(1, ...daily.filter(v => v != null))
|
|
1283
|
+
const x = i => (i / (daily.length - 1)) * (W - 2) + 1
|
|
1284
|
+
const y = v => H - 2 - (v / max) * (H - 4)
|
|
1285
|
+
const segs = []
|
|
1286
|
+
let cur = []
|
|
1287
|
+
daily.forEach((v, i) => {
|
|
1288
|
+
if (v == null) { if (cur.length) segs.push(cur); cur = []; return }
|
|
1289
|
+
cur.push(`${x(i).toFixed(1)},${y(v).toFixed(1)}`)
|
|
1290
|
+
})
|
|
1291
|
+
if (cur.length) segs.push(cur)
|
|
1292
|
+
return `<svg class="spark" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}" role="img" aria-label="30 天每日下载走势,最高 ${num(max)}">` +
|
|
1293
|
+
segs.map(p => (p.length === 1 ? `<circle cx="${p[0].split(',')[0]}" cy="${p[0].split(',')[1]}" r="1.5" fill="${color}"/>` : `<polyline points="${p.join(' ')}" fill="none" stroke="${color}" stroke-width="1.6" stroke-linejoin="round"/>`)).join('') +
|
|
1294
|
+
'</svg>'
|
|
1295
|
+
}
|
|
1296
|
+
/** 在综合榜某个角度里排第几(只在存下来的头部里找) */
|
|
1297
|
+
function angleRank(key, angle) {
|
|
1298
|
+
const o = CAT.boards && CAT.boards.overall
|
|
1299
|
+
if (!o || !o.rows.length || !o.rows[0].a) return null
|
|
1300
|
+
const rows = o.rows.filter(r => r.a[angle] != null)
|
|
1301
|
+
.sort((x, y) => angle === 'new' ? String(y.added || '').localeCompare(String(x.added || '')) || y.a.new - x.a.new : y.a[angle] - x.a[angle])
|
|
1302
|
+
const i = rows.findIndex(r => r.k === key)
|
|
1303
|
+
return i < 0 ? null : i + 1
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
function renderWatchDetail(list) {
|
|
1307
|
+
const sec = $('#secWatchDetail')
|
|
1308
|
+
if (!list.length) { sec.classList.add('hidden'); return }
|
|
1309
|
+
sec.classList.remove('hidden')
|
|
1310
|
+
$('#wdAsOf').textContent = LIVE.at ? `· ${new Date(LIVE.at).toLocaleString()} 刷新` : '· 还没刷新过,先显示目录数据'
|
|
1311
|
+
const recs = list.map(n => ({ n, r: watchRec(n) }))
|
|
1312
|
+
$('#wdHead').innerHTML = '<tr><th>指标</th>' + recs.map(({ n, r }, i) =>
|
|
1313
|
+
`<th><i style="background:${colorOf(i)}"></i>${esc((r && r.label) || n)}</th>`).join('') + '</tr>'
|
|
1314
|
+
const ANG = { rec: '综合', use: '使用', rep: '口碑', stable: '稳定', rise: '增速' }
|
|
1315
|
+
const cell = (r, fn) => (r ? fn(r) : '—')
|
|
1316
|
+
const rows = [
|
|
1317
|
+
['下载'],
|
|
1318
|
+
['30 天每日下载', ({ r }, i) => cell(r, x => (x.daily ? sparkSvg(x.daily, colorOf(i)) : '<span style="color:var(--t3)">刷新后显示</span>'))],
|
|
1319
|
+
['周下载', ({ n, r }) => cell(r, x => (x.w != null ? `<b>${num(x.w)}</b>${changeOf(n, 'w', x.w)}` : '—'))],
|
|
1320
|
+
['上周(前 7 天)', ({ r }) => cell(r, x => {
|
|
1321
|
+
const v = (x.daily || []).filter(d => d != null)
|
|
1322
|
+
return v.length >= 14 ? num(v.slice(-14, -7).reduce((a, b) => a + b, 0)) : '—'
|
|
1323
|
+
})],
|
|
1324
|
+
['日常基线(去噪)', ({ n, r }) => cell(r, x => (x.deep ? `${num(x.deep.base)}/天${changeOf(n, 'base', x.deep.base)}` : '—'))],
|
|
1325
|
+
['近 7 日环比', ({ r }) => cell(r, x => (x.deep && x.deep.growth != null ? `<span class="${x.deep.growth >= 0 ? 'up' : 'down'}">${pct(x.deep.growth)}</span>` : '—'))],
|
|
1326
|
+
['月下载', ({ r }) => cell(r, x => (x.m != null ? num(x.m) : '—'))],
|
|
1327
|
+
['累计下载', ({ r }) => cell(r, x => (x.total != null ? num(x.total) : '—'))],
|
|
1328
|
+
['版本'],
|
|
1329
|
+
['当前版本', ({ r }) => cell(r, x => (x.v ? `v${esc(x.v)}` : '—'))],
|
|
1330
|
+
['最近发版', ({ r }) => cell(r, x => (x.deep && x.deep.lastRelease ? `${esc(x.deep.lastRelease)}<span class="ch flat">${ageText(x.deep.age)}</span>` : '—'))],
|
|
1331
|
+
['版本总数', ({ r }) => cell(r, x => (x.deep && x.deep.versions != null ? num(x.deep.versions) : '—'))],
|
|
1332
|
+
['发版节奏', ({ r }) => cell(r, x => (x.deep && x.deep.cadence != null ? `${x.deep.cadence} 天/版` : '—'))],
|
|
1333
|
+
['健康度', ({ r }) => cell(r, x => (x.deep && x.deep.s != null ? x.deep.s : '—'))],
|
|
1334
|
+
['GitHub'],
|
|
1335
|
+
['星标', ({ n, r }) => cell(r, x => (x.gh ? `${num(x.gh.s)}${changeOf(n, 's', x.gh.s, { asPct: false })}` : '—'))],
|
|
1336
|
+
['Fork', ({ r }) => cell(r, x => (x.gh && x.gh.f != null ? num(x.gh.f) : '—'))],
|
|
1337
|
+
['未关闭 issue / PR', ({ r }) => cell(r, x => (x.gh && x.gh.i != null ? num(x.gh.i) : '—'))],
|
|
1338
|
+
['最近提交', ({ r }) => cell(r, x => (x.gh && x.gh.p ? `${esc(x.gh.p)}${x.gh.a ? '<span class="ch down">已归档</span>' : ''}` : '—'))],
|
|
1339
|
+
['市场位置'],
|
|
1340
|
+
['npm 总榜', ({ n, r }) => cell(r, x => (x.rank ? `#${num(x.rank)}${changeOf(n, 'rank', x.rank, { lowerIsBetter: true, asPct: false })}` : '—'))],
|
|
1341
|
+
['分类排名', ({ r }) => cell(r, x => (x.crank ? `${esc(x.cat)} #${num(x.crank)}` : '—'))],
|
|
1342
|
+
['综合榜排名', ({ n, r }) => cell(r, () => {
|
|
1343
|
+
const parts = Object.entries(ANG).map(([a, label]) => [label, angleRank(n, a)]).filter(([, v]) => v)
|
|
1344
|
+
return parts.length ? parts.map(([l, v]) => `${l} #${v}`).join('<br>') : '<span style="color:var(--t3)">不在各角度前 120 名</span>'
|
|
1345
|
+
})],
|
|
1346
|
+
['综合推荐分', ({ n, r }) => cell(r, x => (x.sc != null ? `${x.sc}${changeOf(n, 'sc', x.sc, { asPct: false })}` : '—'))],
|
|
1347
|
+
['收录于', ({ r }) => cell(r, x => (x.src && x.src.length ? srcChips(x.src, { short: true }) : '—'))],
|
|
1348
|
+
]
|
|
1349
|
+
$('#wdBody').innerHTML = rows.map(([label, fn]) => (fn
|
|
1350
|
+
? `<tr><td>${label}</td>${recs.map((x, i) => `<td>${fn(x, i)}</td>`).join('')}</tr>`
|
|
1351
|
+
: `<tr class="grp"><td colspan="${recs.length + 1}">${label}</td></tr>`)).join('')
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1067
1354
|
async function refreshWatch() {
|
|
1068
1355
|
const list = watch()
|
|
1069
1356
|
if (!list.length) return
|
|
@@ -1076,6 +1363,7 @@ async function refreshWatch() {
|
|
|
1076
1363
|
if (!r.ok) throw new Error(j.error || 'HTTP ' + r.status)
|
|
1077
1364
|
LIVE = { at: j.at, anchor: j.anchor, rows: Object.fromEntries(j.rows.map(x => [x.name, x])) }
|
|
1078
1365
|
try { localStorage.setItem(LIVE_KEY, JSON.stringify(LIVE)) } catch { /* 存不下就只这次有效 */ }
|
|
1366
|
+
saveSnapshots(j.at)
|
|
1079
1367
|
const miss = j.rows.filter(x => !x.found).map(x => x.name)
|
|
1080
1368
|
toast([
|
|
1081
1369
|
miss.length ? `已刷新;npm 上查不到:${miss.join('、')}` : `已刷新 ${j.rows.length} 个插件`,
|
|
@@ -1140,6 +1428,8 @@ function renderWatch() {
|
|
|
1140
1428
|
host.querySelectorAll('[data-rm]').forEach(b =>
|
|
1141
1429
|
b.addEventListener('click', () => saveWatch(watch().filter(x => x !== b.dataset.rm)) || renderWatch()))
|
|
1142
1430
|
|
|
1431
|
+
renderWatchDetail(list)
|
|
1432
|
+
|
|
1143
1433
|
// 对数刻度横条图
|
|
1144
1434
|
const rows = list.map(watchRec).filter(r => r && r.w != null)
|
|
1145
1435
|
const max = Math.max(...rows.map(r => r.w), 1)
|
|
@@ -1154,7 +1444,7 @@ function renderWatch() {
|
|
|
1154
1444
|
|
|
1155
1445
|
/* ---------------- 导出结论(网页版) ---------------- */
|
|
1156
1446
|
function exportHtml() {
|
|
1157
|
-
const rows = picked.map(
|
|
1447
|
+
const rows = picked.map(cmpRec).filter(Boolean)
|
|
1158
1448
|
if (!rows.length) return
|
|
1159
1449
|
const need = $('#need').value.trim()
|
|
1160
1450
|
const verdicts = $('#verdicts').innerHTML
|