dsh-pick 0.5.0 → 0.5.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/package.json +1 -1
- package/web/panel.html +10 -4
- package/web/panel.js +40 -18
package/package.json
CHANGED
package/web/panel.html
CHANGED
|
@@ -228,13 +228,19 @@ td.down{color:var(--bad);font-weight:600}
|
|
|
228
228
|
.catpill{font-size:10.5px;background:var(--soft);color:var(--t2);border-radius:20px;padding:2px 8px;white-space:nowrap}
|
|
229
229
|
|
|
230
230
|
/* ---------- 监控 ---------- */
|
|
231
|
-
.mon{
|
|
231
|
+
.mon{border-bottom:1px solid var(--soft)}
|
|
232
232
|
.mon:last-child{border-bottom:none}
|
|
233
|
-
.mon .
|
|
233
|
+
.mon .mhead{display:flex;align-items:center;gap:6px;padding:8px 0;cursor:pointer}
|
|
234
|
+
.mon .mhead:hover .nm{color:var(--accent)}
|
|
235
|
+
.mon .mtoggle{appearance:none;border:none;background:none;color:var(--t3);cursor:pointer;font-size:11px;width:16px;padding:0;flex:none}
|
|
236
|
+
.mon .nm{font-size:13px;font-weight:650;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
237
|
+
.mon .ver{color:var(--t3);font-weight:400;font-size:11px}
|
|
238
|
+
.mon .mdetail{display:flex;flex-wrap:wrap;align-items:center;gap:5px 12px;padding:0 0 10px 22px;font-size:12px;color:var(--t2)}
|
|
239
|
+
.mon .mdetail b{color:var(--text)}
|
|
234
240
|
.mon .mrank{font-size:10.5px;color:var(--t3);font-variant-numeric:tabular-nums}
|
|
235
241
|
.mon .mrank b{color:var(--t2);font-weight:700}
|
|
236
|
-
.mon .mlinks{display:flex;
|
|
237
|
-
.mon .x{appearance:none;border:none;background:none;color:var(--t3);cursor:pointer;font-size:16px;padding:0 4px}
|
|
242
|
+
.mon .mlinks{display:flex;flex:none}
|
|
243
|
+
.mon .x{appearance:none;border:none;background:none;color:var(--t3);cursor:pointer;font-size:16px;line-height:1;padding:0 2px 0 4px;flex:none}
|
|
238
244
|
.mon .x:hover{color:var(--bad)}
|
|
239
245
|
|
|
240
246
|
.foot{font-size:11.5px;color:var(--t3);line-height:1.9;margin-top:6px}
|
package/web/panel.js
CHANGED
|
@@ -850,6 +850,9 @@ async function refreshWatch() {
|
|
|
850
850
|
renderWatch()
|
|
851
851
|
}
|
|
852
852
|
|
|
853
|
+
/** 我的监控里展开着的插件(只在这次打开期间记住) */
|
|
854
|
+
const watchOpen = new Set()
|
|
855
|
+
|
|
853
856
|
function renderWatch() {
|
|
854
857
|
const list = watch()
|
|
855
858
|
$('#watchCount').textContent = list.length ? ` (${list.length})` : ''
|
|
@@ -866,29 +869,48 @@ function renderWatch() {
|
|
|
866
869
|
|
|
867
870
|
host.innerHTML = list.map(n => {
|
|
868
871
|
const r = watchRec(n)
|
|
869
|
-
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
let
|
|
873
|
-
if (r
|
|
874
|
-
const
|
|
875
|
-
|
|
872
|
+
const name = r ? esc(r.label || n) : esc(n)
|
|
873
|
+
const ver = r && r.v ? ` <span class="ver">v${esc(r.v)}</span>` : ''
|
|
874
|
+
const open = watchOpen.has(n)
|
|
875
|
+
let detail = '<span>不在目录中,点「刷新」去 npm 查</span>'
|
|
876
|
+
if (r) {
|
|
877
|
+
const d = r.deep
|
|
878
|
+
// 和目录数据比,周下载涨了还是跌了(只在刷新过、差得明显时标)
|
|
879
|
+
let delta = ''
|
|
880
|
+
if (r.live && r.catalogW) {
|
|
881
|
+
const ch = (r.w - r.catalogW) / Math.max(r.catalogW, 1)
|
|
882
|
+
if (Math.abs(ch) >= 0.05) delta = `<span class="delta ${ch > 0 ? 'up' : 'down'}" title="和目录数据(截止 ${esc(CAT.anchor)})相比">${ch > 0 ? '↑' : '↓'}${Math.round(Math.abs(ch) * 100)}%</span>`
|
|
883
|
+
}
|
|
884
|
+
detail = (r.live ? '<span class="live" title="刚从 npm / GitHub 查的">实时</span>' : '') +
|
|
885
|
+
`<span class="mrank">${rankText(r)}</span>` +
|
|
886
|
+
`<span>${esc(r.cat)}</span>` +
|
|
887
|
+
(r.w != null ? `<span><b>${num(r.w)}</b>/周${delta}</span>` : '') +
|
|
888
|
+
(r.w != null ? `<span>基线 ${d ? num(d.base) : '—'}</span>` : '') +
|
|
889
|
+
(r.gh ? `<span title="GitHub · 最近提交 ${esc(r.gh.p || '—')}">★ ${short(r.gh.s)}${r.gh.a ? ' · 已归档' : ''}</span>` : '') +
|
|
890
|
+
(d ? `<span>${ageText(d.age)}发版</span>` : '')
|
|
876
891
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
`<
|
|
886
|
-
|
|
887
|
-
`<button class="x" data-rm="${esc(n)}">×</button></div>`
|
|
892
|
+
// 一个插件一行:名字占满中间,最后是链接图标和移除;其余数据折叠,点这一行展开
|
|
893
|
+
return `<div class="mon${open ? ' open' : ''}">` +
|
|
894
|
+
`<div class="mhead" data-toggle="${esc(n)}">` +
|
|
895
|
+
`<button class="mtoggle" aria-expanded="${open}" aria-label="${open ? '收起' : '展开'} ${name} 的数据">${open ? '▾' : '▸'}</button>` +
|
|
896
|
+
`<span class="nm" title="${name}">${name}${ver}</span>` +
|
|
897
|
+
(r ? `<span class="mlinks">${linkBtns(r, { icon: true })}</span>` : '') +
|
|
898
|
+
`<button class="x" data-rm="${esc(n)}" title="从我的监控移除" aria-label="移除 ${name}">×</button>` +
|
|
899
|
+
`</div>` +
|
|
900
|
+
(open ? `<div class="mdetail">${detail}</div>` : '') +
|
|
901
|
+
`</div>`
|
|
888
902
|
}).join('')
|
|
889
903
|
|
|
890
904
|
host.querySelectorAll('[data-rm]').forEach(b =>
|
|
891
905
|
b.addEventListener('click', () => saveWatch(watch().filter(x => x !== b.dataset.rm)) || renderWatch()))
|
|
906
|
+
host.querySelectorAll('[data-toggle]').forEach(row =>
|
|
907
|
+
row.addEventListener('click', e => {
|
|
908
|
+
if (e.target.closest('a, [data-rm]')) return
|
|
909
|
+
const n = row.dataset.toggle
|
|
910
|
+
if (watchOpen.has(n)) watchOpen.delete(n)
|
|
911
|
+
else watchOpen.add(n)
|
|
912
|
+
renderWatch()
|
|
913
|
+
}))
|
|
892
914
|
|
|
893
915
|
// 对数刻度横条图
|
|
894
916
|
const rows = list.map(watchRec).filter(r => r && r.w != null)
|