dsh-pick 0.6.1 → 0.6.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/package.json +1 -1
- package/web/panel.html +22 -3
- package/web/panel.js +45 -17
package/package.json
CHANGED
package/web/panel.html
CHANGED
|
@@ -119,7 +119,25 @@ table.rank td.nm .desc{min-width:150px;display:-webkit-box;-webkit-line-clamp:2;
|
|
|
119
119
|
.srcchip.off{color:var(--accent);background:var(--accent-bg)}
|
|
120
120
|
.srcchip.gh{color:var(--t3)}
|
|
121
121
|
table.rank td .sc{font-size:13px;font-weight:700;color:var(--text);cursor:help}
|
|
122
|
-
|
|
122
|
+
/* 排行榜操作列的四个图标一样大:+、安装、GitHub、npm,都是 24×22 */
|
|
123
|
+
.ib{appearance:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:22px;padding:0;margin-right:4px;
|
|
124
|
+
border:1px solid var(--line);border-radius:6px;background:var(--panel);color:var(--accent);font-size:12px;line-height:1;vertical-align:top;cursor:default;font-family:inherit}
|
|
125
|
+
button.ib{cursor:pointer}
|
|
126
|
+
button.ib:hover{border-color:var(--accent);background:var(--accent-bg)}
|
|
127
|
+
.ib.inst-ic.confirm{background:var(--accent);border-color:var(--accent);color:#fff}
|
|
128
|
+
.ib.inst-ic:disabled{opacity:.6;cursor:default}
|
|
129
|
+
.ib.in{color:var(--ok-text);background:var(--ok-bg);border-color:transparent}
|
|
130
|
+
.ib.no{color:var(--t3);background:var(--soft);border-color:transparent;cursor:help}
|
|
131
|
+
table.rank .wadd{width:24px;height:22px;font-size:14px}
|
|
132
|
+
/* 综合榜固定列宽:插件名占剩下的空间,太长的省略、简介两行;数字始终看得见 */
|
|
133
|
+
table.rank.ov{table-layout:fixed;min-width:0}
|
|
134
|
+
table.rank.ov th,table.rank.ov td{padding-left:5px;padding-right:5px}
|
|
135
|
+
table.rank.ov td.nm{overflow:hidden}
|
|
136
|
+
table.rank.ov td.nm > .nmline{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
137
|
+
table.rank.ov td.nm .desc{min-width:0}
|
|
138
|
+
table.rank.ov td.nm .chips{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
139
|
+
table.rank.ov .srcchip{margin-right:2px;padding:0 3px}
|
|
140
|
+
table.rank.ov td.lks{width:112px}
|
|
123
141
|
table.rank td .arch{font-size:10.5px;color:var(--t3);background:var(--soft);border-radius:5px;padding:1px 6px}
|
|
124
142
|
.section h2 .h2-acts{margin-left:auto;display:inline-flex;gap:8px;align-items:center}
|
|
125
143
|
.section h2 .h2-acts .ai{margin-left:0}
|
|
@@ -236,7 +254,7 @@ td.down{color:var(--bad);font-weight:600}
|
|
|
236
254
|
/* 我的监控:和排行榜一样一行一个插件,上面是列名。名字和最后的图标宽度固定,
|
|
237
255
|
中间各列用 minmax(0, 1fr) 平分剩下的宽度,栏变窄时一起压缩,放不下的用省略号 */
|
|
238
256
|
/* 数字列留够短写数字(312k、#3088)的最小宽度,不会被截断;压缩主要由「分类」承担 */
|
|
239
|
-
#watchList{--mcols:minmax(84px,3.4fr) minmax(36px,.7fr) minmax(0,1.2fr) minmax(40px,.9fr) minmax(32px,.8fr) minmax(30px,.7fr) minmax(36px,.8fr)
|
|
257
|
+
#watchList{--mcols:minmax(84px,3.4fr) minmax(36px,.7fr) minmax(0,1.2fr) minmax(40px,.9fr) minmax(32px,.8fr) minmax(30px,.7fr) minmax(36px,.8fr) 76px}
|
|
240
258
|
.mrow{display:grid;grid-template-columns:var(--mcols);align-items:center;column-gap:6px;padding:8px 0;border-bottom:1px solid var(--soft);font-size:12px;color:var(--t2)}
|
|
241
259
|
.mrow:last-child{border-bottom:none}
|
|
242
260
|
.mrow.mhead{font-size:11px;color:var(--t3);font-weight:600;padding:0 0 7px;border-bottom:1px solid var(--line)}
|
|
@@ -247,7 +265,8 @@ td.down{color:var(--bad);font-weight:600}
|
|
|
247
265
|
.mrow .nm{font-size:13px;font-weight:650;color:var(--text)}
|
|
248
266
|
.mrow.mhead .nm{font-size:11px;font-weight:600;color:var(--t3)}
|
|
249
267
|
.mrow .ver{color:var(--t3);font-weight:400;font-size:11px}
|
|
250
|
-
|
|
268
|
+
/* 最后一列固定宽度(两个链接图标 + ×):每一行是各自的网格,宽度要是按内容来,表头(空的)和数据行就对不齐 */
|
|
269
|
+
.mrow .acts{display:flex;align-items:center;justify-content:flex-end;overflow:visible;width:76px}
|
|
251
270
|
.mrow .livedot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--ok);margin-right:5px;vertical-align:middle}
|
|
252
271
|
.mrow .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}
|
|
253
272
|
.mrow .x:hover{color:var(--bad)}
|
package/web/panel.js
CHANGED
|
@@ -203,29 +203,47 @@ function checkRow(r) {
|
|
|
203
203
|
`</div>`
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
// 安装的图标:向下的箭头落进托盘(和 GitHub、npm 图标一样 13px)
|
|
207
|
+
const INSTALL_SVG = '<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v8M4.5 6.5 8 10l3.5-3.5M2.5 12.5v1h11v-1"/></svg>'
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 安装区:已安装 / 安装(点一下变「确认」,再点才装)/ 装不了。
|
|
211
|
+
* icon = 排行榜这种窄列:和 GitHub、npm 一样只要一个 24×22 的图标,说明放在悬停提示里
|
|
212
|
+
*/
|
|
213
|
+
function installArea(r, { icon = false } = {}) {
|
|
208
214
|
if (!IN_DSH) return ''
|
|
209
|
-
if (INSTALLED.has(r.n))
|
|
215
|
+
if (INSTALLED.has(r.n)) {
|
|
216
|
+
return icon ? '<span class="ib in" title="已安装">✓</span>' : '<span class="badge-in">✓ 已安装</span>'
|
|
217
|
+
}
|
|
210
218
|
if (!CAN_INSTALL) return ''
|
|
211
|
-
|
|
212
|
-
|
|
219
|
+
const check = installCheck(r)
|
|
220
|
+
if (!check.ok) {
|
|
221
|
+
return icon ? `<span class="ib no" title="不能安装:${esc(check.warn.join(';'))}">⊘</span>` : '<span class="badge-no" title="原因见卡片上的提醒">不能安装</span>'
|
|
222
|
+
}
|
|
223
|
+
return icon
|
|
224
|
+
? `<button class="ib inst-ic" data-install="${esc(r.n)}" data-icon="1" title="安装(点两次:第一次确认)" aria-label="安装 ${esc(r.n)}">${INSTALL_SVG}</button>`
|
|
225
|
+
: `<button class="inst" data-install="${esc(r.n)}" title="用 DSH 的插件管理器安装">安装</button>`
|
|
213
226
|
}
|
|
214
227
|
|
|
215
228
|
async function onInstallClick(btn) {
|
|
216
229
|
const name = btn.dataset.install
|
|
230
|
+
const icon = btn.dataset.icon === '1' // 图标按钮:不换文字,只换样式和提示
|
|
231
|
+
const label = text => { if (!icon) btn.textContent = text }
|
|
217
232
|
if (!btn.classList.contains('confirm')) {
|
|
218
233
|
btn.classList.add('confirm')
|
|
219
|
-
|
|
234
|
+
label('确认安装?')
|
|
235
|
+
if (icon) { btn.title = `再点一次,安装 ${name}`; toast(`再点一次安装按钮,确认安装 ${name}`) }
|
|
220
236
|
setTimeout(() => {
|
|
221
237
|
if (btn.isConnected && btn.classList.contains('confirm') && !btn.disabled) {
|
|
222
|
-
btn.classList.remove('confirm');
|
|
238
|
+
btn.classList.remove('confirm'); label('安装')
|
|
239
|
+
if (icon) btn.title = '安装(点两次:第一次确认)'
|
|
223
240
|
}
|
|
224
241
|
}, 4000)
|
|
225
242
|
return
|
|
226
243
|
}
|
|
227
244
|
btn.disabled = true
|
|
228
|
-
|
|
245
|
+
label('安装中…')
|
|
246
|
+
if (icon) toast(`正在安装 ${name}…`)
|
|
229
247
|
try {
|
|
230
248
|
const r = await fetch('/api-dsh-pick/install', {
|
|
231
249
|
method: 'POST',
|
|
@@ -246,7 +264,7 @@ async function onInstallClick(btn) {
|
|
|
246
264
|
}
|
|
247
265
|
btn.disabled = false
|
|
248
266
|
btn.classList.remove('confirm')
|
|
249
|
-
|
|
267
|
+
label('安装')
|
|
250
268
|
}
|
|
251
269
|
|
|
252
270
|
/* ---------------- 排名文案与外链按钮 ---------------- */
|
|
@@ -664,9 +682,14 @@ function renderOuterBoard(board) {
|
|
|
664
682
|
}
|
|
665
683
|
|
|
666
684
|
/** 「收录于」的市场名 */
|
|
667
|
-
const MARKET_LABEL = { dshmarket: 'dshmarket', 'dsh-m': 'dsh-m 精选', shop: '商店', official: '官方' }
|
|
668
|
-
|
|
669
|
-
|
|
685
|
+
const MARKET_LABEL = { dshmarket: 'dshmarket', 'dsh-m': 'dsh-m 精选', shop: 'dsh-plugin-shop 商店', official: 'DeepSeek 官方' }
|
|
686
|
+
// 排行榜那种窄列里用短名(悬停看全名)
|
|
687
|
+
const MARKET_SHORT = { dshmarket: 'dshm', 'dsh-m': '精选', shop: '商店', official: '官方' }
|
|
688
|
+
function srcChips(src, { short = false } = {}) {
|
|
689
|
+
return (src || []).map(k => {
|
|
690
|
+
const full = MARKET_LABEL[k] || k
|
|
691
|
+
return `<span class="srcchip${k === 'official' ? ' off' : ''}" title="收录于 ${esc(full)}">${esc(short ? MARKET_SHORT[k] || k : full)}</span>`
|
|
692
|
+
}).join('')
|
|
670
693
|
}
|
|
671
694
|
|
|
672
695
|
/**
|
|
@@ -689,8 +712,12 @@ function renderOverall() {
|
|
|
689
712
|
.map(r => ({ r, rec: r.n ? CAT.packages[r.n] : null }))
|
|
690
713
|
.filter(({ rec }) => !cat || (rec && rec.cat === cat))
|
|
691
714
|
.slice(0, 60)
|
|
692
|
-
|
|
693
|
-
|
|
715
|
+
// 固定列宽(table.ov):数字列和操作列宽度固定,插件名占剩下的;不然简介把名字一列撑得很宽,
|
|
716
|
+
// 右边固定的操作列正好盖住数字
|
|
717
|
+
$('#rankHead').innerHTML = '<tr><th style="width:26px">#</th><th>插件</th>' +
|
|
718
|
+
'<th class="r" style="width:34px" title="综合分 0~100">综合</th><th class="r" style="width:44px">周下载</th>' +
|
|
719
|
+
'<th class="r" style="width:38px" title="GitHub 星标">★</th><th class="r" style="width:46px" title="最近一次发版或提交">最近</th>' +
|
|
720
|
+
'<th style="width:112px"></th></tr>'
|
|
694
721
|
$('#rankBody').innerHTML = rows.map(({ r, rec }, i) => {
|
|
695
722
|
const name = r.n || r.name
|
|
696
723
|
const v = rec ? rec.v : r.v
|
|
@@ -700,11 +727,11 @@ function renderOverall() {
|
|
|
700
727
|
const why = `使用 ${pu} · 关注 ${ps} · 维护 ${pm} · 共识 ${pc} · 健康 ${ph}(各项 0~100)`
|
|
701
728
|
const age = daysSince(r.last)
|
|
702
729
|
// 能装的:目录里的 npm 包按装前检查给按钮;官方插件不在目录里,名字核对过,也能装
|
|
703
|
-
const inst = r.n ? installArea(rec || { n: r.n }) : ''
|
|
730
|
+
const inst = r.n ? installArea(rec || { n: r.n }, { icon: true }) : ''
|
|
704
731
|
const links = linkBtns(rec || { n: r.n || '', ghUrl: r.repo || '' }, { icon: true })
|
|
705
732
|
return `<tr><td style="color:var(--t3)">${i + 1}</td>` +
|
|
706
|
-
`<td class="nm">${esc(name)}${v ? ` <span style="color:var(--t3);font-weight:400;font-size:11px">v${esc(v)}</span>` : ''}
|
|
707
|
-
`<div>${srcChips(r.src)}${r.n ? '' : '<span class="srcchip gh"
|
|
733
|
+
`<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>` +
|
|
734
|
+
`<div class="chips">${srcChips(r.src, { short: true })}${r.n ? '' : '<span class="srcchip gh" title="只在 GitHub,没发到 npm">GitHub</span>'}</div>` +
|
|
708
735
|
(desc ? `<div class="sub desc" title="${esc(desc)}">${esc(desc)}</div>` : '') + `</td>` +
|
|
709
736
|
`<td class="r"><span class="sc" title="${why}">${r.sc}</span></td>` +
|
|
710
737
|
`<td class="r">${w != null ? short(w) : '—'}</td>` +
|
|
@@ -716,6 +743,7 @@ function renderOverall() {
|
|
|
716
743
|
|
|
717
744
|
function renderRank() {
|
|
718
745
|
const board = rankBoard()
|
|
746
|
+
document.querySelector('table.rank').classList.toggle('ov', board === 'overall')
|
|
719
747
|
if (board === 'overall') {
|
|
720
748
|
$('#rankCat').classList.remove('hidden')
|
|
721
749
|
renderOverall()
|