dsh-pick 0.7.1 → 0.7.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 +4 -2
- package/data/catalog.json +1 -1
- package/lib/boards.js +20 -3
- package/lib/engine.js +55 -13
- package/lib/overall.js +19 -1
- package/package.json +1 -1
- package/plugin/client.js +12 -3
- package/plugin/index.js +2 -0
- package/plugin/tools.js +1 -1
- package/web/panel.html +26 -2
- package/web/panel.js +152 -36
package/lib/boards.js
CHANGED
|
@@ -148,12 +148,29 @@ async function loadOfficial(fetchImpl) {
|
|
|
148
148
|
return { total: rows.length, rows }
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
/** 下载插件商店的目录和星标表。构建时只下一次,补目录和商店榜共用 */
|
|
152
|
+
export async function loadShopDocs(fetchImpl = globalThis.fetch) {
|
|
152
153
|
const index = await getJson(fetchImpl, `${SHOP_BASE}index.json`, 30000)
|
|
153
154
|
const [plugins, stars] = await Promise.all([
|
|
154
155
|
getJson(fetchImpl, SHOP_BASE + index.plugins.url, 180000),
|
|
155
156
|
getJson(fetchImpl, SHOP_BASE + index.stars.url, 60000),
|
|
156
157
|
])
|
|
158
|
+
return { plugins, stars }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** 插件商店里发到 npm 的包(包名校验过):补进 npm 目录用。商店不给下载量 */
|
|
162
|
+
export function shopPackages(plugins) {
|
|
163
|
+
const list = Array.isArray(plugins) ? plugins : (plugins && plugins.plugins) || []
|
|
164
|
+
const out = new Map()
|
|
165
|
+
for (const p of list) {
|
|
166
|
+
const n = p && p.source === 'npm' ? npmName(p.name) : null
|
|
167
|
+
if (n && !out.has(n)) out.set(n, { n, m: 0, repo: repoUrl(p.repository) })
|
|
168
|
+
}
|
|
169
|
+
return [...out.values()]
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function loadShop(fetchImpl, members, docs) {
|
|
173
|
+
const { plugins, stars } = docs || await loadShopDocs(fetchImpl)
|
|
157
174
|
const board = shopBoard(plugins, stars)
|
|
158
175
|
members.shop = board.all
|
|
159
176
|
delete board.all
|
|
@@ -182,7 +199,7 @@ export function picksMembers(doc) {
|
|
|
182
199
|
* @param {object} [opt.previous] 上一次的 boards
|
|
183
200
|
* @param {object} [opt.communityDoc] 已经下载好的社区目录,有就不再下一次
|
|
184
201
|
*/
|
|
185
|
-
export async function buildBoards({ fetchImpl = globalThis.fetch, previous = {}, communityDoc = null, members = {}, onProgress = () => {} } = {}) {
|
|
202
|
+
export async function buildBoards({ fetchImpl = globalThis.fetch, previous = {}, communityDoc = null, shopDocs = null, members = {}, onProgress = () => {} } = {}) {
|
|
186
203
|
// members:各市场的完整收录名单(综合榜算「收录于」要用),不落盘;抓不到的那个市场留 null
|
|
187
204
|
members.community = null
|
|
188
205
|
members.shop = null
|
|
@@ -201,7 +218,7 @@ export async function buildBoards({ fetchImpl = globalThis.fetch, previous = {},
|
|
|
201
218
|
delete board.all
|
|
202
219
|
return board
|
|
203
220
|
},
|
|
204
|
-
shop: () => loadShop(fetchImpl, members),
|
|
221
|
+
shop: () => loadShop(fetchImpl, members, shopDocs),
|
|
205
222
|
}
|
|
206
223
|
try {
|
|
207
224
|
members.picks = picksMembers(await getJson(fetchImpl, PICKS_URL, 30000))
|
package/lib/engine.js
CHANGED
|
@@ -13,7 +13,7 @@ import { classify } from './classify.js'
|
|
|
13
13
|
import { expandWords } from './words.js'
|
|
14
14
|
import { baselineWithStart, growth, cadence, ageDays, score, sum } from './metrics.js'
|
|
15
15
|
import { parseRepo, fetchRepos, fetchRepoLive, countsForPlugin } from './github.js'
|
|
16
|
-
import { buildBoards, communityPackages, loadCommunity, repoUrl } from './boards.js'
|
|
16
|
+
import { buildBoards, communityPackages, loadCommunity, loadShopDocs, shopPackages, repoUrl } from './boards.js'
|
|
17
17
|
import { buildOverall } from './overall.js'
|
|
18
18
|
|
|
19
19
|
const PKG_ROOT = fileURLToPath(new URL('..', import.meta.url))
|
|
@@ -165,6 +165,7 @@ export async function buildCatalog({ deep = 200, max = 2250, pages = 9, deepOnly
|
|
|
165
165
|
const records = new Map()
|
|
166
166
|
const previous = await readJson(CATALOG_PATH)
|
|
167
167
|
let communityDoc = null
|
|
168
|
+
let shopDocs = null
|
|
168
169
|
|
|
169
170
|
if (deepOnly) {
|
|
170
171
|
const prev = await loadCatalog()
|
|
@@ -206,10 +207,19 @@ export async function buildCatalog({ deep = 200, max = 2250, pages = 9, deepOnly
|
|
|
206
207
|
} catch (e) {
|
|
207
208
|
onProgress(`社区目录抓不到(${e.message}),沿用上次目录里的包`)
|
|
208
209
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
// 插件商店里发到 npm 的包也补进来:商店收录的比社区目录还多,只看社区目录覆盖不全
|
|
211
|
+
try {
|
|
212
|
+
shopDocs = await loadShopDocs()
|
|
213
|
+
} catch (e) {
|
|
214
|
+
onProgress(`插件商店抓不到(${e.message}),沿用上次目录里的包`)
|
|
215
|
+
}
|
|
216
|
+
const fromPrevious = () => Object.values((previous && previous.packages) || {}).map(r => ({ n: r.n, m: r.m, repo: repoUrl(r.repo) }))
|
|
217
|
+
const merged = new Map()
|
|
218
|
+
for (const r of [
|
|
219
|
+
...(communityDoc ? communityPackages(communityDoc) : fromPrevious()),
|
|
220
|
+
...(shopDocs ? shopPackages(shopDocs.plugins) : fromPrevious()),
|
|
221
|
+
]) if (!merged.has(r.n)) merged.set(r.n, r)
|
|
222
|
+
await addCommunity(records, [...merged.values()], { previous: previous && previous.packages, onProgress })
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
// 分类:**全部**目录都要有(v1 只给深挖目标分了类,导致其余全是 undefined)
|
|
@@ -325,7 +335,7 @@ export async function buildCatalog({ deep = 200, max = 2250, pages = 9, deepOnly
|
|
|
325
335
|
// npm、GitHub 之外的榜单:官方、社区、插件商店(抓不到的沿用上次)
|
|
326
336
|
onProgress('其他榜单…')
|
|
327
337
|
const members = {}
|
|
328
|
-
const boards = await buildBoards({ previous: previous && previous.boards, communityDoc, members, onProgress })
|
|
338
|
+
const boards = await buildBoards({ previous: previous && previous.boards, communityDoc, shopDocs, members, onProgress })
|
|
329
339
|
|
|
330
340
|
// 综合榜:几个市场合成一个榜,一个插件一行;顺带给每个 npm 包写上综合分 sc 和「收录于」src
|
|
331
341
|
const previousSrc = {}
|
|
@@ -364,13 +374,27 @@ export async function buildCatalog({ deep = 200, max = 2250, pages = 9, deepOnly
|
|
|
364
374
|
* @param {string} [opt.today] YYYY-MM-DD,决定今天轮到哪些带 scope 的包(见 weeklyDue)
|
|
365
375
|
* @returns {Promise<number>} 补进去几个
|
|
366
376
|
*/
|
|
367
|
-
export async function addCommunity(records, rows, {
|
|
377
|
+
export async function addCommunity(records, rows, {
|
|
378
|
+
previous = {}, today = new Date().toISOString().slice(0, 10), wait = 800, onProgress = () => {},
|
|
379
|
+
manifestRotation = MANIFEST_ROTATION, newPerDay = NEW_PER_DAY, newScopedWeekly = NEW_SCOPED_WEEKLY,
|
|
380
|
+
} = {}) {
|
|
368
381
|
const missing = rows.filter(r => !records.has(r.n))
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
382
|
+
// npm 注册表对 GitHub Actions 限流很狠(四千多个 manifest 要读四十分钟),不能每天全读:
|
|
383
|
+
// 上次目录里有完整记录的,按包名分 manifestRotation 组轮着重读,没轮到的沿用上次的;
|
|
384
|
+
// 第一次见到的,每天最多读 newPerDay 个(按插件市场给的下载量从高到低),其余明天接着补
|
|
385
|
+
const complete = r => Boolean(r && r.v && r.inst)
|
|
386
|
+
const reuse = missing.filter(r => complete(previous[r.n]) && !rotationDue(r.n, today, manifestRotation))
|
|
387
|
+
const known = missing.filter(r => complete(previous[r.n]) && rotationDue(r.n, today, manifestRotation))
|
|
388
|
+
const fresh = missing.filter(r => !complete(previous[r.n])).sort((a, b) => (b.m || 0) - (a.m || 0))
|
|
389
|
+
const freshToday = fresh.slice(0, newPerDay)
|
|
390
|
+
const deferred = fresh.length - freshToday.length
|
|
391
|
+
const toRead = [...known, ...freshToday]
|
|
392
|
+
onProgress(`插件市场里 ${rows.length} 个 npm 包,其中 ${missing.length} 个搜索接口没翻到:` +
|
|
393
|
+
`${reuse.length} 个沿用上次的(轮着重读),读 manifest ${toRead.length} 个(新的 ${freshToday.length} 个${deferred ? `,另有 ${deferred} 个新的明天再补` : ''})…`)
|
|
394
|
+
const got = await fetchManifests(toRead.map(r => r.n), { wait, onProgress })
|
|
395
|
+
const added = reuse.map(r => ({ ...previous[r.n] }))
|
|
372
396
|
let gone = 0, reused = 0, lost = 0
|
|
373
|
-
for (const row of
|
|
397
|
+
for (const row of toRead) {
|
|
374
398
|
const res = got.get(row.n)
|
|
375
399
|
if (res.status === 'ok') {
|
|
376
400
|
const rec = communityRecord(row, res.data)
|
|
@@ -393,7 +417,9 @@ export async function addCommunity(records, rows, { previous = {}, today = new D
|
|
|
393
417
|
// 不带 scope 的批量查,每天全查;带 scope 的只能逐个查,下载量接口经不起(几百个包在 Actions 上要排队二十多分钟),
|
|
394
418
|
// 所以每天只查轮到的那组和上次没有数的,其余沿用上次的
|
|
395
419
|
const prevW = n => previous?.[n]?.w
|
|
396
|
-
|
|
420
|
+
// 第一次见到的带 scope 包也有上限:一下子几千个逐个查要排好几个小时;没轮到的先记 0,几天内轮到
|
|
421
|
+
let newScoped = 0
|
|
422
|
+
const due = added.filter(r => !r.n.startsWith('@') || weeklyDue(r.n, today) || (prevW(r.n) == null && newScoped++ < newScopedWeekly))
|
|
397
423
|
onProgress(` 周下载 ${due.length} 个(带 scope 的 ${added.length - due.length} 个今天没轮到,沿用上次的)…`)
|
|
398
424
|
const weekly = await fetchWeekly(due.map(r => r.n), onProgress)
|
|
399
425
|
let stale = 0
|
|
@@ -465,7 +491,23 @@ async function fetchWeekly(names, onProgress = () => {}) {
|
|
|
465
491
|
}
|
|
466
492
|
|
|
467
493
|
/** 带 scope 的包分几天轮着查周下载 */
|
|
468
|
-
export const WEEKLY_ROTATION =
|
|
494
|
+
export const WEEKLY_ROTATION = 5
|
|
495
|
+
/** 插件市场补进来的包分几天轮着重读 manifest(版本、说明、安装信息) */
|
|
496
|
+
export const MANIFEST_ROTATION = 4
|
|
497
|
+
/** 每天最多读几个第一次见到的包的 manifest */
|
|
498
|
+
export const NEW_PER_DAY = 3000
|
|
499
|
+
/** 每天最多逐个查几个第一次见到、还没轮到的带 scope 包的周下载 */
|
|
500
|
+
export const NEW_SCOPED_WEEKLY = 300
|
|
501
|
+
|
|
502
|
+
/** 按包名分进 n 组,今天轮不轮到这一组(不记状态,每隔 n 天正好轮到一次) */
|
|
503
|
+
export function rotationDue(name, today, n) {
|
|
504
|
+
if (n <= 1) return true
|
|
505
|
+
let h = 0
|
|
506
|
+
for (const ch of name) h = (h * 31 + ch.codePointAt(0)) >>> 0
|
|
507
|
+
const day = Math.floor(Date.parse(today + 'T00:00:00Z') / 86400000)
|
|
508
|
+
// 和周下载的轮换错开(同一个哈希会让两件事总落在同一天)
|
|
509
|
+
return (h >>> 3) % n === day % n
|
|
510
|
+
}
|
|
469
511
|
|
|
470
512
|
/**
|
|
471
513
|
* 这个带 scope 的包今天轮不轮到查周下载:按包名分进 WEEKLY_ROTATION 组,一天查一组。
|
package/lib/overall.js
CHANGED
|
@@ -102,6 +102,7 @@ export function stableScore({ firstDays, cadence, license, issues, stars }) {
|
|
|
102
102
|
*/
|
|
103
103
|
export function buildOverall({ packages, members, previousSrc = {}, now = Date.now() }) {
|
|
104
104
|
const cands = new Map() // key → 候选
|
|
105
|
+
const uncataloged = new Set()
|
|
105
106
|
const npmKey = n => `npm:${n}`
|
|
106
107
|
for (const rec of Object.values(packages)) {
|
|
107
108
|
cands.set(npmKey(rec.n), { key: npmKey(rec.n), n: rec.n, rec, src: new Set(), stars: rec.gh ? rec.gh.s : null, repo: rec.ghUrl || rec.repo || null })
|
|
@@ -136,7 +137,11 @@ export function buildOverall({ packages, members, previousSrc = {}, now = Date.n
|
|
|
136
137
|
c = { key: npmKey(m.n), n: m.n, rec, src: new Set(), stars: null, repo: null, outside: true }
|
|
137
138
|
cands.set(c.key, c)
|
|
138
139
|
}
|
|
139
|
-
if (!c)
|
|
140
|
+
if (!c) {
|
|
141
|
+
// npm 名字不在目录里:每日构建一天只补一部分新包,或者 npm 上已经没有了。算进覆盖数,暂时不参与排名
|
|
142
|
+
if (m.n) uncataloged.add(m.n)
|
|
143
|
+
continue
|
|
144
|
+
}
|
|
140
145
|
c.src.add(market)
|
|
141
146
|
if (c.stars == null && Number.isFinite(m.s)) c.stars = m.s
|
|
142
147
|
// 第一次被市场收录的日期(「新上架」「稳定可靠」要用)
|
|
@@ -144,6 +149,18 @@ export function buildOverall({ packages, members, previousSrc = {}, now = Date.n
|
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
|
|
152
|
+
// 覆盖范围:几个市场 + npm 搜索合起来、去重后一共多少个插件(一票否决之前),其中多少发到了 npm
|
|
153
|
+
const all = [...cands.values()]
|
|
154
|
+
const cover = {
|
|
155
|
+
all: all.length + uncataloged.size,
|
|
156
|
+
npm: all.filter(c => c.n).length + uncataloged.size,
|
|
157
|
+
gh: all.filter(c => !c.n).length,
|
|
158
|
+
pending: uncataloged.size, // 市场里有、npm 目录还没补进来的
|
|
159
|
+
|
|
160
|
+
// 每个市场自己收录了多少条(市场里同一个插件可能占好几条,比如一个仓库里好几个插件);这次抓不到的不写
|
|
161
|
+
markets: Object.fromEntries(MARKETS.map(m => [m, members[MEMBER_KEY[m]] ? members[MEMBER_KEY[m]].length : null]).filter(([, v]) => v != null)),
|
|
162
|
+
}
|
|
163
|
+
|
|
147
164
|
// 一票否决
|
|
148
165
|
const excluded = {}
|
|
149
166
|
const out = []
|
|
@@ -224,6 +241,7 @@ export function buildOverall({ packages, members, previousSrc = {}, now = Date.n
|
|
|
224
241
|
const pct = v => Math.round(v * 100)
|
|
225
242
|
return {
|
|
226
243
|
total: out.length,
|
|
244
|
+
cover,
|
|
227
245
|
excluded,
|
|
228
246
|
weights: WEIGHTS,
|
|
229
247
|
angles: ANGLES,
|
package/package.json
CHANGED
package/plugin/client.js
CHANGED
|
@@ -297,9 +297,18 @@ window.__ModuleLoader__.load({
|
|
|
297
297
|
const catalog = !meta
|
|
298
298
|
? L('正在读取目录…', 'Loading catalog…')
|
|
299
299
|
: meta.total
|
|
300
|
-
?
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
? meta.cover
|
|
301
|
+
// 几个插件市场 + npm 去重后的总数;旧目录没有,就只说 npm 上的包数
|
|
302
|
+
? L(
|
|
303
|
+
`收录 ${meta.cover.all.toLocaleString()} 个插件(dshmarket、dsh-plugin-shop、dsh-m 精选、DeepSeek 官方和 npm 合起来去重),` +
|
|
304
|
+
`其中 ${meta.cover.npm.toLocaleString()} 个发布在 npm、能一键安装,${meta.cover.gh.toLocaleString()} 个只在 GitHub;` +
|
|
305
|
+
`npm 上下载最多的 ${meta.deepCount} 个有去噪指标。每天更新,数据截止 ${meta.anchor}。`,
|
|
306
|
+
`${meta.cover.all.toLocaleString()} plugins across dshmarket, dsh-plugin-shop, dsh-m picks, DeepSeek official and npm (deduplicated): ` +
|
|
307
|
+
`${meta.cover.npm.toLocaleString()} on npm (one-click install), ${meta.cover.gh.toLocaleString()} GitHub-only; ` +
|
|
308
|
+
`the ${meta.deepCount} most-downloaded have denoised metrics. Updated daily; data as of ${meta.anchor}.`)
|
|
309
|
+
: L(
|
|
310
|
+
`npm 上收录 ${meta.total.toLocaleString()} 个插件包(每天更新),其中下载最多的 ${meta.deepCount} 个有去噪指标;数据截止 ${meta.anchor}。`,
|
|
311
|
+
`${meta.total.toLocaleString()} plugin packages on npm (updated daily); the ${meta.deepCount} most-downloaded have denoised metrics; data as of ${meta.anchor}.`)
|
|
303
312
|
: L('目录未生成:在 dsh-pick 目录跑一次 dsh-pick build', 'Catalog not built yet: run `dsh-pick build`')
|
|
304
313
|
|
|
305
314
|
return h('div', { style: { color: C.text } },
|
package/plugin/index.js
CHANGED
|
@@ -230,6 +230,8 @@ async function catalogMeta() {
|
|
|
230
230
|
anchor: cat.anchor || null,
|
|
231
231
|
total: cat.total || Object.keys(packages).length,
|
|
232
232
|
deepCount: Object.values(packages).filter(p => p && p.deep).length,
|
|
233
|
+
// 几个插件市场 + npm 合起来去重后的覆盖数(每日目录用新代码构建后才有)
|
|
234
|
+
cover: (cat.boards && cat.boards.overall && cat.boards.overall.cover) || null,
|
|
233
235
|
source: cat.source || 'bundled',
|
|
234
236
|
checkedAt: state.checkedAt || null,
|
|
235
237
|
}
|
package/plugin/tools.js
CHANGED
|
@@ -130,7 +130,7 @@ export async function buildToolDefinitions(deps = {}) {
|
|
|
130
130
|
const installed = async () => {
|
|
131
131
|
try { return deps.installed ? await deps.installed() : new Set() } catch { return new Set() }
|
|
132
132
|
}
|
|
133
|
-
const header = cat => `目录数据截止 ${cat.anchor || '未知'}(npm 最近有数据的一天;npm
|
|
133
|
+
const header = cat => `目录数据截止 ${cat.anchor || '未知'}(npm 最近有数据的一天;npm 每日下载只在一天结束后汇总,常晚几天),npm 上共 ${num(cat.total)} 个插件包。`
|
|
134
134
|
const CATS = allCategories()
|
|
135
135
|
|
|
136
136
|
return [
|
package/web/panel.html
CHANGED
|
@@ -124,6 +124,8 @@ table.rank td.nm .desc{min-width:150px;display:-webkit-box;-webkit-line-clamp:2;
|
|
|
124
124
|
.addwrap{position:relative;flex:1;min-width:160px}
|
|
125
125
|
.addwrap input{width:100%;box-sizing:border-box;border:1px solid var(--line);border-radius:8px;padding:6px 10px;font-size:12.5px;font-family:inherit;background:var(--input);color:var(--text)}
|
|
126
126
|
.addwrap input:focus{outline:none;border-color:var(--accent)}
|
|
127
|
+
.watchadd{display:flex;gap:8px;align-items:center;margin:2px 0 12px}
|
|
128
|
+
.watchadd .btn.sm{height:30px}
|
|
127
129
|
.sug{position:absolute;left:0;right:0;top:100%;margin-top:4px;z-index:50;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:0 6px 18px var(--shadow);max-height:300px;overflow:auto}
|
|
128
130
|
.sug .opt{padding:7px 10px;cursor:pointer;border-bottom:1px solid var(--soft)}
|
|
129
131
|
.sug .opt:last-child{border-bottom:none}
|
|
@@ -240,6 +242,20 @@ table.cmp.wd .ch{display:block;font-size:10.5px;font-weight:600}
|
|
|
240
242
|
table.cmp.wd .ch.up{color:var(--ok)}table.cmp.wd .ch.down{color:var(--bad)}table.cmp.wd .ch.flat{color:var(--t3);font-weight:400}
|
|
241
243
|
table.cmp.wd .grp td{background:var(--soft);color:var(--t3);font-size:10.5px;font-weight:700;padding:4px 9px;text-align:left}
|
|
242
244
|
table.cmp.wd svg.spark{display:block;margin-left:auto}
|
|
245
|
+
/* 监控详情的窄屏版:按指标分块,每块一行一个插件,只往下长,不横向滚 */
|
|
246
|
+
.wds .grp{margin:14px 0 4px;padding:4px 8px;border-radius:6px;background:var(--soft);color:var(--t3);font-size:10.5px;font-weight:700}
|
|
247
|
+
.wds .grp:first-child{margin-top:0}
|
|
248
|
+
.wds .m{padding:7px 2px 6px;border-bottom:1px solid var(--soft)}
|
|
249
|
+
.wds .m:last-child{border-bottom:none}
|
|
250
|
+
.wds .ml{color:var(--t3);font-size:11px;font-weight:600;margin-bottom:3px}
|
|
251
|
+
.wds .r{display:flex;align-items:center;gap:8px;min-height:22px;font-size:12px}
|
|
252
|
+
.wds .nm{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--t2)}
|
|
253
|
+
.wds .nm i{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px;vertical-align:0}
|
|
254
|
+
.wds .v{flex:none;max-width:62%;text-align:right;display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}
|
|
255
|
+
.wds .ch{font-size:10.5px;font-weight:600}
|
|
256
|
+
.wds .ch.up{color:var(--ok)}.wds .ch.down{color:var(--bad)}.wds .ch.flat{color:var(--t3);font-weight:400}
|
|
257
|
+
.wds svg.spark{display:block}
|
|
258
|
+
.wds .v .up{color:var(--ok)}.wds .v .down{color:var(--bad)}
|
|
243
259
|
td.best{color:var(--ok);font-weight:700}
|
|
244
260
|
td.best::after{content:' ★';font-size:9px}
|
|
245
261
|
.miss{color:var(--mute)}
|
|
@@ -505,14 +521,22 @@ td.down{color:var(--bad);font-weight:600}
|
|
|
505
521
|
<!-- ============ Tab 3:监控 ============ -->
|
|
506
522
|
<div id="tab-watch" class="hidden">
|
|
507
523
|
<div class="section">
|
|
508
|
-
<h2>我的监控<span class="h2-acts"><button class="btn ghost sm" id="btnWatchRefresh" title="去 npm 实时查这些插件的最新数据">↻ 刷新</button><button class="ai hidden" id="aiWatch" title="把监控列表发到对话里,让 AI 看看谁在涨、谁停更了">+AI 看看近况</button></span></h2>
|
|
524
|
+
<h2>我的监控<span class="h2-acts"><button class="btn sm" id="btnWatchAdd" title="输入插件名或 GitHub 地址,加到我的监控" aria-expanded="false">+ 添加</button><button class="btn ghost sm" id="btnWatchRefresh" title="去 npm 实时查这些插件的最新数据">↻ 刷新</button><button class="ai hidden" id="aiWatch" title="把监控列表发到对话里,让 AI 看看谁在涨、谁停更了">+AI 看看近况</button></span></h2>
|
|
509
525
|
<p class="cap"><span id="watchAsOf"></span>监控列表存在浏览器本地,不上传。点「刷新」去 npm 和 GitHub 查最新:版本号、发版时间、GitHub 数据是即时的;周下载 npm 大约一天更新一次;日常基线和环比按 npm 已经出数据的最近 30 天算(npm 只在一天结束后才汇总,最近还常晚几天)。</p>
|
|
526
|
+
<div class="watchadd hidden" id="watchAdd">
|
|
527
|
+
<span class="addwrap">
|
|
528
|
+
<input id="addWatch" placeholder="输入插件名、npm 包名或 GitHub 地址" autocomplete="off" aria-label="输入插件名,加入我的监控">
|
|
529
|
+
<div id="watchSug" class="sug hidden" role="listbox"></div>
|
|
530
|
+
</span>
|
|
531
|
+
<button class="btn sm" id="watchAddGo">添加</button>
|
|
532
|
+
</div>
|
|
510
533
|
<div id="watchList"></div>
|
|
511
534
|
</div>
|
|
512
535
|
<div class="section" id="secWatchDetail">
|
|
513
536
|
<h2>监控详情 <span style="font-size:11.5px;color:var(--t3);font-weight:500" id="wdAsOf"></span></h2>
|
|
514
537
|
<p class="cap">每个插件一列,下载、版本、GitHub、市场位置都摆出来。「较上次」是和你上一次点刷新时比:每次刷新都会在本机存一份快照,盯自家产品和竞品的变化。</p>
|
|
515
|
-
<div class="tblwrap"><table class="cmp wd"><thead id="wdHead"></thead><tbody id="wdBody"></tbody></table></div>
|
|
538
|
+
<div class="tblwrap" id="wdTable"><table class="cmp wd"><thead id="wdHead"></thead><tbody id="wdBody"></tbody></table></div>
|
|
539
|
+
<div id="wdStack" class="wds hidden"></div>
|
|
516
540
|
</div>
|
|
517
541
|
<div class="section">
|
|
518
542
|
<h2>对比图</h2>
|
package/web/panel.js
CHANGED
|
@@ -344,8 +344,13 @@ async function boot() {
|
|
|
344
344
|
CAT = await res.json()
|
|
345
345
|
|
|
346
346
|
const deepN = Object.values(CAT.packages).filter(p => p.deep).length
|
|
347
|
+
// 覆盖数:几个插件市场 + npm 合起来去重(每日目录用新代码构建后才有);旧目录只说 npm 上的包数
|
|
348
|
+
const cover = CAT.boards && CAT.boards.overall && CAT.boards.overall.cover
|
|
349
|
+
const MKT = { dshmarket: 'dshmarket', shop: 'dsh-plugin-shop 商店', 'dsh-m': 'dsh-m 精选', official: 'DeepSeek 官方' }
|
|
347
350
|
$('#meta').innerHTML =
|
|
348
|
-
|
|
351
|
+
(cover
|
|
352
|
+
? `收录 <b>${num(cover.all)}</b> 个插件(4 个市场 + npm 去重)· npm 上 <b>${num(cover.npm)}</b> 个 · 去噪指标 <b>${num(deepN)}</b> 个<br>`
|
|
353
|
+
: `npm 上 <b>${num(CAT.total)}</b> 个插件包 · 去噪指标 <b>${num(deepN)}</b> 个<br>`) +
|
|
349
354
|
`数据截止 <b>${CAT.anchor}</b>(npm 最近有数据的一天)`
|
|
350
355
|
|
|
351
356
|
const gapNote = CAT.gaps && CAT.gaps.length
|
|
@@ -353,7 +358,13 @@ async function boot() {
|
|
|
353
358
|
: ''
|
|
354
359
|
$('#foot').innerHTML =
|
|
355
360
|
`<b>口径:</b>下载量含 CI、镜像、爬虫等非人类流量,不等于用户数;<b>日常基线</b>= 扣掉版本发布日与次日后的每日中位数,比原始下载量更接近真实使用量。<br>` +
|
|
356
|
-
|
|
361
|
+
(cover
|
|
362
|
+
? `<b>覆盖范围:</b>把 ${Object.entries(cover.markets).map(([k, v]) => `${MKT[k] || esc(k)}(${num(v)} 条)`).join('、')}和 npm 上带 <code>dsh-plugin</code> 关键字的包合起来,` +
|
|
363
|
+
`按 npm 包名、GitHub 仓库去重,共 <b>${num(cover.all)}</b> 个插件:${num(cover.npm)} 个发布在 npm(能一键安装、有下载量),${num(cover.gh)} 个只在 GitHub。` +
|
|
364
|
+
`市场里一个仓库拆成好几条、几个市场互相重复收录,所以去重后比各市场条数相加少。` +
|
|
365
|
+
(cover.pending ? `其中 ${num(cover.pending)} 个 npm 包还没补进目录(每天补一批,几天补完),补进来之前不参与排名。` : '') +
|
|
366
|
+
`去噪指标只算了 npm 上周下载最多的 ${num(deepN)} 个。目录每天自动重建。<br>`
|
|
367
|
+
: `<b>覆盖范围:</b>npm 上带 <code>dsh-plugin</code> 关键字、或被插件市场收录的 ${num(CAT.total)} 个 npm 包;去噪指标只算了周下载最多的 ${num(deepN)} 个。目录每天自动重建。<br>`) +
|
|
357
368
|
(IN_DSH
|
|
358
369
|
? `<b>当前结论由本地规则生成</b>(依据就是对比表里的数字)。点各处的「+AI」,把数据发到对话里让 AI 结合你的场景分析;在对话里也可以直接问「哪个插件能做某某」,AI 会自己查这份目录。`
|
|
359
370
|
: `<b>当前结论由本地规则生成</b>(依据就是对比表里的数字)。装上 DSH 插件版后,可以一键交给 AI,结合你的具体场景解释取舍。`) +
|
|
@@ -383,20 +394,22 @@ function bindEvents() {
|
|
|
383
394
|
$('#btnFind').addEventListener('click', doSearch)
|
|
384
395
|
$('#btnAi').addEventListener('click', runAiPick)
|
|
385
396
|
// 比较清单:输入插件名加入
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
if (!sugItems.length) return
|
|
390
|
-
if (e.key === 'ArrowDown') { sugOn = (sugOn + 1) % sugItems.length; renderSug(); e.preventDefault() }
|
|
391
|
-
else if (e.key === 'ArrowUp') { sugOn = (sugOn - 1 + sugItems.length) % sugItems.length; renderSug(); e.preventDefault() }
|
|
392
|
-
else if (e.key === 'Enter' && sugOn >= 0) { addFromSug(sugItems[sugOn].n); e.preventDefault() }
|
|
393
|
-
else if (e.key === 'Escape') { sugItems = []; renderSug() }
|
|
397
|
+
bindSuggest({
|
|
398
|
+
input: $('#addCmp'), box: $('#addSug'), has: n => picked.includes(n), hasText: '已在清单里',
|
|
399
|
+
onPick: n => { if (!picked.includes(n)) togglePick(n); $('#secCmp').scrollIntoView({ block: 'nearest' }) },
|
|
394
400
|
})
|
|
395
|
-
|
|
396
|
-
$('#
|
|
397
|
-
|
|
398
|
-
|
|
401
|
+
// 我的监控:「+ 添加」打开输入框;选建议里的,或直接回车按输入的名字 / GitHub 地址加
|
|
402
|
+
const watchInput = $('#addWatch')
|
|
403
|
+
const watchSug = bindSuggest({
|
|
404
|
+
input: watchInput, box: $('#watchSug'), has: n => watch().includes(n), hasText: '已在监控里',
|
|
405
|
+
onPick: n => addToWatch(n), onEnter: text => addToWatch(text),
|
|
406
|
+
})
|
|
407
|
+
$('#btnWatchAdd').addEventListener('click', () => {
|
|
408
|
+
const open = $('#watchAdd').classList.toggle('hidden') === false
|
|
409
|
+
$('#btnWatchAdd').setAttribute('aria-expanded', String(open))
|
|
410
|
+
if (open) watchInput.focus()
|
|
399
411
|
})
|
|
412
|
+
$('#watchAddGo').addEventListener('click', () => watchSug.submit())
|
|
400
413
|
$('#need').addEventListener('keydown', e => { if (e.key === 'Enter') doSearch() })
|
|
401
414
|
|
|
402
415
|
document.querySelectorAll('.examples .chip').forEach(c => {
|
|
@@ -409,6 +422,7 @@ function bindEvents() {
|
|
|
409
422
|
const t = b.dataset.tab
|
|
410
423
|
// 每个标签一块内容:tab-pick / tab-rank / tab-watch
|
|
411
424
|
document.querySelectorAll('#tabs button').forEach(x => $('#tab-' + x.dataset.tab).classList.toggle('hidden', x.dataset.tab !== t))
|
|
425
|
+
if (t === 'watch') layoutWatchDetail() // 标签页隐藏时量不出宽度,显示出来再选版式
|
|
412
426
|
// 打开「我的监控」时,数据超过 6 小时没刷新就自动刷新一次
|
|
413
427
|
if (t === 'watch' && watch().length && (!LIVE.at || Date.now() - Date.parse(LIVE.at) > 6 * 3600 * 1000) && !$('#btnWatchRefresh').disabled) refreshWatch()
|
|
414
428
|
})
|
|
@@ -537,8 +551,6 @@ function renderPickBar() {
|
|
|
537
551
|
: '<span class="none">还没有,点候选卡片或在右边输入插件名</span>'
|
|
538
552
|
}
|
|
539
553
|
|
|
540
|
-
let sugItems = []
|
|
541
|
-
let sugOn = -1
|
|
542
554
|
/** 按名字找插件:名字开头吻合的优先,其次名字里包含、关键字吻合;同档按周下载 */
|
|
543
555
|
function suggest(q) {
|
|
544
556
|
q = q.trim().toLowerCase()
|
|
@@ -551,20 +563,41 @@ function suggest(q) {
|
|
|
551
563
|
}
|
|
552
564
|
return out.sort((a, b) => a[0] - b[0] || (b[1].w || 0) - (a[1].w || 0)).slice(0, 8).map(x => x[1])
|
|
553
565
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
566
|
+
/**
|
|
567
|
+
* 输入框 + 下拉建议(比较清单、我的监控共用):上下键选、回车加、Esc 收起。
|
|
568
|
+
* 没有建议、或没选中时回车:交给 onEnter(按输入的原文加),没有 onEnter 就不动
|
|
569
|
+
*/
|
|
570
|
+
function bindSuggest({ input, box, has, hasText, onPick, onEnter }) {
|
|
571
|
+
let items = []
|
|
572
|
+
let on = -1
|
|
573
|
+
const render = () => {
|
|
574
|
+
if (!items.length) { box.classList.add('hidden'); return }
|
|
575
|
+
box.innerHTML = items.map((r, i) => `<div class="opt${i === on ? ' on' : ''}" data-add="${esc(r.n)}" role="option">` +
|
|
576
|
+
`<b>${esc(r.n)}</b>${has(r.n) ? ` <em style="color:var(--ok-text);font-style:normal;font-size:11px">${hasText}</em>` : ''}` +
|
|
577
|
+
`<span>周下载 ${short(r.w)}${r.sc != null ? ` · 综合分 ${r.sc}` : ''} · ${esc(String(r.d || '').slice(0, 60))}</span></div>`).join('')
|
|
578
|
+
box.classList.remove('hidden')
|
|
579
|
+
}
|
|
580
|
+
const done = () => { input.value = ''; items = []; render() }
|
|
581
|
+
const pick = n => { onPick(n); done() }
|
|
582
|
+
const submit = () => {
|
|
583
|
+
if (items.length && on >= 0) return pick(items[on].n)
|
|
584
|
+
const text = input.value.trim()
|
|
585
|
+
if (text && onEnter && onEnter(text) !== false) done()
|
|
586
|
+
}
|
|
587
|
+
input.addEventListener('input', () => { items = suggest(input.value); on = items.length ? 0 : -1; render() })
|
|
588
|
+
input.addEventListener('keydown', e => {
|
|
589
|
+
if (e.key === 'Enter') { submit(); e.preventDefault(); return }
|
|
590
|
+
if (!items.length) return
|
|
591
|
+
if (e.key === 'ArrowDown') { on = (on + 1) % items.length; render(); e.preventDefault() }
|
|
592
|
+
else if (e.key === 'ArrowUp') { on = (on - 1 + items.length) % items.length; render(); e.preventDefault() }
|
|
593
|
+
else if (e.key === 'Escape') { items = []; render() }
|
|
594
|
+
})
|
|
595
|
+
input.addEventListener('blur', () => setTimeout(() => { items = []; render() }, 150))
|
|
596
|
+
box.addEventListener('mousedown', e => {
|
|
597
|
+
const o = e.target.closest('[data-add]')
|
|
598
|
+
if (o) { e.preventDefault(); pick(o.dataset.add) }
|
|
599
|
+
})
|
|
600
|
+
return { submit }
|
|
568
601
|
}
|
|
569
602
|
|
|
570
603
|
/* ---------------- AI 精选:用 DSH 当前的模型挑插件 ---------------- */
|
|
@@ -1294,13 +1327,18 @@ function sparkSvg(daily, color) {
|
|
|
1294
1327
|
'</svg>'
|
|
1295
1328
|
}
|
|
1296
1329
|
/** 在综合榜某个角度里排第几(只在存下来的头部里找) */
|
|
1330
|
+
// 综合榜每个角度的完整名次(和排行榜同一套排法),算一次存着,监控详情重画时清掉
|
|
1331
|
+
let ANGLE_ORDER = new Map()
|
|
1297
1332
|
function angleRank(key, angle) {
|
|
1298
1333
|
const o = CAT.boards && CAT.boards.overall
|
|
1299
1334
|
if (!o || !o.rows.length || !o.rows[0].a) return null
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1335
|
+
if (!ANGLE_ORDER.has(angle)) {
|
|
1336
|
+
const w = r => (r.n && CAT.packages[r.n] ? CAT.packages[r.n].w || 0 : 0)
|
|
1337
|
+
const rows = overallPool(o).filter(r => r.a[angle] != null)
|
|
1338
|
+
.sort((x, y) => angle === 'new' ? String(y.added || '').localeCompare(String(x.added || '')) || y.a.new - x.a.new : y.a[angle] - x.a[angle] || w(y) - w(x))
|
|
1339
|
+
ANGLE_ORDER.set(angle, new Map(rows.map((r, i) => [r.k, i + 1])))
|
|
1340
|
+
}
|
|
1341
|
+
return ANGLE_ORDER.get(angle).get(key) || null
|
|
1304
1342
|
}
|
|
1305
1343
|
|
|
1306
1344
|
function renderWatchDetail(list) {
|
|
@@ -1308,6 +1346,7 @@ function renderWatchDetail(list) {
|
|
|
1308
1346
|
if (!list.length) { sec.classList.add('hidden'); return }
|
|
1309
1347
|
sec.classList.remove('hidden')
|
|
1310
1348
|
$('#wdAsOf').textContent = LIVE.at ? `· ${new Date(LIVE.at).toLocaleString()} 刷新` : '· 还没刷新过,先显示目录数据'
|
|
1349
|
+
ANGLE_ORDER = new Map()
|
|
1311
1350
|
const recs = list.map(n => ({ n, r: watchRec(n) }))
|
|
1312
1351
|
$('#wdHead').innerHTML = '<tr><th>指标</th>' + recs.map(({ n, r }, i) =>
|
|
1313
1352
|
`<th><i style="background:${colorOf(i)}"></i>${esc((r && r.label) || n)}</th>`).join('') + '</tr>'
|
|
@@ -1341,7 +1380,7 @@ function renderWatchDetail(list) {
|
|
|
1341
1380
|
['分类排名', ({ r }) => cell(r, x => (x.crank ? `${esc(x.cat)} #${num(x.crank)}` : '—'))],
|
|
1342
1381
|
['综合榜排名', ({ n, r }) => cell(r, () => {
|
|
1343
1382
|
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)"
|
|
1383
|
+
return parts.length ? parts.map(([l, v]) => `${l} #${v}`).join('<br>') : '<span style="color:var(--t3)">没进综合榜</span>'
|
|
1345
1384
|
})],
|
|
1346
1385
|
['综合推荐分', ({ n, r }) => cell(r, x => (x.sc != null ? `${x.sc}${changeOf(n, 'sc', x.sc, { asPct: false })}` : '—'))],
|
|
1347
1386
|
['收录于', ({ r }) => cell(r, x => (x.src && x.src.length ? srcChips(x.src, { short: true }) : '—'))],
|
|
@@ -1349,6 +1388,82 @@ function renderWatchDetail(list) {
|
|
|
1349
1388
|
$('#wdBody').innerHTML = rows.map(([label, fn]) => (fn
|
|
1350
1389
|
? `<tr><td>${label}</td>${recs.map((x, i) => `<td>${fn(x, i)}</td>`).join('')}</tr>`
|
|
1351
1390
|
: `<tr class="grp"><td colspan="${recs.length + 1}">${label}</td></tr>`)).join('')
|
|
1391
|
+
// 窄屏版:同一份指标,按指标分块,每块一行一个插件
|
|
1392
|
+
const names = recs.map(({ n, r }, i) => `<span class="nm" title="${esc((r && r.label) || n)}"><i style="background:${colorOf(i)}"></i>${esc((r && r.label) || n)}</span>`)
|
|
1393
|
+
$('#wdStack').innerHTML = rows.map(([label, fn]) => (fn
|
|
1394
|
+
? `<div class="m"><div class="ml">${label}</div>${recs.map((x, i) => `<div class="r">${names[i]}<span class="v">${fn(x, i)}</span></div>`).join('')}</div>`
|
|
1395
|
+
: `<div class="grp">${label}</div>`)).join('')
|
|
1396
|
+
WD_COUNT = recs.length
|
|
1397
|
+
layoutWatchDetail()
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* 监控详情选版式:右侧栏放得下整张表(每个插件一列)就用表格,放不下就用按指标分块的竖排版
|
|
1402
|
+
* (手机那样只往下长,不用横着滚)。直接量表格的实际宽度:插件名长短、有没有「较上次」都会影响列宽,估不准。
|
|
1403
|
+
* 拖动侧栏宽度时跟着切换
|
|
1404
|
+
*/
|
|
1405
|
+
let WD_COUNT = 0
|
|
1406
|
+
function layoutWatchDetail() {
|
|
1407
|
+
const wrap = $('#wdTable')
|
|
1408
|
+
if (!$('#secWatchDetail').clientWidth || !WD_COUNT) return // 标签页没显示时量不出宽度,显示出来再量
|
|
1409
|
+
wrap.classList.remove('hidden')
|
|
1410
|
+
const fits = wrap.scrollWidth <= wrap.clientWidth + 1
|
|
1411
|
+
wrap.classList.toggle('hidden', !fits)
|
|
1412
|
+
$('#wdStack').classList.toggle('hidden', fits)
|
|
1413
|
+
}
|
|
1414
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
1415
|
+
let lastW = 0
|
|
1416
|
+
new ResizeObserver(entries => {
|
|
1417
|
+
const w = Math.round(entries[0].contentRect.width)
|
|
1418
|
+
if (w !== lastW) { lastW = w; layoutWatchDetail() }
|
|
1419
|
+
}).observe(document.getElementById('secWatchDetail'))
|
|
1420
|
+
}
|
|
1421
|
+
// 保险:有的环境(后台页、老内核)不触发 ResizeObserver,窗口大小变了也量一次;切到「我的监控」时也会量
|
|
1422
|
+
window.addEventListener('resize', () => layoutWatchDetail())
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* 用户输入 → 监控名:目录里的包名直接用;GitHub 地址或 owner/repo:目录里有发到 npm 的就记包名,
|
|
1426
|
+
* 没有就记 gh:owner/repo;其余像 npm 包名的也收(目录外的插件,刷新时去 npm 查)。认不出返回 ''
|
|
1427
|
+
*/
|
|
1428
|
+
function watchKeyOf(text) {
|
|
1429
|
+
const t = text.trim().replace(/\/+$/, '').replace(/\.git$/, '')
|
|
1430
|
+
if (CAT.packages[t]) return t
|
|
1431
|
+
const lower = t.toLowerCase()
|
|
1432
|
+
if (CAT.packages[lower]) return lower
|
|
1433
|
+
const gh = /^(?:https?:\/\/)?(?:www\.)?github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/.exec(t) || (!t.startsWith('@') && /^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/.exec(t))
|
|
1434
|
+
if (gh) {
|
|
1435
|
+
const repo = `${gh[1]}/${gh[2]}`
|
|
1436
|
+
const hit = Object.values(CAT.packages).filter(r => r.gh && r.gh.repo.toLowerCase() === repo.toLowerCase()).sort((a, b) => (b.w || 0) - (a.w || 0))[0]
|
|
1437
|
+
return hit ? hit.n : 'gh:' + repo
|
|
1438
|
+
}
|
|
1439
|
+
const npm = /^(?:https?:\/\/)?(?:www\.)?npmjs\.com\/package\/(.+)$/.exec(t)
|
|
1440
|
+
const name = (npm ? decodeURIComponent(npm[1]) : t).toLowerCase()
|
|
1441
|
+
return /^(@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name) ? name : ''
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
/** 「+ 添加」:加进监控,再只查这一个的实时数据(不动「较上次」用的快照) */
|
|
1445
|
+
function addToWatch(text) {
|
|
1446
|
+
const key = watchKeyOf(text)
|
|
1447
|
+
if (!key) { toast(`认不出「${text}」:输入 npm 包名,或 GitHub 仓库地址`); return false }
|
|
1448
|
+
if (watch().includes(key)) { toast(`已经在我的监控里了:${watchName(key)}`); return true }
|
|
1449
|
+
const before = watch().length
|
|
1450
|
+
toggleWatch(key)
|
|
1451
|
+
if (watch().length === before) return false // 满 30 个,toggleWatch 已提示
|
|
1452
|
+
fetchLiveOne(key)
|
|
1453
|
+
return true
|
|
1454
|
+
}
|
|
1455
|
+
async function fetchLiveOne(key) {
|
|
1456
|
+
try {
|
|
1457
|
+
const r = await fetch(`${P.live}?names=${encodeURIComponent(key)}`, { cache: 'no-store' })
|
|
1458
|
+
const j = await r.json()
|
|
1459
|
+
if (!r.ok) throw new Error(j.error || 'HTTP ' + r.status)
|
|
1460
|
+
const row = j.rows.find(x => x.name === key)
|
|
1461
|
+
if (!row) return
|
|
1462
|
+
LIVE = { ...LIVE, rows: { ...LIVE.rows, [key]: row } }
|
|
1463
|
+
try { localStorage.setItem(LIVE_KEY, JSON.stringify(LIVE)) } catch { /* 存不下就只这次有效 */ }
|
|
1464
|
+
if (!row.found) toast(`${watchName(key)}:${key.startsWith('gh:') ? 'GitHub 上查不到这个仓库' : 'npm 上查不到这个包'},检查一下名字(不要的话点 × 移除)`)
|
|
1465
|
+
renderWatch()
|
|
1466
|
+
} catch { /* 没网就先显示目录数据,点「刷新」再查 */ }
|
|
1352
1467
|
}
|
|
1353
1468
|
|
|
1354
1469
|
async function refreshWatch() {
|
|
@@ -1386,7 +1501,8 @@ function renderWatch() {
|
|
|
1386
1501
|
: `现在显示的是目录数据(截止 <b>${esc(CAT.anchor)}</b>)。`
|
|
1387
1502
|
const host = $('#watchList')
|
|
1388
1503
|
if (!list.length) {
|
|
1389
|
-
|
|
1504
|
+
$('#watchAdd').classList.remove('hidden') // 空的时候直接摆出输入框
|
|
1505
|
+
host.innerHTML = '<div class="empty">还没有监控的插件。点上面的「+ 添加」输入插件名,或在「选插件」、排行榜里点彩色的 +。</div>'
|
|
1390
1506
|
$('#watchChart').innerHTML = ''
|
|
1391
1507
|
return
|
|
1392
1508
|
}
|