dsh-dpharness 0.6.4 → 0.6.5

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/lib/changelog.js CHANGED
@@ -37,6 +37,17 @@ export function npmLatestUrl(pkg) {
37
37
  * (用户要看的是行为变化,不是我们的 commit 分类)。
38
38
  */
39
39
  export const CHANGELOG = [
40
+ {
41
+ version: "0.6.5",
42
+ date: "2026-10-21",
43
+ title: "插件卡片可以直接分享,整页尺寸统一",
44
+ items: [
45
+ "每张卡片的命令条旁多了「分享」:复制链接、复制文案、下载说明图三件事,发到群里对方点开就是插件详情页。",
46
+ "复制出的链接带 dsh 来源标识,站点「渠道追踪」里能单独看到面板带来的回流,不再混进「直接访问」。",
47
+ "对比中的卡片整卡高亮,收藏过的卡片左侧有一条竖条:一屏十几张卡时,哪张选了、哪张收藏了都看得出来。",
48
+ "版式统一:按钮只有一个高度、标签统一大小,卡片分成「身份 / 说明 / 动作」三段;浮窗与页签两套版式一起对齐。",
49
+ ],
50
+ },
40
51
  {
41
52
  version: "0.6.4",
42
53
  date: "2026-10-20",
package/lib/client.js CHANGED
@@ -9,27 +9,27 @@ window.__ModuleLoader__.load({
9
9
 
10
10
  /* ------------------------------------------------------------------ styles */
11
11
  const css = [
12
- ".dph_root{display:flex;flex-direction:column;gap:12px;width:100%;max-width:1080px;margin:0 auto;padding:6px 4px 24px}",
12
+ ".dph_root{display:flex;flex-direction:column;gap:16px;width:100%;max-width:1080px;margin:0 auto;padding:8px 4px 24px}",
13
13
  ".dph_header{display:flex;align-items:center;gap:10px;flex-wrap:wrap}",
14
14
  ".dph_title{margin:0;font-size:17px;font-weight:600;color:var(--dsw-alias-label-primary)}",
15
15
  ".dph_sub{color:var(--dsw-alias-label-tertiary);font-size:12px}",
16
16
  ".dph_spacer{flex:1}",
17
- ".dph_btn{border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);border-radius:6px;padding:4px 12px;font:inherit;font-size:12px;cursor:pointer;text-decoration:none;white-space:nowrap}",
17
+ ".dph_btn{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;height:28px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font:inherit;font-size:12px;line-height:1;cursor:pointer;text-decoration:none;white-space:nowrap}",
18
18
  ".dph_btn:hover{background:var(--dsw-alias-interactive-bg-hover)}",
19
19
  ".dph_bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
20
- ".dph_input{flex:1;min-width:180px;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:8px;padding:7px 10px;font:inherit;font-size:13px;outline:none}",
20
+ ".dph_input{flex:1;min-width:180px;box-sizing:border-box;height:32px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 10px;font:inherit;font-size:13px;outline:none}",
21
21
  ".dph_input:focus{border-color:var(--dsw-alias-state-business-primary)}",
22
22
  ".dph_seg{display:inline-flex;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;overflow:hidden;flex:none}",
23
- ".dph_segBtn{border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:6px 12px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap}",
23
+ ".dph_segBtn{border:0;background:transparent;color:var(--dsw-alias-label-secondary);height:30px;padding:0 12px;box-sizing:border-box;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap}",
24
24
  ".dph_segBtnOn{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);font-weight:600}",
25
25
  ".dph_list{display:flex;flex-direction:column;gap:8px}",
26
- ".dph_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);border-radius:10px;padding:12px 14px;display:flex;flex-direction:column;gap:8px}",
26
+ ".dph_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);border-radius:10px;padding:14px;display:flex;flex-direction:column;gap:10px}",
27
27
  ".dph_cardTop{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}",
28
28
  ".dph_name{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary)}",
29
29
  ".dph_owner{font-size:12px;color:var(--dsw-alias-label-tertiary)}",
30
30
  ".dph_stars{font-size:12px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}",
31
31
  ".dph_tags{display:flex;gap:6px;flex-wrap:wrap}",
32
- ".dph_tag{border:1px solid var(--dsw-alias-border-l2);border-radius:999px;padding:1px 8px;font-size:11px;color:var(--dsw-alias-label-secondary);white-space:nowrap}",
32
+ ".dph_tag{display:inline-flex;align-items:center;box-sizing:border-box;height:20px;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:0 7px;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);white-space:nowrap}",
33
33
  ".dph_tagOk{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary)}",
34
34
  ".dph_tagBad{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}",
35
35
  ".dph_desc{font-size:12px;line-height:1.6;color:var(--dsw-alias-label-secondary);margin:0}",
@@ -43,6 +43,24 @@ window.__ModuleLoader__.load({
43
43
  ".dph_segWrap{display:flex}",
44
44
  ".dph_segWrap .dph_seg{flex:1}",
45
45
  ".dph_segWrap .dph_segBtn{flex:1}",
46
+ /* 周榜(2026-10-20):面板从 5 个视图变 6 个,`.dph_segBtn{flex:1}` 六等分
47
+ 在 372px 可用宽里会把四字标签(严选推荐 / 分类精选 / 每日推荐 / 我的插件)
48
+ 挤到溢出裁切。这里**不改任何既有文案、也不重定义 .dph_segBtn**:
49
+ 只给多出来的这一层加横向滚动,按钮转为按内容宽度排列。
50
+ min-width:100% 保证视图少时不缩成一坨(与原来的铺满观感一致)。 */
51
+ ".dph_segWrapScroll{display:flex;overflow-x:auto;scrollbar-width:none}",
52
+ ".dph_segWrapScroll::-webkit-scrollbar{display:none}",
53
+ /* 12px→10px 内边距是为 372px 可用宽算过的:六个标签合计 360px,能整排放下;
54
+ justify-content:space-between 把余量摊回两端,不会在右侧留一条空档。
55
+ 更窄(<360px)时才真的横向滚动 —— 滚动条隐藏,但不裁字。 */
56
+ ".dph_segWrapScroll .dph_seg{flex:none;min-width:100%;justify-content:space-between}",
57
+ ".dph_segWrapScroll .dph_segBtn{flex:none;padding:6px 10px}",
58
+ /* 周榜行头:名次 + 依据(周下载 / 本周人数)。名次宽度固定,便于纵向扫读。 */
59
+ ".dph_boardHead{display:flex;align-items:baseline;gap:8px;padding:2px 2px 0}",
60
+ ".dph_boardRank{flex:none;min-width:22px;font-size:11px;font-weight:700;color:var(--dsw-alias-state-business-primary);font-variant-numeric:tabular-nums}",
61
+ ".dph_boardMetric{font-size:11px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}",
62
+ ".dph_boardDelta{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
63
+ ".dph_boardWhy{flex:none;font-size:10px;line-height:1.5;color:var(--dsw-alias-label-tertiary);padding:2px 2px 4px}",
46
64
  /* 分类精选:大类(可折叠)→ 小类 → 条目
47
65
  ⚠️ `flex:none` 不可省(2026-09-18 实测踩到,用户截图暴露):
48
66
  `.dph_panelBody` 是 `display:flex; flex-direction:column`,而本元素有
@@ -62,14 +80,24 @@ window.__ModuleLoader__.load({
62
80
  ".dph_bestItem{display:flex;flex-direction:column;gap:4px}",
63
81
  ".dph_bestRank{font-size:10px;font-weight:700;color:var(--dsw-alias-state-business-primary)}",
64
82
  ".dph_bestReason{font-size:10px;color:var(--dsw-alias-label-tertiary);padding-left:2px}",
65
- /* 套装:槽位行 = 职责(这个位置干什么)→ 插件名 → 必要性标签 → 星标/已装。
66
- 职责用等宽小字、与名字左对齐两栏,扫一眼能看出"这套配了哪些岗位"。 */
67
- ".dph_setRow{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;padding:2px 0}",
68
- ".dph_setRole{flex:none;min-width:74px;max-width:110px;font-size:11px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
69
- ".dph_setName{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}",
83
+ /* 套装槽位行(2026-10-20 重排):职责 → 插件名 → 必要性 → 星标/已装。
84
+ ⚠️ 三个坑,动之前先看:
85
+ 1) **不要复用 `.dph_setRow`**:设置页那一族也叫这个名字(见下方 `.dph_set*`),
86
+ 后定义者覆盖前者 —— 实测把槽位行变成 `justify-content:space-between`,
87
+ 四段被均摊到行两端,名字/徽标的位置随星数宽度漂移(用户截图暴露);
88
+ 2) 职责列旧版写死 `max-width:110px` + nowrap,长文案被截成「免 Key 主视觉入口…」
89
+ ⇒ 现改两行 clamp,并在 title 里保留全文;
90
+ 3) 宽屏单行 flex 时行内总宽只有 450px 上下,主列却有 850px+,右侧整片空白
91
+ (用户反馈「单靠左边」)⇒ 用 auto-fit 网格,让宽度按列数吃满。 */
92
+ ".dph_slotGrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:10px 22px}",
93
+ ".dph_slotRow{display:grid;grid-template-columns:minmax(0,1fr) auto auto;column-gap:8px;row-gap:2px;align-items:baseline;min-width:0;padding:2px 0}",
94
+ ".dph_slotRole{grid-column:1/-1;min-height:16px;font-size:11px;line-height:1.45;color:var(--dsw-alias-label-tertiary);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}",
95
+ ".dph_slotName{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
96
+ ".dph_slotNeed{justify-self:end;white-space:nowrap}",
97
+ ".dph_slotTail{justify-self:end;max-width:112px;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums}",
70
98
  ".dph_cmdBlock{white-space:pre-wrap;word-break:break-all;max-height:132px;overflow:auto}",
71
- ".dph_cmd{flex:1;min-width:200px;box-sizing:border-box;background:var(--dsw-alias-bg-layer-3);border-radius:6px;padding:6px 10px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--dsw-alias-label-primary);overflow-x:auto;white-space:nowrap}",
72
- ".dph_cmdMissing{font-size:12px;color:var(--dsw-alias-label-tertiary)}",
99
+ ".dph_cmd{flex:1;min-width:200px;box-sizing:border-box;display:flex;align-items:center;height:28px;background:var(--dsw-alias-bg-layer-3);border-radius:8px;padding:0 10px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--dsw-alias-label-primary);overflow-x:auto;white-space:nowrap}",
100
+ ".dph_cmdMissing{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:12px;color:var(--dsw-alias-label-tertiary)}",
73
101
  ".dph_notice{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:14px;font-size:13px;color:var(--dsw-alias-label-secondary)}",
74
102
  ".dph_noticeBad{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}",
75
103
  ".dph_footer{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.6}",
@@ -111,7 +139,7 @@ window.__ModuleLoader__.load({
111
139
  ".dph_close{border:0;background:transparent;color:var(--dsw-alias-label-tertiary);font-size:16px;line-height:1;cursor:pointer;padding:2px 6px;border-radius:6px}",
112
140
  ".dph_close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}",
113
141
  ".dph_cardSm{padding:10px 12px;gap:6px}",
114
- ".dph_instRow{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
142
+ ".dph_instRow{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:2px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2)}",
115
143
  ".dph_instCol{flex-direction:column;align-items:flex-start;gap:4px}",
116
144
  ".dph_btnPrimary{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);font-weight:600}",
117
145
  ".dph_btn:disabled{opacity:.55;cursor:not-allowed}",
@@ -120,7 +148,7 @@ window.__ModuleLoader__.load({
120
148
  ".dph_instBad{color:var(--dsw-alias-state-error-primary)}",
121
149
  ".dph_instHint{font-size:11px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}",
122
150
  ".dph_sell{display:flex;align-items:flex-start;gap:6px;font-size:12px;line-height:1.6}",
123
- ".dph_sellTag{flex:none;border:1px solid var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);border-radius:4px;padding:0 5px;font-size:11px;line-height:16px}",
151
+ ".dph_sellTag{flex:none;display:inline-flex;align-items:center;box-sizing:border-box;height:18px;border:1px solid var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);border-radius:6px;padding:0 5px;font-size:10px;line-height:1}",
124
152
  ".dph_sellText{color:var(--dsw-alias-label-primary);font-weight:500}",
125
153
  ".dph_raw{color:var(--dsw-alias-label-tertiary)}",
126
154
  ".dph_drag{cursor:grab;touch-action:none;user-select:none}",
@@ -189,19 +217,19 @@ window.__ModuleLoader__.load({
189
217
  不写会把 1fr 列撑破、侧栏被挤出可视区;
190
218
  2) 窄窗单列时用 display:contents 把侧栏拆成两个栅格项(今日推荐 / 其余),
191
219
  靠 order 把今日推荐提到列表之前 —— 不复制 DOM,也不存在两套渲染分支。 */
192
- ".dph_work{display:grid;grid-template-columns:minmax(0,1fr) 212px;gap:16px;align-items:start;width:100%;max-width:1080px;margin:0 auto;padding:6px 4px 20px}",
193
- ".dph_workHead{grid-column:1/-1;display:flex;align-items:center;gap:10px;flex-wrap:wrap;border-bottom:1px solid var(--dsw-alias-border-l2);padding-bottom:9px}",
194
- ".dph_tabbar{grid-column:1/-1;display:flex;gap:18px;flex-wrap:wrap;border-bottom:1px solid var(--dsw-alias-border-l2)}",
195
- ".dph_tab{border:0;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;padding:2px 0 8px;cursor:pointer;white-space:nowrap}",
220
+ ".dph_work{display:grid;grid-template-columns:minmax(0,1fr) 212px;gap:20px;align-items:start;width:100%;max-width:1080px;margin:0 auto;padding:12px 4px 20px}",
221
+ ".dph_workHead{grid-column:1/-1;display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 0 0;font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}",
222
+ ".dph_tabbar{grid-column:1/-1;display:flex;gap:20px;flex-wrap:wrap;border-bottom:1px solid var(--dsw-alias-border-l2)}",
223
+ ".dph_tab{border:0;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;height:32px;padding:0 0 10px;box-sizing:border-box;cursor:pointer;white-space:nowrap}",
196
224
  ".dph_tab:hover{color:var(--dsw-alias-label-primary)}",
197
225
  ".dph_tabOn{color:var(--dsw-alias-state-business-primary);font-weight:600;box-shadow:inset 0 -2px 0 var(--dsw-alias-state-business-primary)}",
198
- ".dph_mainCol{display:flex;flex-direction:column;gap:9px;min-width:0}",
226
+ ".dph_mainCol{display:flex;flex-direction:column;gap:12px;min-width:0}",
199
227
  ".dph_sectionHead{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}",
200
228
  ".dph_sectionTitle{margin:0;font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary)}",
201
229
  ".dph_sectionCount{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
202
- ".dph_rail{display:flex;flex-direction:column;gap:10px;min-width:0;position:sticky;top:0}",
230
+ ".dph_rail{display:flex;flex-direction:column;gap:8px;min-width:0;position:sticky;top:0}",
203
231
  ".dph_railSlot{display:flex;flex-direction:column;gap:10px;min-width:0}",
204
- ".dph_railCard{display:flex;flex-direction:column;gap:5px;min-width:0;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:10px 11px}",
232
+ ".dph_railCard{display:flex;flex-direction:column;gap:8px;min-width:0;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:12px}",
205
233
  /* 今日推荐是侧栏里唯一"当天只有一个答案"的东西,给一条强调边区分于其它信息块 */
206
234
  ".dph_railCardAccent{border-left:3px solid var(--dsw-alias-state-business-primary)}",
207
235
  ".dph_railLabel{margin:0;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
@@ -219,17 +247,24 @@ window.__ModuleLoader__.load({
219
247
  ".dph_top3Num{flex:none;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}",
220
248
  /* 宽屏卡片:左内容 + 右 84px 操作轨道。只由 renderCard 的 wide 分支产出;
221
249
  浮窗 / 今日推荐 / 分类精选仍走原来的 .dph_card,互不影响。 */
222
- ".dph_cardLg{display:grid;grid-template-columns:minmax(0,1fr) 84px;gap:12px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);border-radius:10px;padding:11px 12px}",
223
- ".dph_cardLgMain{display:flex;flex-direction:column;gap:5px;min-width:0}",
250
+ ".dph_cardLg{display:grid;grid-template-columns:minmax(0,1fr) 88px;gap:14px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);border-radius:10px;padding:14px}",
251
+ ".dph_cardLgMain{display:flex;flex-direction:column;gap:10px;min-width:0}",
224
252
  ".dph_opRail{display:flex;flex-direction:column;gap:5px}",
225
253
  ".dph_opRail .dph_btn{width:100%;text-align:center;padding:5px 6px}",
226
- ".dph_btnSm{padding:3px 8px;font-size:11px}",
254
+ ".dph_btnSm{height:28px;padding:0 10px;font-size:12px;border-radius:8px;box-sizing:border-box}",
227
255
  /* 命令条:复制按钮内嵌右端,不再靠 flex:1 把按钮顶到卡的另一头 */
228
- ".dph_cmdbar{display:flex;align-items:center;gap:6px;min-width:0;background:var(--dsw-alias-bg-layer-3);border-radius:6px;padding:5px 6px 5px 9px}",
256
+ /* 分享(2026-10-21):与「复制命令」同行,所以命令条必须允许换行 ——
257
+ 浮窗只有 400px,展开后 4 个动作按钮放不下,不换行就会顶出卡片右边界。 */
258
+ ".dph_shareWrap{display:inline-flex;align-items:center;flex-wrap:wrap;gap:4px;max-width:100%}",
259
+ /* 212px 侧栏里的命令条是竖排(.dph_cmdbarCol),四个动作若各占一行会把卡片拉高近一半;
260
+ 改成两列网格即可。只在展开态生效,收起态仍是一颗普通按钮。 */
261
+ ".dph_cmdbarCol .dph_shareWrapOpen{display:grid;grid-template-columns:1fr 1fr;gap:6px;width:100%}",
262
+ ".dph_cmdbarCol .dph_shareWrapOpen .dph_btn{width:100%;text-align:center}",
263
+ ".dph_cmdbar{display:flex;align-items:center;gap:6px;row-gap:4px;flex-wrap:wrap;min-width:0;background:var(--dsw-alias-bg-layer-3);border-radius:6px;padding:5px 6px 5px 9px}",
229
264
  ".dph_cmdbarCode{flex:1;min-width:0;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--dsw-alias-label-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
230
265
  /* 212px 侧栏里的命令条:横向排会把命令截成「dsh plugin ----」(实测),
231
266
  改竖排 + 允许断词,命令必须完整可读 —— 它是这一块的行动依据。 */
232
- ".dph_cmdbarCol{flex-direction:column;align-items:stretch;gap:5px}",
267
+ ".dph_cmdbarCol{display:grid;grid-template-columns:1fr 1fr;align-items:center;gap:6px}",
233
268
  ".dph_cmdbarCol .dph_cmdbarCode{white-space:normal;overflow-wrap:anywhere;word-break:normal;line-height:1.5}",
234
269
  /* 侧栏里的安装行同理:包名在窄栏里必须能换行,否则会顶出卡片右边界 */
235
270
  ".dph_railCard .dph_instRow{flex-direction:column;align-items:stretch;gap:4px}",
@@ -241,7 +276,7 @@ window.__ModuleLoader__.load({
241
276
  这里不改小 —— 扫不出来的二维码等于没有入口。
242
277
  二维码**默认收起**:展开后高度约 +120px,页签首屏会被列表挤走,
243
278
  「入口存在但看不见」比没有入口更糟。 */
244
- ".dph_join{flex:none;display:flex;flex-direction:column;gap:7px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:10px 12px}",
279
+ ".dph_join{flex:none;display:flex;flex-direction:column;gap:8px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:12px 14px}",
245
280
  ".dph_joinHead{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}",
246
281
  ".dph_joinTitle{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary)}",
247
282
  ".dph_joinSub{font-size:11px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}",
@@ -253,7 +288,7 @@ window.__ModuleLoader__.load({
253
288
  ".dph_qrLink{font-size:11px;color:var(--dsw-alias-state-business-primary);text-decoration:none}",
254
289
  ".dph_qrLink:hover{text-decoration:underline}",
255
290
  ".dph_subForm{display:flex;align-items:center;gap:6px;flex-wrap:wrap;flex:1;min-width:0}",
256
- ".dph_subInput{flex:1;min-width:150px;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);border-radius:6px;padding:5px 9px;font:inherit;font-size:12px;outline:none}",
291
+ ".dph_subInput{flex:1;min-width:150px;box-sizing:border-box;height:28px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 9px;font:inherit;font-size:12px;outline:none}",
257
292
  ".dph_subInput:focus{border-color:var(--dsw-alias-state-business-primary)}",
258
293
  ".dph_joinMsg{font-size:11px;line-height:1.5;color:var(--dsw-alias-label-secondary)}",
259
294
  ".dph_joinOk{color:var(--dsw-alias-state-business-primary)}",
@@ -263,6 +298,26 @@ window.__ModuleLoader__.load({
263
298
  ".dph_joinCompact .dph_joinSub{display:none}",
264
299
  /* 设置页里是「卡中卡」:去掉外框,用一条分隔线接在更新日志之后 */
265
300
  ".dph_joinInSet{border:0;border-top:1px solid var(--dsw-alias-border-l2);border-radius:0;background:transparent;padding:12px 0 0}",
301
+ ".dph_workHead::before{content:\"\";width:3px;height:11px;border-radius:2px;background:var(--dsw-alias-state-business-primary)}",
302
+ ".dph_workHead .dph_sub{font-weight:400}",
303
+ /* 已安装:实底浅蓝 —— 它说的是「现在的事实」,与分类标签同形不同质 */
304
+ ".dph_tagSolid{background:var(--dsw-alias-state-business-tertiary);border-color:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-state-business-primary)}",
305
+ /* 选中(已进对比篮):整卡描边 + 极浅主色底。
306
+ 只靠按钮变蓝在长列表里认不出「这条被选了」——用户原话是「选中之后需要加高亮」。
307
+ 第二圈用 box-shadow inset 画,不加 border 宽度:改宽度会让卡片跳 1px。 */
308
+ ".dph_cardOn{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-state-business-tertiary);box-shadow:inset 0 0 0 1px var(--dsw-alias-state-business-primary)}",
309
+ /* 已收藏:只在左侧画 3px 竖条,不染色不描边 —— 收藏是跨会话的持久偏好,
310
+ 用户可能攒十几条,整卡染色会盖掉「对比选中」那个更临时的信号。
311
+ padding-left 从 14 减到 11:3px 边框 + 11px 内距 = 内容仍从 14px 起,不动版。 */
312
+ ".dph_cardFav{border-left:3px solid var(--dsw-alias-state-business-primary);padding-left:11px}",
313
+ /* 选中卡里的主按钮改回白底:浅蓝底 + 蓝描边按钮叠在一起会糊成一片 */
314
+ ".dph_cardOn .dph_btnPrimary{background:var(--dsw-alias-bg-layer-1)}",
315
+ /* 右栏命令条是两列网格:命令跨两列,复制/分享各占一格(展开态自然排成 2×2) */
316
+ ".dph_cmdbarCol .dph_cmdbarCode{grid-column:1/-1;font-size:11.5px}",
317
+ ".dph_cmdbarCol .dph_shareWrap,.dph_cmdbarCol .dph_shareWrap .dph_btn{width:100%}",
318
+ ".dph_cmdbarCol .dph_shareWrap .dph_btn{height:28px;padding:0 6px;font-size:11.5px}",
319
+ /* 响应式(2026-10-21):主列单栏时宽卡也拆单列,操作轨道转横排成一条动作行 */
320
+ "@media (max-width:900px){.dph_cardLg{grid-template-columns:minmax(0,1fr);gap:10px}.dph_opRail{flex-direction:row;flex-wrap:wrap;margin-top:2px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2)}.dph_opRail .dph_btn{flex:1 1 0;min-width:0}.dph_rail{position:static}}",
266
321
  ].join("");
267
322
  const tagId = "dsh-dpharness/client.css";
268
323
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
@@ -331,6 +386,18 @@ window.__ModuleLoader__.load({
331
386
  "action.openSite": "打开站点",
332
387
  "action.copy": "复制命令",
333
388
  "action.copied": "已复制",
389
+ /* 分享(2026-10-21):入口贴近「复制命令」—— 两者同属「把这条带走」,
390
+ 所以文案也贴着这两条放,翻译时一起改,别分到两个区块去。 */
391
+ "share.action": "分享",
392
+ "share.toggle": "把这条发给同事:链接 / 文案 / 说明图",
393
+ "share.closeHint": "收起分享选项",
394
+ "share.link": "复制链接",
395
+ "share.linkHint": "复制站点详情页链接(带 dsh 来源标识,落地可在渠道追踪里看到)",
396
+ "share.text": "复制文案",
397
+ "share.textHint": "标题 + 一句话卖点 + 链接,直接贴进群里",
398
+ "share.card": "说明图",
399
+ "share.cardHint": "下载这张插件的说明图(1200×630 PNG),发群或贴文用",
400
+ "share.collapse": "收起",
334
401
  "action.open": "严选插件",
335
402
  "action.show": "显示浮窗",
336
403
  "action.close": "收起",
@@ -555,6 +622,30 @@ window.__ModuleLoader__.load({
555
622
  "need.required": "必备",
556
623
  "need.enhance": "增强",
557
624
  "need.optional": "可选",
625
+ /* 周榜(2026-10-20):站点两条榜单线搬进插件。
626
+ 两者口径不同,文案里必须各自点名依据 —— 下载量 vs 站内复制安装
627
+ 差好几个数量级,用户拿它们互相对照就会得出错误结论。 */
628
+ "board.tab": "周榜",
629
+ "board.top": "精选 Top 榜",
630
+ "board.installs": "真装机周榜",
631
+ "board.topSub": "{n} 条 · 第 {p} 期",
632
+ "board.topSubLive": "{n} 条 · 实时口径",
633
+ "board.installsSub": "{n} 条 · 近 7 天",
634
+ "board.loading": "正在取当期周榜…",
635
+ "board.empty": "本周还没有可上榜的数据",
636
+ "board.topWhy": "按 npm 全网周下载量排序,每周一采集一期;期次是当时的数据,不随现在重算。",
637
+ "board.topWhyLive": "当期快照还没回填,这里显示的是实时口径(没有期次)。",
638
+ "board.installsWhy": "按本站「复制安装」的人数排序 —— 本站实测,不是全网热度,不能和上面的下载量榜对照。",
639
+ "board.weekly": "周下载 {n}",
640
+ "board.thisWeek": "本周 {n} 人",
641
+ "board.prevWeek": "上周 {m} 人",
642
+ "board.deltaUp": "↑{n}",
643
+ "board.deltaDown": "↓{n}",
644
+ "board.deltaNew": "新增",
645
+ "board.deltaFlat": "持平",
646
+ "board.offline": "站点榜单接口暂不可用(可能还没发版),点「打开官网」看完整榜单。",
647
+ /* 大数单位(见 fmtCount):中文按万,英文按 K —— 单位跟着语言走 */
648
+ "board.scale": "10000|万",
558
649
  /* 社群 + 订阅(页签 / 浮窗 / 设置页三处共用一套文案) */
559
650
  "join.title": "插件交流群已开放",
560
651
  "join.sub": "用法、报错、新插件,群里问更快",
@@ -571,7 +662,13 @@ window.__ModuleLoader__.load({
571
662
  "join.subscribe": "订阅",
572
663
  "join.sending": "发送中…",
573
664
  "join.subscribeOk": "确认信已发出,请到邮箱点确认",
574
- "join.subscribeFailed": "订阅失败,请稍后再试",
665
+ /* 失败文案按「错在哪一段」分开说(2026-10-20 实测踩过):
666
+ 宿主未重启时路由根本没注册,请求拿不到 2xx,旧版把所有情况压成
667
+ 「订阅失败,请稍后再试」——用户对着一个已订阅的邮箱排不出任何线索。 */
668
+ "join.failRoute": "订阅失败(HTTP {code}):插件路由未加载 —— 完全退出 dsh 再打开后重试",
669
+ "join.failHttp": "订阅失败(HTTP {code})",
670
+ "join.failUpstream": "订阅失败(HTTP {code}):站点暂不可用,稍后再试",
671
+ "join.failNetwork": "订阅失败:连不上本机插件服务 —— 确认 dsh 正在运行",
575
672
  "join.needEmail": "请先填邮箱",
576
673
  "join.note": "邮箱只用于周报,可随时退订。",
577
674
  "join.past": "往期周报 →",
@@ -623,6 +720,16 @@ window.__ModuleLoader__.load({
623
720
  "action.openSite": "Open site",
624
721
  "action.copy": "Copy command",
625
722
  "action.copied": "Copied",
723
+ "share.action": "Share",
724
+ "share.toggle": "Send this to a teammate: link / text / card",
725
+ "share.closeHint": "Hide the share options",
726
+ "share.link": "Copy link",
727
+ "share.linkHint": "Copies the site detail-page URL with a dsh source tag (visible in channel tracking)",
728
+ "share.text": "Copy text",
729
+ "share.textHint": "Name + one-line pitch + link, ready to paste into a chat",
730
+ "share.card": "Card",
731
+ "share.cardHint": "Downloads the 1200×630 explainer card (PNG) for chats or posts",
732
+ "share.collapse": "Hide",
626
733
  "action.open": "Curated",
627
734
  "action.show": "Show the panel",
628
735
  "action.close": "Collapse",
@@ -842,6 +949,28 @@ window.__ModuleLoader__.load({
842
949
  "need.required": "Core",
843
950
  "need.enhance": "Enhance",
844
951
  "need.optional": "Optional",
952
+ /* Weekly boards: two different measurements — npm downloads vs.
953
+ in-site copy-install visitors. Never present them as comparable. */
954
+ "board.tab": "Weekly",
955
+ "board.top": "Top downloads",
956
+ "board.installs": "Real installs",
957
+ "board.topSub": "{n} items · issue {p}",
958
+ "board.topSubLive": "{n} items · live",
959
+ "board.installsSub": "{n} items · last 7 days",
960
+ "board.loading": "Loading this week's board…",
961
+ "board.empty": "No qualifying data for this week yet",
962
+ "board.topWhy": "Ranked by weekly npm downloads, captured every Monday; the issue is a snapshot, not a live re-rank.",
963
+ "board.topWhyLive": "This issue's snapshot has not been captured yet — showing a live ranking (no issue number).",
964
+ "board.installsWhy": "Ranked by unique visitors who copied an install command on this site — measured here, not a global popularity metric. Not comparable with the downloads board.",
965
+ "board.weekly": "{n}/wk",
966
+ "board.thisWeek": "{n} this week",
967
+ "board.prevWeek": "{m} last week",
968
+ "board.deltaUp": "↑{n}",
969
+ "board.deltaDown": "↓{n}",
970
+ "board.deltaNew": "new",
971
+ "board.deltaFlat": "flat",
972
+ "board.offline": "The site's board API is unavailable (probably not released yet). Use “Open site” to see the full board.",
973
+ "board.scale": "1000|K",
845
974
  "join.title": "Community group is open",
846
975
  "join.sub": "Usage, install errors and new plugins — asking in the group is faster",
847
976
  "join.showQr": "Show QR codes",
@@ -857,7 +986,10 @@ window.__ModuleLoader__.load({
857
986
  "join.subscribe": "Subscribe",
858
987
  "join.sending": "Sending…",
859
988
  "join.subscribeOk": "Confirmation sent — open your inbox and click the link",
860
- "join.subscribeFailed": "Subscription failed, please try again later",
989
+ "join.failRoute": "Subscribe failed (HTTP {code}): plugin route not loaded — quit dsh completely, reopen, then retry",
990
+ "join.failHttp": "Subscribe failed (HTTP {code})",
991
+ "join.failUpstream": "Subscribe failed (HTTP {code}): the site is unavailable, try again later",
992
+ "join.failNetwork": "Subscribe failed: cannot reach the local plugin service — make sure dsh is running",
861
993
  "join.needEmail": "Enter your email first",
862
994
  "join.note": "Used for the digest only; unsubscribe anytime.",
863
995
  "join.past": "Past issues →",
@@ -2456,6 +2588,68 @@ window.__ModuleLoader__.load({
2456
2588
  return { state, copiedCmd, markCopied, refresh: () => setReload((n) => n + 1) };
2457
2589
  }
2458
2590
 
2591
+ /**
2592
+ * 「周榜」取数:kind = top(npm 周下载)| installs(站内真装机)。
2593
+ *
2594
+ * 与 useBest / useSets 的三处刻意差别:
2595
+ * ① **按 kind 分别取**,切到另一个榜必须重新请求(不能拿上一条缓存充数:
2596
+ * 两个榜的字段不同,混用会让装机榜显示成下载量);
2597
+ * ② 不设「拿到一次就不再请求」的 loaded 闸 —— 装机榜的窗口是滚动的,
2598
+ * 面板开一整天还显示早上那份就会自相矛盾;真正的成本闸在 host 端
2599
+ * (top 5 分钟 / installs 60 秒);
2600
+ * ③ 卸载时 abort 在途请求:快速来回切两个榜时,晚到的旧响应会覆盖新数据。
2601
+ *
2602
+ * 出错时把「站点接口还没发版(404)」与「真的失败了」分开说 ——
2603
+ * 前者有明确的下一步(去官网看),后者才该说"失败"。
2604
+ */
2605
+ function useBoard(t, kind, enabled) {
2606
+ const [reload, setReload] = react.useState(0);
2607
+ const [state, setState] = react.useState({ loading: false, kind: null, data: null, error: null });
2608
+
2609
+ react.useEffect(() => {
2610
+ if (!enabled) return undefined;
2611
+ const controller = new AbortController();
2612
+ const timer = setTimeout(() => controller.abort(), 20000);
2613
+ /* 换榜时先把上一条数据摘掉:两榜条目字段不同,留着只会显示错东西 */
2614
+ setState((previous) => ({
2615
+ loading: true,
2616
+ kind,
2617
+ data: previous.kind === kind ? previous.data : null,
2618
+ error: null,
2619
+ }));
2620
+ readHostJson("/api/dpharness/board?kind=" + kind, controller.signal)
2621
+ .then((body) => {
2622
+ if (controller.signal.aborted) return;
2623
+ setState({ loading: false, kind, data: body, error: null });
2624
+ track("plugin_hub", { action: "board_open", kind, n: (body && body.total) || 0 });
2625
+ })
2626
+ .catch((error) => {
2627
+ if (controller.signal.aborted) return;
2628
+ const message = error && error.name === "AbortError" ? "timeout" : String((error && error.message) || error);
2629
+ setState((previous) => ({ loading: false, kind, data: previous.kind === kind ? previous.data : null, error: message }));
2630
+ })
2631
+ .finally(() => clearTimeout(timer));
2632
+ return () => {
2633
+ clearTimeout(timer);
2634
+ controller.abort();
2635
+ };
2636
+ }, [enabled, kind, reload]);
2637
+
2638
+ const [copiedCmd, setCopiedCmd] = react.useState("");
2639
+ const markCopied = react.useCallback((text) => {
2640
+ setCopiedCmd(text);
2641
+ setTimeout(() => setCopiedCmd((current) => (current === text ? "" : current)), 2000);
2642
+ }, []);
2643
+
2644
+ return {
2645
+ state,
2646
+ copiedCmd,
2647
+ markCopied,
2648
+ refresh: () => setReload((n) => n + 1),
2649
+ items: state.data && Array.isArray(state.data.items) ? state.data.items : [],
2650
+ };
2651
+ }
2652
+
2459
2653
  /**
2460
2654
  * 更新日志(本机 host 的只读接口)。
2461
2655
  *
@@ -2749,7 +2943,7 @@ window.__ModuleLoader__.load({
2749
2943
  item.rank
2750
2944
  ? h("div", { className: "dph_bestRank", key: "rank" }, "#" + item.rank)
2751
2945
  : null,
2752
- renderCard(item, copiedCmd, onCopied, true),
2946
+ renderCard(item, copiedCmd, onCopied, true, false, false, "best"),
2753
2947
  item.reason
2754
2948
  ? h("div", { className: "dph_bestReason", key: "why" }, item.reason)
2755
2949
  : null,
@@ -2813,6 +3007,72 @@ window.__ModuleLoader__.load({
2813
3007
  ]);
2814
3008
  }
2815
3009
 
3010
+ /**
3011
+ * 数字口径(周下载量这类大数)。
3012
+ *
3013
+ * 为什么单位来自词典而不是代码:中文读「万」、英文读「K/M」,
3014
+ * 写死一种语言就等于在另一种语言里输出乱码式数字("54.8 万" 出现在英文界面)。
3015
+ * 词典键 `board.scale` 形如 `10000|万` / `1000|K`。
3016
+ */
3017
+ function fmtCount(n, t) {
3018
+ const v = Math.round(Number(n) || 0);
3019
+ if (!Number.isFinite(v) || v <= 0) return "0";
3020
+ const scale = String(t("board.scale") || "1000|K").split("|");
3021
+ const div = Number(scale[0]) || 1000;
3022
+ const unit = scale[1] || "K";
3023
+ if (v < div) return String(v);
3024
+ const w = v / div;
3025
+ const num = w >= 100 ? String(Math.round(w)) : w.toFixed(1).replace(/\.0$/, "");
3026
+ return num + " " + unit;
3027
+ }
3028
+
3029
+ /**
3030
+ * 「周榜」列表:名次 + 依据 → 复用同一张插件卡。
3031
+ *
3032
+ * 为什么不新写一张卡:安装命令、已装态、汉化兜底、copy_install 埋点
3033
+ * 全在 renderCard 里,复制一份必然分叉 —— 站点侧已经为「同一个插件
3034
+ * 在两个出口给出两套命令」付过代价(lib/installCmd.ts 头部注释)。
3035
+ * 本函数只负责卡片**上面**那一行:第几名、凭什么上榜。
3036
+ *
3037
+ * 名次优先用上游给的 rank(top 是快照固化的名次,installs 侧没有),
3038
+ * 缺失时按下标补,避免出现「第 0 名」。
3039
+ */
3040
+ function renderBoard(data, kind, copiedCmd, onCopied, opts) {
3041
+ if (!data) return null;
3042
+ const items = Array.isArray(data.items) ? data.items : [];
3043
+ const wide = !!(opts && opts.wide);
3044
+ return items.map((item, index) => {
3045
+ const rank = typeof item.rank === "number" && item.rank > 0 ? item.rank : index + 1;
3046
+ const metric =
3047
+ kind === "top"
3048
+ ? format(t("board.weekly"), { n: fmtCount(item.weekly, t) })
3049
+ : format(t("board.thisWeek"), { n: item.thisUv }) + " · " + format(t("board.prevWeek"), { m: item.prevUv });
3050
+ /* 增减只在装机榜有意义:下载量榜的期次差值不在这里算(快照之间对比是另一件事) */
3051
+ const prev = Number(item.prevUv) || 0;
3052
+ const delta = Number(item.delta) || 0;
3053
+ const deltaText =
3054
+ kind !== "installs"
3055
+ ? null
3056
+ : prev === 0 && delta > 0
3057
+ ? t("board.deltaNew")
3058
+ : delta > 0
3059
+ ? format(t("board.deltaUp"), { n: delta })
3060
+ : delta < 0
3061
+ ? format(t("board.deltaDown"), { n: -delta })
3062
+ : t("board.deltaFlat");
3063
+ return h("div", { className: "dph_boardItem", key: item.fullName || "board" + index }, [
3064
+ h("div", { className: "dph_boardHead", key: "head" }, [
3065
+ h("span", { className: "dph_boardRank", key: "rank" }, "#" + rank),
3066
+ h("span", { className: "dph_boardMetric", key: "metric" }, metric),
3067
+ deltaText ? h("span", { className: "dph_boardDelta", key: "delta" }, deltaText) : null,
3068
+ h("span", { className: "dph_spacer", key: "gap" }),
3069
+ item.src === "repo" ? h("span", { className: "dph_tag", key: "src" }, t("label.repoSource")) : null,
3070
+ ]),
3071
+ renderCard(item, copiedCmd, onCopied, !wide, false, wide, "board"),
3072
+ ]);
3073
+ });
3074
+ }
3075
+
2816
3076
  /**
2817
3077
  * 「套装」视图:一整套方案(跨插件纵向组合)→ 槽位 → 批量命令。
2818
3078
  *
@@ -2847,14 +3107,17 @@ window.__ModuleLoader__.load({
2847
3107
  set.syncedMonth && set.syncedSlots ? h("span", { className: "dph_tag", key: "sync" }, format(t("sets.synced"), { m: set.syncedMonth, s: set.syncedSlots })) : null,
2848
3108
  ])
2849
3109
  : null,
2850
- h("div", { className: "dph_list", key: "list" }, (set.items || []).map((item) =>
2851
- h("div", { className: "dph_setRow", key: item.fullName }, [
2852
- h("span", { className: "dph_setRole", key: "role", title: item.slotRole || "" }, item.slotRole || ""),
2853
- h("span", { className: "dph_setName", key: "name" }, item.nameZh || item.name || item.fullName || ""),
2854
- h("span", { className: "dph_tag", key: "need" }, t("need." + (item.need || "enhance"))),
3110
+ /* 槽位行:类名**故意不复用 `.dph_setRow`**(那个名字归设置页,见样式区注释)。
3111
+ role 为空的条目(没有槽位定义的老套装)仍渲染空 span 占位:
3112
+ role 行是 `grid-column:1/-1` 的整行,缺了它这一格就少一行、与邻格错位。 */
3113
+ h("div", { className: "dph_slotGrid", key: "list" }, (set.items || []).map((item) =>
3114
+ h("div", { className: "dph_slotRow", key: item.fullName }, [
3115
+ h("span", { className: "dph_slotRole", key: "role", title: item.slotRole || "" }, item.slotRole || ""),
3116
+ h("span", { className: "dph_slotName", key: "name", title: item.nameZh || item.name || item.fullName || "" }, item.nameZh || item.name || item.fullName || ""),
3117
+ h("span", { className: "dph_tag dph_slotNeed", key: "need" }, t("need." + (item.need || "enhance"))),
2855
3118
  item.installed
2856
- ? h("span", { className: "dph_tag dph_tagOk", key: "inst" }, format(t("card.installed"), { v: item.installed }))
2857
- : h("span", { className: "dph_stars", key: "stars" }, format(t("badge.stars"), { n: item.stars })),
3119
+ ? h("span", { className: "dph_tag dph_tagOk dph_slotTail", key: "inst", title: format(t("card.installed"), { v: item.installed }) }, format(t("card.installed"), { v: item.installed }))
3120
+ : h("span", { className: "dph_stars dph_slotTail", key: "stars" }, format(t("badge.stars"), { n: item.stars })),
2858
3121
  ]),
2859
3122
  )),
2860
3123
  h("div", { className: "dph_logCmd", key: "install" }, h(SetInstallButton, { set: set })),
@@ -2964,6 +3227,138 @@ window.__ModuleLoader__.load({
2964
3227
  ]);
2965
3228
  }
2966
3229
 
3230
+ /* ------------------------------------------------------- share (2026-10-21) */
3231
+ /**
3232
+ * 把一条插件变成「能直接发出去的东西」。
3233
+ *
3234
+ * 为什么面板只给三个动作,不照搬站点 ShareButton 的 14 个平台入口:
3235
+ * · 微博 / X / QQ 的网页分享接口是给浏览器页设计的,桌面面板里跳编辑框
3236
+ * 比把文案直接贴进群多绕两步;
3237
+ * · 微信没有网页分享接口,站点用「PC 显示二维码、手机扫」绕过去 —— 这里
3238
+ * 方向正好相反:手机上装不了 dsh 插件,扫码过去只能看详情页,多一步零增量;
3239
+ * · 站点那套的价值在「网页里读完好转发」,而面板里用户是在挑插件,
3240
+ * 他要的是「这条能发给同事」的物料。
3241
+ *
3242
+ * 文案刻意**不带安装命令**:面板命令里的 --profile 是本机真实值(host 侧 PROFILE),
3243
+ * 接收方若用 web profile 就会装到别处(2026-10-12 已踩过)。只给链接,让对方在
3244
+ * 详情页拿他自己的命令 —— 详情页与验证器是同一口径。
3245
+ *
3246
+ * 说明图走站点的 /og-card(带 Content-Disposition: attachment),点一下即落盘。
3247
+ * 不走「取 PNG 再转 blob」:该接口不带 CORS 头,跨源 fetch 会被浏览器拒。
3248
+ */
3249
+ function sharePathOf(fullName) {
3250
+ return String(fullName || "").split("/").filter(Boolean).map(encodeURIComponent).join("/");
3251
+ }
3252
+
3253
+ /** 详情页 + 渠道参数。utm_source=dsh 已在站点 lib/source-glossary.ts 登记。 */
3254
+ function shareLinkOf(fullName) {
3255
+ const slug = String(fullName || "").replace(/\//g, "-");
3256
+ return SITE + "/plugin/" + sharePathOf(fullName)
3257
+ + "?utm_source=dsh&utm_medium=panel&utm_content=" + encodeURIComponent(slug);
3258
+ }
3259
+
3260
+ /** 1200×630 说明图;服务端声明 attachment,点击即下载。 */
3261
+ function shareCardOf(fullName) {
3262
+ return SITE + "/og-card/" + sharePathOf(fullName) + ".png";
3263
+ }
3264
+
3265
+ /**
3266
+ * 摘要截断:优先在句子边界收尾(与站点 ShareButton 的 clipText 同一策略)。
3267
+ * 裸 slice 会把文案切成半句话,分享出去读起来像没写完。
3268
+ * ① 句末标点(保留)② 句中停顿(去标点)③ 都没有才硬截 + 省略号。
3269
+ * ①② 的落点不得早于 max*0.6,否则回退过头、丢的信息比截断还多。
3270
+ */
3271
+ function shareClip(text, max) {
3272
+ const value = String(text || "").replace(/\s+/g, " ").trim();
3273
+ if (value.length <= max) return value;
3274
+ const head = value.slice(0, max);
3275
+ const floor = Math.floor(max * 0.6);
3276
+ const hard = Math.max(head.lastIndexOf("。"), head.lastIndexOf("!"), head.lastIndexOf("?"), head.lastIndexOf(";"));
3277
+ if (hard >= floor) return head.slice(0, hard + 1);
3278
+ const soft = Math.max(head.lastIndexOf(","), head.lastIndexOf("、"), head.lastIndexOf(":"));
3279
+ if (soft >= floor) return head.slice(0, soft);
3280
+ return head.trimEnd() + "…";
3281
+ }
3282
+
3283
+ /** 分享文案:标题行 + 一句话卖点 + 链接。可直接贴群、贴微博。 */
3284
+ function shareTextOf(item) {
3285
+ const title = item.nameZh || item.name || item.fullName || "";
3286
+ const head = title
3287
+ + (item.owner ? " @" + item.owner : "")
3288
+ + (Number(item.stars) > 0 ? " " + format(t("badge.stars"), { n: item.stars }) : "");
3289
+ const brief = shareClip(item.sell || item.descZh || "", 60);
3290
+ return (brief ? head + "\n" + brief : head) + "\n" + shareLinkOf(item.fullName);
3291
+ }
3292
+
3293
+ /**
3294
+ * 分享入口本体。**行内展开**,不是浮层:浮窗的 .dph_panelBody 是 overflow-y:auto,
3295
+ * 绝对定位弹层会被裁掉(HandoffToDesktop 踩过同类问题,那边能 portal 出去,
3296
+ * 这里 portal 出去会跟卡片脱节)。行内展开零定位风险,也与 InstallRow 的
3297
+ * 二次确认同一交互范式。
3298
+ *
3299
+ * scope = 视图名(picks / panel / daily / best / board),由 renderCard 传入,
3300
+ * 用来回答「哪个视图的人在分享」—— 卡片曝光拿不到,只能看分布与趋势。
3301
+ */
3302
+ function ShareUnit(props) {
3303
+ const item = props.item || {};
3304
+ const fullName = typeof item.fullName === "string" ? item.fullName : "";
3305
+ const scope = props.scope || "";
3306
+ const [open, setOpen] = react.useState(false);
3307
+ const [done, setDone] = react.useState("");
3308
+ /* 没有 owner/repo 就拼不出详情页(站点 /plugin/<owner>/<repo> 需要两段)——
3309
+ 宁可不渲染这个入口,也不给一个必然落到列表页的链接。hooks 已跑完,早退安全。 */
3310
+ if (fullName.indexOf("/") < 0) return null;
3311
+ const mark = (key) => {
3312
+ setDone(key);
3313
+ setTimeout(() => setDone((current) => (current === key ? "" : current)), 1800);
3314
+ };
3315
+ const copy = (kind, text) => copyText(text, () => {
3316
+ mark(kind);
3317
+ track("plugin_hub", { action: kind === "link" ? "share_link" : "share_text", scope });
3318
+ });
3319
+ const toggle = h("button", {
3320
+ className: "dph_btn" + (open ? " dph_btnPrimary" : ""),
3321
+ key: "toggle",
3322
+ type: "button",
3323
+ title: open ? t("share.closeHint") : t("share.toggle"),
3324
+ onClick: () => {
3325
+ const next = !open;
3326
+ setOpen(next);
3327
+ /* 打开与收起分开记:收起多半是误触或反悔,混进分享量会把分子放大。 */
3328
+ track("plugin_hub", { action: next ? "share_open" : "share_close", scope });
3329
+ },
3330
+ /* 展开后这个按钮自己变成「收起」—— 不再单列第四个「收起」按钮:
3331
+ 400px 浮窗里多一个按钮就多占一行,而这两个本来就是同一个开关。 */
3332
+ }, open ? t("share.collapse") : t("share.action"));
3333
+ if (!open) return h("span", { className: "dph_shareWrap", key: "share" }, [toggle]);
3334
+ return h("span", { className: "dph_shareWrap dph_shareWrapOpen", key: "share" }, [
3335
+ toggle,
3336
+ h("button", {
3337
+ className: "dph_btn dph_btnSm",
3338
+ key: "link",
3339
+ type: "button",
3340
+ title: t("share.linkHint"),
3341
+ onClick: () => copy("link", shareLinkOf(fullName)),
3342
+ }, done === "link" ? t("action.copied") : t("share.link")),
3343
+ h("button", {
3344
+ className: "dph_btn dph_btnSm",
3345
+ key: "text",
3346
+ type: "button",
3347
+ title: t("share.textHint"),
3348
+ onClick: () => copy("text", shareTextOf(item)),
3349
+ }, done === "text" ? t("action.copied") : t("share.text")),
3350
+ h("a", {
3351
+ className: "dph_btn dph_btnSm",
3352
+ key: "card",
3353
+ href: shareCardOf(fullName),
3354
+ target: "_blank",
3355
+ rel: "noopener noreferrer",
3356
+ title: t("share.cardHint"),
3357
+ onClick: () => track("plugin_hub", { action: "share_card", scope }),
3358
+ }, t("share.card")),
3359
+ ]);
3360
+ }
3361
+
2967
3362
  /**
2968
3363
  * 一张插件卡。
2969
3364
  *
@@ -2973,12 +3368,18 @@ window.__ModuleLoader__.load({
2973
3368
  * 操作轨道。原来靠 .dph_spacer 把 ★ 与 GitHub 顶到卡片两端,正文只占一半、
2974
3369
  * 右侧大片空白;挪成轨道后操作按列对齐、可纵向扫读(2026-10-19 A2)。
2975
3370
  * ⚠️ wide 必须由调用方显式传参,不能靠样式选择器自动套用 —— 本组件有 4 处复用。
3371
+ * scope 同理:只用于分享埋点的 via,缺省空串(老调用点不传也能跑)。
2976
3372
  */
2977
- function renderCard(item, copiedCmd, onCopied, compact, comparable, wide) {
3373
+ function renderCard(item, copiedCmd, onCopied, compact, comparable, wide, scope) {
2978
3374
  const title = item.nameZh || item.name || item.fullName || "";
2979
3375
  const tags = tagsOf(item);
2980
- // 卖点行:站点 tagline 经严格过滤后的结果;没有就不占位(宁可不显示,也不放英文原文或垃圾串)
2981
- const sellRow = item.sell
3376
+ /* 卖点行:站点 tagline 经严格过滤后的结果;没有就不占位(宁可不显示,也不放英文原文或垃圾串)。
3377
+ 2026-10-21:卖点与正文**开头相同**时只留正文。host 侧 slim() 在 tagline 缺失时
3378
+ 把 sell 回落到 descriptionZh,于是卡片上会出现两行几乎一样的字(真机截图里就是这样),
3379
+ 层级反而被抹平 —— 判据取前 16 字,足够区分「同一句话」与「同一主题的两种说法」。 */
3380
+ const sellEcho = item.sell && item.descZh
3381
+ && (item.descZh.startsWith(item.sell.slice(0, 16)) || item.sell.startsWith(item.descZh));
3382
+ const sellRow = item.sell && !sellEcho
2982
3383
  ? h("div", { className: "dph_sell", key: "sell" }, [
2983
3384
  h("span", { className: "dph_sellTag", key: "tag" }, t("label.sell")),
2984
3385
  h("span", { className: "dph_sellText", key: "text" }, item.sell),
@@ -2994,9 +3395,14 @@ window.__ModuleLoader__.load({
2994
3395
  ])
2995
3396
  : null;
2996
3397
  /* 已经装过就直说 —— 实测有用户对着一个早就装好的插件反复点「安装」,
2997
- 然后判定"安装不成功"(他无从知道那东西其实已经在跑了)。 */
2998
- const installedRow = item.installed
2999
- ? h("div", { className: "dph_tags", key: "installed" }, h("span", { className: "dph_tag dph_tagOk" }, format(t("card.installed"), { v: item.installed })))
3398
+ 然后判定"安装不成功"(他无从知道那东西其实已经在跑了)。
3399
+ 2026-10-21 版式:已安装并入标签行(实底浅蓝)。它和分类标签同属
3400
+ 「这条现在什么状态」,单开一行既多 20px、又让人以为是另一种层级。 */
3401
+ const installedChip = item.installed
3402
+ ? h("span", { className: "dph_tag dph_tagSolid", key: "installed" }, format(t("card.installed"), { v: item.installed }))
3403
+ : null;
3404
+ const tagRow = (tags.length || installedChip)
3405
+ ? h("div", { className: "dph_tags", key: "tags" }, installedChip ? tags.concat([installedChip]) : tags)
3000
3406
  : null;
3001
3407
  const onCopy = () => copyText(item.cmd, () => {
3002
3408
  onCopied(item.cmd);
@@ -3034,15 +3440,22 @@ window.__ModuleLoader__.load({
3034
3440
  : null;
3035
3441
 
3036
3442
  if (wide) {
3037
- /* 命令条通栏、复制按钮内嵌右端 —— 短命令不再拉出一条空白 */
3443
+ /* 命令条通栏、复制按钮内嵌右端 —— 短命令不再拉出一条空白。
3444
+ 分享与复制命令同处一条:都是「把这条带走」,分开摆要来回找。 */
3445
+ const share = h(ShareUnit, { item: item, scope: scope, key: "share" });
3038
3446
  const bar = item.cmd
3039
3447
  ? h("div", { className: "dph_cmdbar", key: "cmd" }, [
3040
3448
  h("code", { className: "dph_cmdbarCode", key: "code" }, item.cmd),
3041
3449
  h("button", { className: "dph_btn dph_btnSm", key: "copy", type: "button", onClick: onCopy },
3042
3450
  copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
3451
+ share,
3043
3452
  ])
3044
- : h("div", { className: "dph_cmdMissing", key: "cmd" }, t("cmd.missing"));
3045
- return h("div", { className: "dph_cardLg", key: item.fullName || title }, [
3453
+ : h("div", { className: "dph_cmdMissing", key: "cmd" }, [
3454
+ h("span", { key: "text" }, t("cmd.missing")),
3455
+ /* 命令缺失不等于不能分享:这条仍可发给同事,让对方自己判断 */
3456
+ share,
3457
+ ]);
3458
+ return h("div", { className: "dph_cardLg" + (comparable && inCompare(item) ? " dph_cardOn" : "") + (comparable && inFav(item) ? " dph_cardFav" : ""), key: item.fullName || title }, [
3046
3459
  h("div", { className: "dph_cardLgMain", key: "main" }, [
3047
3460
  h("div", { className: "dph_cardTop", key: "top" }, [
3048
3461
  h("span", { className: "dph_name", key: "name" }, title),
@@ -3050,8 +3463,7 @@ window.__ModuleLoader__.load({
3050
3463
  h("span", { className: "dph_stars", key: "stars" }, format(t("badge.stars"), { n: item.stars })),
3051
3464
  item.src === "repo" ? h("span", { className: "dph_tag", key: "src" }, t("label.repoSource")) : null,
3052
3465
  ]),
3053
- tags.length ? h("div", { className: "dph_tags", key: "tags" }, tags) : null,
3054
- installedRow,
3466
+ tagRow,
3055
3467
  sellRow,
3056
3468
  descRow,
3057
3469
  h(InstallRow, { item: item, key: "install" }),
@@ -3061,6 +3473,8 @@ window.__ModuleLoader__.load({
3061
3473
  ]);
3062
3474
  }
3063
3475
 
3476
+ /* 窄卡同理:分享紧挨复制按钮(.dph_cmdRow 本来就会换行,展开后自动落到第二行) */
3477
+ const shareUnit = h(ShareUnit, { item: item, scope: scope, key: "share" });
3064
3478
  const cmdRow = item.cmd
3065
3479
  ? h("div", { className: "dph_cmdWrap", key: "cmd" }, [
3066
3480
  h("div", { className: "dph_cmdRow", key: "row" }, [
@@ -3071,12 +3485,16 @@ window.__ModuleLoader__.load({
3071
3485
  h("code", { className: "dph_cmd", key: "code" }, item.cmd),
3072
3486
  h("button", { className: "dph_btn", key: "copy", type: "button", onClick: onCopy },
3073
3487
  copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
3488
+ shareUnit,
3074
3489
  ]),
3075
3490
  item.src === "repo" ? h("div", { className: "dph_instHint", key: "hint" }, t("hint.repoSource")) : null,
3076
3491
  ])
3077
- : h("div", { className: "dph_cmdMissing", key: "cmd" }, t("cmd.missing"));
3492
+ : h("div", { className: "dph_cmdMissing", key: "cmd" }, [
3493
+ h("span", { key: "text" }, t("cmd.missing")),
3494
+ shareUnit,
3495
+ ]);
3078
3496
 
3079
- return h("div", { className: "dph_card" + (compact ? " dph_cardSm" : ""), key: item.fullName || title }, [
3497
+ return h("div", { className: "dph_card" + (compact ? " dph_cardSm" : "") + (comparable && inCompare(item) ? " dph_cardOn" : "") + (comparable && inFav(item) ? " dph_cardFav" : ""), key: item.fullName || title }, [
3080
3498
  h("div", { className: "dph_cardTop", key: "top" }, [
3081
3499
  cmpBtn,
3082
3500
  favBtn,
@@ -3086,8 +3504,7 @@ window.__ModuleLoader__.load({
3086
3504
  h("span", { className: "dph_stars", key: "stars" }, format(t("badge.stars"), { n: item.stars })),
3087
3505
  linkBtn,
3088
3506
  ]),
3089
- tags.length ? h("div", { className: "dph_tags", key: "tags" }, tags) : null,
3090
- installedRow,
3507
+ tagRow,
3091
3508
  sellRow,
3092
3509
  descRow,
3093
3510
  h(InstallRow, { item: item, key: "install" }),
@@ -3138,7 +3555,7 @@ window.__ModuleLoader__.load({
3138
3555
  if (opts.collapsed) return h("div", { className: "dph_daily", key: "daily" }, [head]);
3139
3556
  return h("div", { className: "dph_daily", key: "daily" }, [
3140
3557
  head,
3141
- renderCard(picked.item, copiedCmd, onCopied, true),
3558
+ renderCard(picked.item, copiedCmd, onCopied, true, false, false, "daily"),
3142
3559
  picked.item.reason
3143
3560
  ? h("p", { className: "dph_dailyWhy", key: "why" }, t("daily.why") + ":" + picked.item.reason)
3144
3561
  : null,
@@ -4163,17 +4580,31 @@ window.__ModuleLoader__.load({
4163
4580
  response.json().catch(() => ({})).then((data) => ({ response, data })),
4164
4581
  )
4165
4582
  .then((pair) => {
4583
+ const response = pair.response;
4166
4584
  const data = pair.data || {};
4167
- if (!pair.response.ok || data.ok === false) {
4168
- /* 服务端的 error 是中文人话(邮箱格式 / 频率限制),直接透出 */
4169
- setSub({ phase: "bad", text: data.error || t("join.subscribeFailed") });
4585
+ /* content-type 判断很关键:宿主没注册这个前缀时,SPA 兜底会回一份
4586
+ HTML(200),只判 response.ok 会被当成成功,界面显示空白或假成功。 */
4587
+ const jsonType = String(response.headers.get("content-type") || "").indexOf("application/json") >= 0;
4588
+ const detail = typeof data.error === "string" ? data.error : "";
4589
+ if (!response.ok || !jsonType || data.ok === false) {
4590
+ let text;
4591
+ if (response.status === 404 || !jsonType) {
4592
+ /* 路由不在(或拿回网页):只有完全重启 dsh 才会重新注册 —— 路由只在进程启动时挂一次 */
4593
+ text = format(t("join.failRoute"), { code: String(response.status) });
4594
+ } else if (response.status >= 500) {
4595
+ text = detail || format(t("join.failUpstream"), { code: String(response.status) });
4596
+ } else {
4597
+ /* 4xx:服务端给了中文人话(邮箱格式 / 频率限制)就原样透出 */
4598
+ text = detail || format(t("join.failHttp"), { code: String(response.status) });
4599
+ }
4600
+ setSub({ phase: "bad", text });
4170
4601
  return;
4171
4602
  }
4172
4603
  setEmail("");
4173
4604
  setSub({ phase: "ok", text: data.message || t("join.subscribeOk") });
4174
4605
  track("plugin_hub", { action: "subscribe_ok" });
4175
4606
  })
4176
- .catch(() => setSub({ phase: "bad", text: t("join.subscribeFailed") }));
4607
+ .catch(() => setSub({ phase: "bad", text: t("join.failNetwork") }));
4177
4608
  }
4178
4609
 
4179
4610
  const qrRow = open
@@ -4375,6 +4806,9 @@ window.__ModuleLoader__.load({
4375
4806
  track("copy_install", { cmd: item.cmd, pkg: item.pkg || "" });
4376
4807
  }),
4377
4808
  }, copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
4809
+ /* 侧栏这条命令条是**自建**的(不走 renderCard),所以分享要单独接一次。
4810
+ 2026-10-21 首版漏了这一处:用户在真机截图里发现"今日推荐卡没有分享"。 */
4811
+ h(ShareUnit, { item: item, scope: "rail", key: "share" }),
4378
4812
  ])
4379
4813
  : null,
4380
4814
  item.reason ? h("p", { className: "dph_railWhy", key: "why" }, t("daily.why") + ":" + item.reason) : null,
@@ -4400,6 +4834,9 @@ window.__ModuleLoader__.load({
4400
4834
  每日推荐的显隐同样读这个 store(设置页改完这里要跟着变)。 */
4401
4835
  const state = useHub();
4402
4836
  const [mode, setMode] = react.useState("search");
4837
+ /* 周榜内部的两条线(top / installs)。默认 top:它与分类精选同属"全网热度"
4838
+ 口径,先给用户熟悉的那一半;装机榜是本站私有信号,解释成本更高。 */
4839
+ const [boardKind, setBoardKind] = react.useState("top");
4403
4840
  /* 对比表开没开 ── 每个面各自记(选择集在 hub 上共享,表格的展开状态是本面的) */
4404
4841
  const [comparing, setComparing] = react.useState(false);
4405
4842
  const dateKey = useDateKey();
@@ -4408,40 +4845,54 @@ window.__ModuleLoader__.load({
4408
4845
  不给侧栏新增任何请求 —— 全站只有这一个数据源。 */
4409
4846
  const best = useBest(t, mode === "best" || mode === "daily" || state.daily);
4410
4847
  const sets = useSets(t, mode === "sets");
4848
+ const board = useBoard(t, boardKind, mode === "board");
4411
4849
  const data = cat.state.data;
4412
4850
  const bestData = best.state.data;
4413
4851
  const setsData = sets.state.data;
4852
+ const boardData = board.state.data;
4414
4853
  const isBest = mode === "best";
4415
4854
  const isDaily = mode === "daily";
4416
4855
  const isUpdate = mode === "update";
4417
4856
  const isSets = mode === "sets";
4857
+ const isBoard = mode === "board";
4418
4858
 
4419
4859
  /* 页头副标题与区标题分工:页头说「这是什么」(固定口径),
4420
4860
  区标题说「现在看到的是哪一段 + 多少条」。
4421
4861
  两处都写"共 N 条"会让页面重复又啰嗦(原版就是这个毛病)。 */
4422
- const headSub = isSets || isBest || isDaily || isUpdate ? "" : t("view.sub");
4862
+ const headSub = isSets || isBest || isDaily || isUpdate || isBoard ? "" : t("view.sub");
4423
4863
  const sectionTitle = isUpdate
4424
4864
  ? t("section.updates")
4425
4865
  : isSets
4426
4866
  ? t("section.sets")
4427
- : isBest
4428
- ? t("section.best")
4429
- : isDaily
4430
- ? t("section.daily")
4431
- : t("section.browse");
4867
+ : isBoard
4868
+ ? t("board.tab")
4869
+ : isBest
4870
+ ? t("section.best")
4871
+ : isDaily
4872
+ ? t("section.daily")
4873
+ : t("section.browse");
4432
4874
  const sectionCount = isUpdate
4433
4875
  ? ""
4434
4876
  : isSets
4435
4877
  ? (setsData ? format(t("sets.count"), { n: setsData.total || 0 }) : "")
4436
- : isBest
4437
- ? (bestData ? format(t("best.month"), { m: bestData.month || "" }) : "")
4438
- : isDaily
4439
- ? dateKey
4440
- : countSub(data, t, cat.state.loading, "");
4878
+ : isBoard
4879
+ ? (boardData
4880
+ ? boardKind === "top"
4881
+ ? boardData.periodNo
4882
+ ? format(t("board.topSub"), { n: boardData.total || 0, p: boardData.periodNo })
4883
+ : format(t("board.topSubLive"), { n: boardData.total || 0 })
4884
+ : format(t("board.installsSub"), { n: boardData.total || 0 })
4885
+ : "")
4886
+ : isBest
4887
+ ? (bestData ? format(t("best.month"), { m: bestData.month || "" }) : "")
4888
+ : isDaily
4889
+ ? dateKey
4890
+ : countSub(data, t, cat.state.loading, "");
4441
4891
 
4442
4892
  const TABS = [
4443
4893
  { value: "search", label: t("best.recommend") },
4444
4894
  { value: "best", label: t("best.picks") },
4895
+ { value: "board", label: t("board.tab") },
4445
4896
  { value: "sets", label: t("sets.tab") },
4446
4897
  { value: "daily", label: t("daily.tab") },
4447
4898
  { value: "update", label: t("updates.tab") },
@@ -4461,6 +4912,30 @@ window.__ModuleLoader__.load({
4461
4912
  ? [
4462
4913
  h("div", { className: "dph_list", key: "dlist" }, dailyCard(best, best.copiedCmd, best.markCopied, { dateKey: dateKey })),
4463
4914
  ]
4915
+ : isBoard
4916
+ ? [
4917
+ /* 两条线用二级切换,不再拆两个顶级页签:顶级页签已经 6 个,
4918
+ 而且用户的心智是"看榜",不是"看两个榜"。 */
4919
+ h("div", { className: "dph_bar", key: "bkind" }, seg([
4920
+ { value: "top", label: t("board.top") },
4921
+ { value: "installs", label: t("board.installs") },
4922
+ ], boardKind, setBoardKind)),
4923
+ /* 口径必须常驻一行:两个榜的量级差几个数量级,不解释就会被互相对照 */
4924
+ h("p", { className: "dph_boardWhy", key: "why" },
4925
+ boardKind === "top"
4926
+ ? (boardData && boardData.live ? t("board.topWhyLive") : t("board.topWhy"))
4927
+ : t("board.installsWhy")),
4928
+ board.state.error
4929
+ ? h(Notice, {
4930
+ key: "boerror",
4931
+ kind: "bad",
4932
+ text: /404/.test(board.state.error) ? t("board.offline") : t("state.failed") + ":" + board.state.error,
4933
+ })
4934
+ : null,
4935
+ board.state.loading && !boardData ? h(Notice, { key: "boloading", text: t("board.loading") }) : null,
4936
+ !board.state.loading && boardData && (boardData.total || 0) === 0 ? h(Notice, { key: "boempty", text: t("board.empty") }) : null,
4937
+ h("div", { className: "dph_list", key: "bolist" }, renderBoard(boardData, boardKind, board.copiedCmd, board.markCopied, { wide: true })),
4938
+ ]
4464
4939
  : isBest
4465
4940
  ? [
4466
4941
  best.state.error ? h(Notice, { key: "berror", kind: "bad", text: t("state.failed") + ":" + best.state.error }) : null,
@@ -4475,7 +4950,7 @@ window.__ModuleLoader__.load({
4475
4950
  !cat.state.loading && !cat.state.error && cat.plugins.length === 0 ? h(Notice, { key: "empty", text: t("state.empty") }) : null,
4476
4951
  h(CompareBar, { key: "cmpBar", open: comparing, onToggle: () => setComparing((value) => !value) }),
4477
4952
  comparing ? h(CompareTable, { key: "cmp", copiedCmd: cat.copiedCmd, markCopied: cat.markCopied }) : null,
4478
- h("div", { className: "dph_list", key: "list" }, cat.plugins.map((item) => renderCard(item, cat.copiedCmd, cat.markCopied, false, true, true))),
4953
+ h("div", { className: "dph_list", key: "list" }, cat.plugins.map((item) => renderCard(item, cat.copiedCmd, cat.markCopied, false, true, true, "picks"))),
4479
4954
  ];
4480
4955
 
4481
4956
  /* ── 侧栏:今日推荐(「每日推荐」视图里正文已经是这条,不重复)+ 各小类冠军 + 安装须知 ── */
@@ -4525,12 +5000,14 @@ window.__ModuleLoader__.load({
4525
5000
  h("a", {
4526
5001
  className: "dph_btn",
4527
5002
  key: "site",
4528
- href: isSets ? SITE + "/sets" : isBest ? SITE + "/best" : SITE + "/plugins",
5003
+ /* 周榜按当前子榜给对应站点页:本站两个榜是**两个独立页面**,
5004
+ 点错了会看到另一套口径(/top 是下载量,/ranking/installs 是站内装机)。 */
5005
+ href: isBoard ? SITE + (boardKind === "top" ? "/top" : "/ranking/installs") : isSets ? SITE + "/sets" : isBest ? SITE + "/best" : SITE + "/plugins",
4529
5006
  target: "_blank",
4530
5007
  rel: "noopener noreferrer",
4531
- onClick: () => track("plugin_hub", { action: "site_click", scope: isDaily ? "daily" : isSets ? "sets" : isBest ? "best" : "tab" }),
5008
+ onClick: () => track("plugin_hub", { action: "site_click", scope: isBoard ? "board_" + boardKind : isDaily ? "daily" : isSets ? "sets" : isBest ? "best" : "tab" }),
4532
5009
  }, t("action.openSite")),
4533
- h("button", { className: "dph_btn", key: "refresh", type: "button", onClick: isUpdate ? () => loadUpdates(true) : isSets ? sets.refresh : (isBest || isDaily) ? best.refresh : cat.refresh }, t("action.refresh")),
5010
+ h("button", { className: "dph_btn", key: "refresh", type: "button", onClick: isUpdate ? () => loadUpdates(true) : isBoard ? board.refresh : isSets ? sets.refresh : (isBest || isDaily) ? best.refresh : cat.refresh }, t("action.refresh")),
4534
5011
  ]),
4535
5012
  /* 页签是页级导航:用下划线而不是分段按钮 —— 原来那枚 seg 与正文控件同规格,
4536
5013
  读不出"它管着下面全部内容"(用户反馈"模块分布不清晰"的一部分)。 */
@@ -4656,6 +5133,8 @@ window.__ModuleLoader__.load({
4656
5133
  * 分成多个入口只会让人不知道该点哪个。
4657
5134
  */
4658
5135
  const [mode, setMode] = react.useState("search");
5136
+ /* 周榜子线(见 CatalogView 同名状态):两处各记一份,与 comparing 同理 */
5137
+ const [boardKind, setBoardKind] = react.useState("top");
4659
5138
  /* 对比表开没开 —— 与页签各记一份(选择集共享,展开状态是本面的) */
4660
5139
  const [comparing, setComparing] = react.useState(false);
4661
5140
  const dateKey = useDateKey();
@@ -4666,6 +5145,8 @@ window.__ModuleLoader__.load({
4666
5145
  const bestData = best.state.data;
4667
5146
  const sets = useSets(t, state.open && mode === "sets");
4668
5147
  const setsData = sets.state.data;
5148
+ const board = useBoard(t, boardKind, state.open && mode === "board");
5149
+ const boardData = board.state.data;
4669
5150
 
4670
5151
  /**
4671
5152
  * 展开时按**面板实际尺寸**重新夹取位置。
@@ -4771,18 +5252,28 @@ window.__ModuleLoader__.load({
4771
5252
  ? dateKey
4772
5253
  : mode === "sets"
4773
5254
  ? (setsData ? format(t("sets.count"), { n: setsData.total || 0 }) : "")
5255
+ : mode === "board"
5256
+ ? (boardData
5257
+ ? boardKind === "top"
5258
+ ? boardData.periodNo
5259
+ ? format(t("board.topSub"), { n: boardData.total || 0, p: boardData.periodNo })
5260
+ : format(t("board.topSubLive"), { n: boardData.total || 0 })
5261
+ : format(t("board.installsSub"), { n: boardData.total || 0 })
5262
+ : "")
4774
5263
  : mode === "best"
4775
5264
  ? (bestData ? format(t("best.month"), { m: bestData.month || "" }) : "")
4776
5265
  : mode === "update"
4777
5266
  ? ""
4778
5267
  : countSub(data, t, cat.state.loading)),
4779
5268
  h("span", { className: "dph_spacer", key: "gap" }),
4780
- h("a", { className: "dph_btn", key: "site", href: mode === "sets" ? SITE + "/sets" : mode === "best" ? SITE + "/best" : SITE + "/plugins", target: "_blank", rel: "noopener noreferrer", onClick: () => track("plugin_hub", { action: "site_click", scope: mode === "daily" ? "daily" : mode === "sets" ? "sets" : mode === "best" ? "best" : "overlay" }) }, t("action.openSite")),
5269
+ h("a", { className: "dph_btn", key: "site", href: mode === "board" ? SITE + (boardKind === "top" ? "/top" : "/ranking/installs") : mode === "sets" ? SITE + "/sets" : mode === "best" ? SITE + "/best" : SITE + "/plugins", target: "_blank", rel: "noopener noreferrer", onClick: () => track("plugin_hub", { action: "site_click", scope: mode === "board" ? "board_" + boardKind : mode === "daily" ? "daily" : mode === "sets" ? "sets" : mode === "best" ? "best" : "overlay" }) }, t("action.openSite")),
4781
5270
  h("button", { className: "dph_close", key: "close", type: "button", title: t("action.close"), "aria-label": t("action.close"), onClick: () => setHub({ open: false }) }, "×"),
4782
5271
  ]),
4783
- h("div", { className: "dph_segWrap", key: "seg" }, seg([
5272
+ /* 6 个视图在 372px 可用宽里会把四字标签挤到裁切 ⇒ 换滚动层(见样式注释) */
5273
+ h("div", { className: "dph_segWrap dph_segWrapScroll", key: "seg" }, seg([
4784
5274
  { value: "search", label: t("best.recommend") },
4785
5275
  { value: "best", label: t("best.picks") },
5276
+ { value: "board", label: t("board.tab") },
4786
5277
  { value: "sets", label: t("sets.tab") },
4787
5278
  { value: "daily", label: t("daily.tab") },
4788
5279
  { value: "update", label: t("updates.tab") },
@@ -4793,6 +5284,27 @@ window.__ModuleLoader__.load({
4793
5284
  ? [
4794
5285
  h("div", { className: "dph_panelBody", key: "ubody" }, h(UpdateView, { scope: "overlay" })),
4795
5286
  ]
5287
+ : mode === "board"
5288
+ ? [
5289
+ h("div", { className: "dph_bar", key: "bkind" }, seg([
5290
+ { value: "top", label: t("board.top") },
5291
+ { value: "installs", label: t("board.installs") },
5292
+ ], boardKind, setBoardKind)),
5293
+ h("p", { className: "dph_boardWhy", key: "why" },
5294
+ boardKind === "top"
5295
+ ? (boardData && boardData.live ? t("board.topWhyLive") : t("board.topWhy"))
5296
+ : t("board.installsWhy")),
5297
+ board.state.error
5298
+ ? h(Notice, {
5299
+ key: "boerror",
5300
+ kind: "bad",
5301
+ text: /404/.test(board.state.error) ? t("board.offline") : t("state.failed") + ":" + board.state.error,
5302
+ })
5303
+ : null,
5304
+ board.state.loading && !boardData ? h(Notice, { key: "boloading", text: t("board.loading") }) : null,
5305
+ !board.state.loading && boardData && (boardData.total || 0) === 0 ? h(Notice, { key: "boempty", text: t("board.empty") }) : null,
5306
+ h("div", { className: "dph_panelBody", key: "bobody" }, renderBoard(boardData, boardKind, board.copiedCmd, board.markCopied, { wide: false })),
5307
+ ]
4796
5308
  : mode === "sets"
4797
5309
  ? [
4798
5310
  sets.state.error ? h(Notice, { key: "serror", kind: "bad", text: t("state.failed") + ":" + sets.state.error }) : null,
@@ -4813,7 +5325,7 @@ window.__ModuleLoader__.load({
4813
5325
  !cat.state.loading && !cat.state.error && cat.plugins.length === 0 ? h(Notice, { key: "empty", text: t("state.empty") }) : null,
4814
5326
  h(CompareBar, { key: "cmpBar", open: comparing, onToggle: () => setComparing((value) => !value) }),
4815
5327
  comparing ? h(CompareTable, { key: "cmp", copiedCmd: cat.copiedCmd, markCopied: cat.markCopied }) : null,
4816
- h("div", { className: "dph_panelBody", key: "body" }, cat.plugins.map((item) => renderCard(item, cat.copiedCmd, cat.markCopied, true, true))),
5328
+ h("div", { className: "dph_panelBody", key: "body" }, cat.plugins.map((item) => renderCard(item, cat.copiedCmd, cat.markCopied, true, true, false, "panel"))),
4817
5329
  ]
4818
5330
  : [
4819
5331
  best.state.error ? h(Notice, { key: "berror", kind: "bad", text: t("state.failed") + ":" + best.state.error }) : null,
package/lib/index.js CHANGED
@@ -48,7 +48,7 @@ export const name = "dpharness";
48
48
  /** The dsh web server service used to register HTTP routes. */
49
49
  export const inject = ["webServer"];
50
50
 
51
- export const VERSION = "0.6.4";
51
+ export const VERSION = "0.6.5";
52
52
 
53
53
  /**
54
54
  * 本插件在 npm 上的包名 —— 与 dsh 的插件 id(上面的 `name = "dpharness"`)**不是一回事**,
@@ -1079,8 +1079,103 @@ async function fetchSets() {
1079
1079
  }
1080
1080
  }
1081
1081
 
1082
+ /**
1083
+ * 「周榜」两条线(站点 /api/board/{top,installs},2026-10-20 新增的只读接口)。
1084
+ *
1085
+ * ── 两个榜不是一回事,**不要合并**──────────────────────────────────────────
1086
+ * top = 精选插件 Top 榜:按 npm **全网周下载量**排序,20 条,周一落期次快照
1087
+ * installs = 真装机周榜:按站内 `copy_install` **去重访客**排序,30 条,滚动 7 天
1088
+ * 前者衡量"全网有多热",后者衡量"本站真有人在装"。两者差好几个数量级,
1089
+ * 放在同一个榜单里用户会互相对照并得出错误结论(站点侧同样是两个独立页面)。
1090
+ *
1091
+ * ── 字段为什么要重新拼 ─────────────────────────────────────────────────────
1092
+ * 两条上游的条目形状不同:
1093
+ * · top 直接给 `installCheck { status, pkgName }`(与 catalog 同形);
1094
+ * · installs 给的是扁平 `installStatus` + `pkgName`。
1095
+ * 若不在这里归一,`slim()` 就要长出第二个分支 —— 而它承载的是「命令该用包名
1096
+ * 还是 owner/repo」这条唯一口径。⇒ 归一放在本层,`slim()` 一行不改。
1097
+ *
1098
+ * ⚠️ 份额(sharePct)**有意不透传**:站内复制安装也计入本榜口径,榜进插件后
1099
+ * 上榜条目曝光更多、复制更多,份额会自我强化。卡片只给「本周 / 上周 / 增减」,
1100
+ * 足以判断趋势,不把百分比摊到用户面前。
1101
+ */
1102
+ const BOARD_UPSTREAM = `${SITE}/api/board`;
1103
+ /** 两个榜的缓存:top 一周才变(5 分钟足够),installs 与站点侧 60s 缓存对齐 */
1104
+ const BOARD_TTL_MS = { top: 300_000, installs: 60_000 };
1105
+ const boardCache = { top: { at: 0, value: null }, installs: { at: 0, value: null } };
1106
+
1107
+ async function fetchBoard(kind) {
1108
+ const now = Date.now();
1109
+ const slot = boardCache[kind];
1110
+ if (slot.value && now - slot.at < BOARD_TTL_MS[kind]) {
1111
+ return { ...slot.value, cached: true, fetchedAt: slot.at };
1112
+ }
1113
+ const controller = new AbortController();
1114
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
1115
+ try {
1116
+ const response = await fetch(`${BOARD_UPSTREAM}/${kind}`, {
1117
+ headers: { accept: "application/json", "user-agent": `dsh-dpharness/${VERSION}` },
1118
+ signal: controller.signal,
1119
+ });
1120
+ // 站点接口尚未发版时是 404 —— 让调用方拿到明确的状态码,不要伪装成"空榜单"
1121
+ if (!response.ok) throw new Error(`upstream HTTP ${response.status}`);
1122
+ const body = await response.json();
1123
+ const installed = installedMap();
1124
+ const items = (Array.isArray(body && body.items) ? body.items : []).map((raw) => {
1125
+ /* installs 侧的形状归一:扁平 installStatus → installCheck 对象。
1126
+ 只搬事实(pkgName 原样带过来,不做 pass 过滤),是否可信由 slim() 判定。 */
1127
+ const normalized =
1128
+ raw && raw.installCheck === undefined
1129
+ ? { ...raw, installCheck: raw.pkgName ? { status: raw.installStatus || null, pkgName: raw.pkgName } : null }
1130
+ : raw;
1131
+ const shaped = slim(normalized);
1132
+ const extra =
1133
+ kind === "top"
1134
+ ? { rank: Number(raw && raw.rank) || null, weekly: Number(raw && raw.weeklyDownloads) || 0 }
1135
+ : {
1136
+ rank: null,
1137
+ weekly: null,
1138
+ thisUv: Number(raw && raw.thisUv) || 0,
1139
+ prevUv: Number(raw && raw.prevUv) || 0,
1140
+ delta: Number(raw && raw.delta) || 0,
1141
+ };
1142
+ return Object.assign(shaped, extra, { installed: installedOf(shaped, installed) });
1143
+ });
1144
+ const value =
1145
+ kind === "top"
1146
+ ? {
1147
+ total: items.length,
1148
+ period: (body && body.period) || null,
1149
+ periodNo: (body && body.periodNo) || null,
1150
+ weekStart: (body && body.weekStart) || null,
1151
+ capturedAt: (body && body.capturedAt) || null,
1152
+ dataFrom: (body && body.dataFrom) || null,
1153
+ dataTo: (body && body.dataTo) || null,
1154
+ /* true = 当期快照还没回填,此次是实时口径(页面不得显示"第 N 期") */
1155
+ live: !!(body && body.isLive),
1156
+ eligibleCount: Number(body && body.eligibleCount) || 0,
1157
+ totalPlugins: Number(body && body.totalPlugins) || 0,
1158
+ items,
1159
+ }
1160
+ : {
1161
+ total: items.length,
1162
+ windowStart: (body && body.windowStart) || null,
1163
+ prevWindowStart: (body && body.prevWindowStart) || null,
1164
+ totalUv: Number(body && body.totalUv) || 0,
1165
+ totalPrevUv: Number(body && body.totalPrevUv) || 0,
1166
+ mappedUv: Number(body && body.mappedUv) || 0,
1167
+ items,
1168
+ };
1169
+ boardCache[kind] = { at: Date.now(), value };
1170
+ return { ...value, cached: false, fetchedAt: Date.now() };
1171
+ } finally {
1172
+ clearTimeout(timer);
1173
+ }
1174
+ }
1175
+
1082
1176
  function withinEventBudget() {
1083
- const now = Date.now(); if (now - eventWindow.startedAt > EVENT_WINDOW_MS) {
1177
+ const now = Date.now();
1178
+ if (now - eventWindow.startedAt > EVENT_WINDOW_MS) {
1084
1179
  eventWindow = { startedAt: now, count: 0 };
1085
1180
  }
1086
1181
  eventWindow.count += 1;
@@ -1673,6 +1768,50 @@ export function apply(ctx) {
1673
1768
  }
1674
1769
  });
1675
1770
 
1771
+ /**
1772
+ * 「周榜」:站点两条榜单线的同源数据(精选 Top 榜 / 真装机周榜)。
1773
+ *
1774
+ * kind 必填且白名单化:不给默认值 —— 默认成任何一个都会让
1775
+ * 「我明明点的是装机榜,怎么显示下载量」变成难查的静默错误。
1776
+ * 非法 kind 返回 400 + 允许值,而不是回落 top。
1777
+ */
1778
+ registerRoute(ctx, "/api/dpharness/board", async (req, res) => {
1779
+ if (req.method !== "GET") {
1780
+ res.writeHead(405, { allow: "GET" });
1781
+ res.end();
1782
+ return;
1783
+ }
1784
+ const kind = (readParams(req).get("kind") || "").trim();
1785
+ if (kind !== "top" && kind !== "installs") {
1786
+ sendJson(res, 400, {
1787
+ ok: false,
1788
+ error: "kind 必须是 top 或 installs",
1789
+ allowed: ["top", "installs"],
1790
+ });
1791
+ return;
1792
+ }
1793
+ try {
1794
+ const result = await fetchBoard(kind);
1795
+ const { cached, fetchedAt, ...payload } = result;
1796
+ sendJson(res, 200, {
1797
+ ok: true,
1798
+ kind,
1799
+ source: `${SITE}/api/board/${kind}`,
1800
+ cached,
1801
+ fetchedAt: new Date(fetchedAt).toISOString(),
1802
+ ...payload,
1803
+ });
1804
+ } catch (error) {
1805
+ sendJson(res, 502, {
1806
+ ok: false,
1807
+ kind,
1808
+ error: String((error && error.message) || error),
1809
+ /* 站点接口未上线时是 404:给客户端一句能照做的解释,别只丢状态码 */
1810
+ hint: "站点榜单接口暂不可用(可能尚未发版),可点「打开官网」查看完整榜单",
1811
+ });
1812
+ }
1813
+ });
1814
+
1676
1815
  registerRoute(ctx, "/api/dpharness/search", async (req, res) => {
1677
1816
  if (req.method !== "GET") {
1678
1817
  res.writeHead(405, { allow: "GET" });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-dpharness",
3
3
  "icon": "./icon.svg",
4
- "version": "0.6.4",
4
+ "version": "0.6.5",
5
5
  "description": "Curated dpharness.com plugin catalog inside the DeepSeek Harness Web GUI: a conversation-view tab, a sidebar entry and a dismissible site-wide floating panel, offering a searchable full catalog, a monthly by-category shortlist, a daily pick and an update check (this plugin plus every installed plugin) with a red-dot reminder, with one-click install via dshmarket or the dsh CLI. Includes a settings page (General row + Plugins tab) for the widget visibility, the daily pick, the update check and the opt-out telemetry relay covering the full install funnel.",
6
6
  "author": "zhanghao3693 <zhanghao3693@qq.com>",
7
7
  "repository": {
@@ -14,6 +14,10 @@
14
14
  },
15
15
  "type": "module",
16
16
  "main": "lib/index.js",
17
+ "scripts": {
18
+ "test": "node test-local.mjs",
19
+ "release": "node scripts/release.mjs"
20
+ },
17
21
  "exports": {
18
22
  "./locale/*.json": "./locale/*.json",
19
23
  ".": "./lib/index.js",