dsh-pick 0.4.0 → 0.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-pick",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "帮你在 DSH 生态里选对插件:说需求 → 找候选 → 多维比较 → 出结论。下载量是证据,AI 是推理。",
5
5
  "type": "module",
6
6
  "main": "./plugin/index.js",
package/web/panel.html CHANGED
@@ -192,7 +192,15 @@ table.rank th{text-align:left;font-size:11px;color:var(--t3);font-weight:600;pad
192
192
  table.rank td{padding:9px 10px;border-bottom:1px solid var(--soft);color:var(--t2);font-variant-numeric:tabular-nums}
193
193
  table.rank tbody tr:hover td{background:var(--row-hover)}
194
194
  table.rank td.nm{color:var(--text);font-weight:650;font-variant-numeric:normal}
195
- td.r,th.r{text-align:right}
195
+ td.r,th.r{text-align:right;white-space:nowrap}
196
+ /* 「更新」一格:最近发版 + 小字节奏 */
197
+ table.rank td.mt{line-height:1.35}
198
+ table.rank td.mt .sub{font-size:10.5px;color:var(--t3)}
199
+ table.rank td.mt .stale{color:var(--warn-text);font-weight:600}
200
+ /* 只有图标的外链(排行榜) */
201
+ table.rank td.lks{white-space:nowrap;width:1%}
202
+ .lk.ic{padding:0;width:24px;height:22px;justify-content:center;gap:0}
203
+ .lk.ic + .lk.ic{margin-left:4px}
196
204
  td.up{color:var(--ok);font-weight:600}
197
205
  td.down{color:var(--bad);font-weight:600}
198
206
  .catpill{font-size:10.5px;background:var(--soft);color:var(--t2);border-radius:20px;padding:2px 8px;white-space:nowrap}
@@ -347,7 +355,7 @@ td.down{color:var(--bad);font-weight:600}
347
355
  <thead><tr>
348
356
  <th style="width:44px">#</th><th>插件</th><th>分类</th>
349
357
  <th class="r">基线</th><th class="r">周下载</th><th class="r">环比</th>
350
- <th class="r">版本节奏</th><th class="r">最近更新</th><th>链接</th>
358
+ <th class="r" title="最近一次发版 · 平均几天发一个版本">更新</th><th></th>
351
359
  </tr></thead>
352
360
  <tbody id="rankBody"></tbody>
353
361
  </table>
package/web/panel.js CHANGED
@@ -251,15 +251,42 @@ function rankText(rec) {
251
251
  }
252
252
 
253
253
  const GH_SVG = '<svg viewBox="0 0 16 16" width="13" height="13" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.4 7.4 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A7.99 7.99 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>'
254
- const NPM_SVG = '<svg viewBox="0 0 16 16" width="13" height="13" fill="currentColor"><path d="M0 0h16v16H0V0zm3.2 12.8V3.2h2.4v9.6H3.2zm3.6 0V3.2h5.6v6.4H8.8v3.2H6.8zM8.8 6.4v3.2h1.6V6.4H8.8z"/></svg>'
254
+ // npm 的方块标志(中间一个 n):缩到 13px 也认得出;颜色用 npm 的红
255
+ const NPM_SVG = '<svg viewBox="0 0 16 16" width="13" height="13"><path fill="#cb3837" d="M0 0h16v16H0z"/><path fill="#fff" d="M3 3h10v10h-2.5V5.5H8V13H3z"/></svg>'
255
256
 
256
- function linkBtns(rec) {
257
+ /**
258
+ * 外链按钮。icon = 只要图标(排行榜这种窄列):悬停看得到完整地址
259
+ */
260
+ function linkBtns(rec, { icon = false } = {}) {
261
+ const npm = rec.npmUrl || ('https://www.npmjs.com/package/' + rec.n)
262
+ const cls = icon ? 'lk ic' : 'lk'
257
263
  let h = ''
258
264
  if (rec.ghUrl) {
259
- h += `<a class="lk" href="${esc(rec.ghUrl)}" target="_blank" rel="noopener" title="GitHub:${esc(rec.ghUrl)}">${GH_SVG}GitHub</a>`
265
+ h += `<a class="${cls}" href="${esc(rec.ghUrl)}" target="_blank" rel="noopener" title="GitHub:${esc(rec.ghUrl)}" aria-label="GitHub">${GH_SVG}${icon ? '' : 'GitHub'}</a>`
260
266
  }
261
- h += `<a class="lk" href="${esc(rec.npmUrl || ('https://www.npmjs.com/package/' + rec.n))}" target="_blank" rel="noopener" title="npm:${esc(rec.npmUrl || rec.n)}">${NPM_SVG}npm</a>`
262
- return h || '<span style="font-size:11px;color:var(--t3)">无外链</span>'
267
+ h += `<a class="${cls}" href="${esc(npm)}" target="_blank" rel="noopener" title="npm:${esc(npm)}" aria-label="npm">${NPM_SVG}${icon ? '' : 'npm'}</a>`
268
+ return h
269
+ }
270
+
271
+ /** 最近一次发版:今天 / 昨天 / N天前 / N个月前 */
272
+ function ageText(age) {
273
+ if (age == null) return '—'
274
+ if (age <= 0) return '今天'
275
+ if (age === 1) return '昨天'
276
+ if (age < 60) return `${age}天前`
277
+ return `${Math.round(age / 30)}个月前`
278
+ }
279
+
280
+ /**
281
+ * 「更新」一格:上面最近一次发版,下面小字写版本节奏。两行都不折行,
282
+ * 比分成两列(窄栏里每列都被挤成「8 / 天 / 前」三行)省地方也整齐。超过 90 天没发版用提醒色
283
+ */
284
+ function maintCell(d) {
285
+ if (!d) return '<td class="r mt">—</td>'
286
+ const stale = d.age != null && d.age > 90
287
+ const cad = d.cadence == null ? '' : `<div class="sub">${d.cadence}天/版</div>`
288
+ return `<td class="r mt" title="最近一次发版 ${d.lastRelease || ''}${d.cadence == null ? '' : ` · 平均 ${d.cadence} 天发一个版本`}">` +
289
+ `<div${stale ? ' class="stale"' : ''}>${ageText(d.age)}</div>${cad}</td>`
263
290
  }
264
291
 
265
292
  /* ---------------- 搜索(与 lib/engine.js 共用同一份词典 lib/words.js) --------------- */
@@ -564,9 +591,8 @@ function renderRank() {
564
591
  `<td class="r"><b>${num(val(r))}</b></td>` +
565
592
  `<td class="r">${num(r.w)}</td>` +
566
593
  `<td class="r ${g === null ? '' : (g >= 0 ? 'up' : 'down')}">${pct(g)}</td>` +
567
- `<td class="r">${d && d.cadence !== null ? d.cadence + ' 天' : '—'}</td>` +
568
- `<td class="r">${d ? d.age + ' 天前' : '—'}</td>` +
569
- `<td style="white-space:nowrap">${linkBtns(r)}</td>` +
594
+ maintCell(d) +
595
+ `<td class="lks">${linkBtns(r, { icon: true })}</td>` +
570
596
  `</tr>`
571
597
  }).join('')
572
598
  }