dsh-dpharness 0.6.2 → 0.6.4

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/client.js CHANGED
@@ -180,6 +180,89 @@ window.__ModuleLoader__.load({
180
180
  ".dph_updVer{font-size:12px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}",
181
181
  ".dph_updNote{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
182
182
  ".dph_updList{display:flex;flex-direction:column;gap:6px}",
183
+ /* ──────────────── 页签入口:双栏工作台(2026-10-19 A2 重构) ────────────────
184
+ 原来是一条 12px 等距的纵向流:页头 / 页签 / 今日推荐 / 筛选 / 列表 / 页脚
185
+ 全贴在同一张背景上,区块之间没有边界;宽屏下卡片正文只占一半、右侧空着。
186
+ 现在分四层:页头 + 页签 / 主列(检索与列表)/ 侧栏(决策信息)。
187
+ ⚠️ 两条实测要点:
188
+ 1) 主列与侧栏都必须 min-width:0 —— 卡片里的安装命令是 nowrap 的 <code>,
189
+ 不写会把 1fr 列撑破、侧栏被挤出可视区;
190
+ 2) 窄窗单列时用 display:contents 把侧栏拆成两个栅格项(今日推荐 / 其余),
191
+ 靠 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}",
196
+ ".dph_tab:hover{color:var(--dsw-alias-label-primary)}",
197
+ ".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}",
199
+ ".dph_sectionHead{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}",
200
+ ".dph_sectionTitle{margin:0;font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary)}",
201
+ ".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}",
203
+ ".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}",
205
+ /* 今日推荐是侧栏里唯一"当天只有一个答案"的东西,给一条强调边区分于其它信息块 */
206
+ ".dph_railCardAccent{border-left:3px solid var(--dsw-alias-state-business-primary)}",
207
+ ".dph_railLabel{margin:0;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
208
+ ".dph_railName{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary);margin-top:4px;word-break:break-word}",
209
+ ".dph_railMeta{font-size:11px;color:var(--dsw-alias-label-secondary);line-height:1.5;word-break:break-word}",
210
+ ".dph_railDesc{margin:4px 0 0;font-size:11px;line-height:1.55;color:var(--dsw-alias-label-secondary)}",
211
+ ".dph_railWhy{margin:5px 0 0;padding-top:6px;border-top:1px solid var(--dsw-alias-border-l2);font-size:11px;line-height:1.55;color:var(--dsw-alias-label-tertiary)}",
212
+ ".dph_railDivider{border-top:1px solid var(--dsw-alias-border-l2);padding-top:6px;margin-top:3px;font-size:11px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}",
213
+ ".dph_railLink{color:var(--dsw-alias-state-business-primary);text-decoration:none}",
214
+ ".dph_railLink:hover{text-decoration:underline}",
215
+ ".dph_railWarn{color:var(--dsw-alias-state-business-primary)}",
216
+ ".dph_top3{display:flex;align-items:baseline;gap:7px;min-width:0;font-size:11px;color:var(--dsw-alias-label-primary)}",
217
+ ".dph_top3Rank{flex:none;width:10px;color:var(--dsw-alias-state-business-primary);font-weight:600}",
218
+ ".dph_top3Name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
219
+ ".dph_top3Num{flex:none;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}",
220
+ /* 宽屏卡片:左内容 + 右 84px 操作轨道。只由 renderCard 的 wide 分支产出;
221
+ 浮窗 / 今日推荐 / 分类精选仍走原来的 .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}",
224
+ ".dph_opRail{display:flex;flex-direction:column;gap:5px}",
225
+ ".dph_opRail .dph_btn{width:100%;text-align:center;padding:5px 6px}",
226
+ ".dph_btnSm{padding:3px 8px;font-size:11px}",
227
+ /* 命令条:复制按钮内嵌右端,不再靠 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}",
229
+ ".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
+ /* 212px 侧栏里的命令条:横向排会把命令截成「dsh plugin ----」(实测),
231
+ 改竖排 + 允许断词,命令必须完整可读 —— 它是这一块的行动依据。 */
232
+ ".dph_cmdbarCol{flex-direction:column;align-items:stretch;gap:5px}",
233
+ ".dph_cmdbarCol .dph_cmdbarCode{white-space:normal;overflow-wrap:anywhere;word-break:normal;line-height:1.5}",
234
+ /* 侧栏里的安装行同理:包名在窄栏里必须能换行,否则会顶出卡片右边界 */
235
+ ".dph_railCard .dph_instRow{flex-direction:column;align-items:stretch;gap:4px}",
236
+ ".dph_railCard .dph_instHint{word-break:break-all}",
237
+ "@media (max-width:900px){.dph_work{grid-template-columns:minmax(0,1fr)}.dph_rail{display:contents}.dph_workHead,.dph_tabbar{order:0}.dph_dailySlot{order:1}.dph_mainCol{order:2}.dph_railSlot{order:3}.dph_railCard .dph_instRow{flex-direction:row;align-items:center}.dph_cmdbarCol{flex-direction:row;align-items:center}.dph_cmdbarCol .dph_cmdbarCode{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}",
238
+ /* ──────────────── 社群 + 订阅(2026-10-20) ────────────────
239
+ 一条通栏卡,三处共用:会话页签(宽)/ 右下浮窗(compact)/ 设置页(无外框)。
240
+ ⚠️ 二维码 84px 是站点实测的下限(64px 时 jsQR 已解不出,72px 是临界),
241
+ 这里不改小 —— 扫不出来的二维码等于没有入口。
242
+ 二维码**默认收起**:展开后高度约 +120px,页签首屏会被列表挤走,
243
+ 「入口存在但看不见」比没有入口更糟。 */
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}",
245
+ ".dph_joinHead{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}",
246
+ ".dph_joinTitle{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary)}",
247
+ ".dph_joinSub{font-size:11px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}",
248
+ ".dph_joinRow{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
249
+ ".dph_qrRow{display:flex;gap:16px;flex-wrap:wrap;padding:2px 0 1px}",
250
+ ".dph_qrItem{display:flex;flex-direction:column;align-items:center;gap:4px;min-width:0}",
251
+ ".dph_qrImg{display:block;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:#fff;padding:3px}",
252
+ ".dph_qrHint{font-size:10px;color:var(--dsw-alias-label-tertiary);text-align:center}",
253
+ ".dph_qrLink{font-size:11px;color:var(--dsw-alias-state-business-primary);text-decoration:none}",
254
+ ".dph_qrLink:hover{text-decoration:underline}",
255
+ ".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}",
257
+ ".dph_subInput:focus{border-color:var(--dsw-alias-state-business-primary)}",
258
+ ".dph_joinMsg{font-size:11px;line-height:1.5;color:var(--dsw-alias-label-secondary)}",
259
+ ".dph_joinOk{color:var(--dsw-alias-state-business-primary)}",
260
+ ".dph_joinBad{color:var(--dsw-alias-state-error-primary)}",
261
+ ".dph_joinNote{font-size:10px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}",
262
+ /* 浮窗 400px:省掉说明行,二维码与表单各占一行,不再并排 */
263
+ ".dph_joinCompact .dph_joinSub{display:none}",
264
+ /* 设置页里是「卡中卡」:去掉外框,用一条分隔线接在更新日志之后 */
265
+ ".dph_joinInSet{border:0;border-top:1px solid var(--dsw-alias-border-l2);border-radius:0;background:transparent;padding:12px 0 0}",
183
266
  ].join("");
184
267
  const tagId = "dsh-dpharness/client.css";
185
268
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
@@ -195,10 +278,52 @@ window.__ModuleLoader__.load({
195
278
  /* 目录站点;改这里的同时要改 host 侧 lib/index.js 的 SITE / UPSTREAM / TRACK。 */
196
279
  const SITE = "https://dpharness.com";
197
280
  const TAKE_OPTIONS = [30, 60, 100];
281
+ /**
282
+ * 社群入口(2026-10-20)。
283
+ *
284
+ * 真源在站点 `lib/community.ts`(首页右栏 / 文章页 CTA / 全站页脚三处读它)。
285
+ * 插件是**独立 npm 包,不能 import 站点代码**,所以这里保留一份副本:
286
+ * 换群或改链接时两处都要改,否则插件里进的是旧群。
287
+ *
288
+ * 二维码不存图:站点 `app/qr/route.ts` 按 url 现生成 PNG(`/qr?url=…`),
289
+ * 换群链接后二维码自动跟着变,不存在「图没换」这种事故。
290
+ */
291
+ const COMMUNITY_GROUPS = [
292
+ {
293
+ key: "qq",
294
+ labelKey: "join.qq",
295
+ scanKey: "join.scanQq",
296
+ name: "DPharness QQ 群",
297
+ url: "https://qm.qq.com/q/CwSG74aKdi",
298
+ },
299
+ {
300
+ key: "feishu",
301
+ labelKey: "join.feishu",
302
+ scanKey: "join.scanFeishu",
303
+ name: "DPharness 飞书群",
304
+ /* applink 深链:装了飞书直接唤起飞书,没装会跳下载引导页 —— 预期行为 */
305
+ url: "https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=640sc405-cb7b-4ba8-b75d-0d21949251a6",
306
+ },
307
+ ].map((group) => Object.assign({}, group, { qr: SITE + "/qr?url=" + encodeURIComponent(group.url) }));
308
+ const NEWSLETTER_URL = SITE + "/newsletter";
198
309
  const zh = {
199
310
  "view.tab": "严选插件",
200
311
  "view.title": "dsh 严选插件",
201
312
  "view.sub": "只推装得上的 · 数据来源 dpharness.com",
313
+ /* 区标题:与页头口径分开 —— 页头说"这是什么",区标题说"现在看到的是哪一段" */
314
+ "section.browse": "浏览插件",
315
+ "section.best": "分类精选",
316
+ "section.sets": "套装方案",
317
+ "section.daily": "每日推荐",
318
+ "section.updates": "我的插件",
319
+ /* 侧栏:今日推荐 / 各小类冠军 / 安装须知 */
320
+ "rail.highlights": "各小类冠军 · 周下载前 3",
321
+ "rail.highlightsHint": "共 {n} 个小类各取第 1 名 · {m} 期 · 按周下载排序",
322
+ "rail.viewBoard": "查看完整榜单 →",
323
+ "rail.install": "安装须知",
324
+ "rail.installTip": "插件走本地通道安装,重启 dsh 后生效;未重启时页面上方会提示。",
325
+ "rail.restartPending": "有插件装完还没重启,重启 dsh 才会生效。",
326
+ "rail.week": "周下载 {n}",
202
327
  "search.placeholder": "搜索插件名称 / 描述 / 作者…",
203
328
  "sort.default": "综合",
204
329
  "sort.stars": "按 Star",
@@ -430,6 +555,26 @@ window.__ModuleLoader__.load({
430
555
  "need.required": "必备",
431
556
  "need.enhance": "增强",
432
557
  "need.optional": "可选",
558
+ /* 社群 + 订阅(页签 / 浮窗 / 设置页三处共用一套文案) */
559
+ "join.title": "插件交流群已开放",
560
+ "join.sub": "用法、报错、新插件,群里问更快",
561
+ "join.showQr": "查看二维码",
562
+ "join.hideQr": "收起二维码",
563
+ "join.qq": "QQ 群",
564
+ "join.feishu": "飞书群",
565
+ "join.scanQq": "手机 QQ 扫码进群",
566
+ "join.scanFeishu": "飞书扫码进群",
567
+ "join.joinGroup": "加入{label}",
568
+ "join.newsletter": "每周一封插件周报",
569
+ "join.newsletterSub": "新插件、精选评测与福利,周一早上发",
570
+ "join.email": "你的邮箱",
571
+ "join.subscribe": "订阅",
572
+ "join.sending": "发送中…",
573
+ "join.subscribeOk": "确认信已发出,请到邮箱点确认",
574
+ "join.subscribeFailed": "订阅失败,请稍后再试",
575
+ "join.needEmail": "请先填邮箱",
576
+ "join.note": "邮箱只用于周报,可随时退订。",
577
+ "join.past": "往期周报 →",
433
578
  "footer.hint": "网页无法自动安装:复制命令到终端执行,装完重启 dsh 才会生效。命令里的 --profile 已按你本机填好,别改成别的。",
434
579
  "telemetry.on": "匿名统计(不含搜索内容)",
435
580
  "install.action": "安装",
@@ -459,6 +604,18 @@ window.__ModuleLoader__.load({
459
604
  "view.tab": "Curated",
460
605
  "view.title": "dsh curated plugins",
461
606
  "view.sub": "Only installable ones · source dpharness.com",
607
+ "section.browse": "Browse plugins",
608
+ "section.best": "By category",
609
+ "section.sets": "Setups",
610
+ "section.daily": "Daily pick",
611
+ "section.updates": "My plugins",
612
+ "rail.highlights": "Top of each group · weekly downloads",
613
+ "rail.highlightsHint": "{n} groups, 1 each · {m} · ranked by weekly downloads",
614
+ "rail.viewBoard": "See the full board →",
615
+ "rail.install": "Install notes",
616
+ "rail.installTip": "Installs go through the local channel and take effect after restarting dsh.",
617
+ "rail.restartPending": "A plugin is installed but dsh has not been restarted yet.",
618
+ "rail.week": "{n}/wk",
462
619
  "search.placeholder": "Search name / description / owner…",
463
620
  "sort.default": "Relevance",
464
621
  "sort.stars": "By stars",
@@ -685,6 +842,25 @@ window.__ModuleLoader__.load({
685
842
  "need.required": "Core",
686
843
  "need.enhance": "Enhance",
687
844
  "need.optional": "Optional",
845
+ "join.title": "Community group is open",
846
+ "join.sub": "Usage, install errors and new plugins — asking in the group is faster",
847
+ "join.showQr": "Show QR codes",
848
+ "join.hideQr": "Hide QR codes",
849
+ "join.qq": "QQ group",
850
+ "join.feishu": "Feishu group",
851
+ "join.scanQq": "Scan with mobile QQ",
852
+ "join.scanFeishu": "Scan with Feishu",
853
+ "join.joinGroup": "Join {label}",
854
+ "join.newsletter": "Weekly plugin digest",
855
+ "join.newsletterSub": "New plugins, reviews and perks — Monday mornings",
856
+ "join.email": "Your email",
857
+ "join.subscribe": "Subscribe",
858
+ "join.sending": "Sending…",
859
+ "join.subscribeOk": "Confirmation sent — open your inbox and click the link",
860
+ "join.subscribeFailed": "Subscription failed, please try again later",
861
+ "join.needEmail": "Enter your email first",
862
+ "join.note": "Used for the digest only; unsubscribe anytime.",
863
+ "join.past": "Past issues →",
688
864
  "footer.hint": "A web page cannot install plugins: copy the command into a terminal, then restart dsh. The --profile in it is already set to this machine's — leave it as is.",
689
865
  "telemetry.on": "Anonymous stats (no search text)",
690
866
  "install.action": "Install",
@@ -1936,6 +2112,46 @@ window.__ModuleLoader__.load({
1936
2112
  return sorted[hashKey(dateKey) % sorted.length];
1937
2113
  }
1938
2114
 
2115
+ /**
2116
+ * 侧栏「各小类冠军」的三条 —— 口径 A(2026-10-19 定案)。
2117
+ *
2118
+ * ⚠️ 不能直接取 /api/best 的前三条:那个接口的分组顺序是
2119
+ * `subKey asc, rank asc`(app/api/best/route.ts),**没有跨小类排名**。
2120
+ * 实测当期(2026-10)直接取前三条得到的是「市场/管理 › 插件发现」这一个
2121
+ * 小类的第 1、2、3 名 —— 看起来像"榜单坏了",实际是读错了口径。
2122
+ *
2123
+ * 所以:候选集只保留 rank=1(每个小类一条,当期 43 条),按周下载降序,
2124
+ * 并列时用星数、再用 fullName 字典序兜底 —— 最后一级与 pickDaily 同一条纪律:
2125
+ * 上游分组顺序会随站点重算榜单而变,只有唯一键排序才能保证同一天多次刷新一致。
2126
+ *
2127
+ * 全部在客户端完成:不新增请求、不改站点接口。数据未就绪时返回空数组,
2128
+ * 调用方据此整块不渲染(不占位、不显示"暂无")。
2129
+ */
2130
+ function pickHighlights(data, limit) {
2131
+ const all = flattenBest(data).filter((entry) => Number(entry.item.rank) === 1);
2132
+ if (all.length === 0) return [];
2133
+ const num = (value) => (typeof value === "number" && Number.isFinite(value) ? value : -1);
2134
+ const sorted = all.slice().sort((a, b) => {
2135
+ const weekly = num(b.item.weeklyDownloads) - num(a.item.weeklyDownloads);
2136
+ if (weekly !== 0) return weekly;
2137
+ const stars = num(b.item.stars) - num(a.item.stars);
2138
+ if (stars !== 0) return stars;
2139
+ return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
2140
+ });
2141
+ const seen = Object.create(null);
2142
+ const output = [];
2143
+ const max = limit && limit > 0 ? limit : 3;
2144
+ for (let index = 0; index < sorted.length; index += 1) {
2145
+ const entry = sorted[index];
2146
+ /* 同一插件在两个小类都以 rank=1 出现时只留一条(fullName 是唯一键) */
2147
+ if (seen[entry.key]) continue;
2148
+ seen[entry.key] = true;
2149
+ output.push(entry);
2150
+ if (output.length >= max) break;
2151
+ }
2152
+ return output;
2153
+ }
2154
+
1939
2155
  /**
1940
2156
  * 当前自然日键,跨天自动刷新。
1941
2157
  *
@@ -2748,7 +2964,17 @@ window.__ModuleLoader__.load({
2748
2964
  ]);
2749
2965
  }
2750
2966
 
2751
- function renderCard(item, copiedCmd, onCopied, compact, comparable) {
2967
+ /**
2968
+ * 一张插件卡。
2969
+ *
2970
+ * 两种版式,同一份数据:
2971
+ * · 窄卡(默认,浮窗 / 今日推荐 / 分类精选):.dph_card,动作按钮都在标题行;
2972
+ * · 宽卡(wide=true,仅页签「严选推荐」列表):.dph_cardLg = 左内容 + 右 84px
2973
+ * 操作轨道。原来靠 .dph_spacer 把 ★ 与 GitHub 顶到卡片两端,正文只占一半、
2974
+ * 右侧大片空白;挪成轨道后操作按列对齐、可纵向扫读(2026-10-19 A2)。
2975
+ * ⚠️ wide 必须由调用方显式传参,不能靠样式选择器自动套用 —— 本组件有 4 处复用。
2976
+ */
2977
+ function renderCard(item, copiedCmd, onCopied, compact, comparable, wide) {
2752
2978
  const title = item.nameZh || item.name || item.fullName || "";
2753
2979
  const tags = tagsOf(item);
2754
2980
  // 卖点行:站点 tagline 经严格过滤后的结果;没有就不占位(宁可不显示,也不放英文原文或垃圾串)
@@ -2767,6 +2993,74 @@ window.__ModuleLoader__.load({
2767
2993
  h("span", { className: "dph_tag", key: "unzh" }, t("label.untranslated")),
2768
2994
  ])
2769
2995
  : null;
2996
+ /* 已经装过就直说 —— 实测有用户对着一个早就装好的插件反复点「安装」,
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 })))
3000
+ : null;
3001
+ const onCopy = () => copyText(item.cmd, () => {
3002
+ onCopied(item.cmd);
3003
+ // 与站点 InstallBlock 同口径:value 传整条命令
3004
+ track("copy_install", { cmd: item.cmd, pkg: item.pkg || "" });
3005
+ });
3006
+ /* comparable = 这张卡片支持"选择类动作"(对比 + 收藏)。两处都放最左:
3007
+ 多选/收藏的第一列位置固定,扫一眼就知道能选;第二列才是插件名。
3008
+ 宽屏时这两个按钮与 GitHub 一起挪到右侧操作轨道,样式与行为不变。 */
3009
+ const cmpBtn = comparable ? h("button", {
3010
+ className: "dph_btn" + (inCompare(item) ? " dph_btnPrimary" : ""),
3011
+ key: "cmp",
3012
+ type: "button",
3013
+ title: format(t("compare.toggle"), { max: COMPARE_MAX }),
3014
+ onClick: () => {
3015
+ /* 先读旧状态再改 —— toggleCompare 是同步写 hub,改完再判断就反了 */
3016
+ const was = inCompare(item);
3017
+ toggleCompare(item);
3018
+ track("plugin_hub", { action: was ? "compare_off" : "compare_on" });
3019
+ },
3020
+ }, inCompare(item) ? t("compare.picked") : t("compare.pick")) : null;
3021
+ const favBtn = comparable ? h("button", {
3022
+ className: "dph_btn" + (inFav(item) ? " dph_btnPrimary" : ""),
3023
+ key: "fav",
3024
+ type: "button",
3025
+ title: t("fav.toggle"),
3026
+ onClick: () => {
3027
+ const was = inFav(item);
3028
+ toggleFav(item);
3029
+ track("plugin_hub", { action: was ? "fav_off" : "fav_on" });
3030
+ },
3031
+ }, inFav(item) ? t("fav.added") : t("fav.add")) : null;
3032
+ const linkBtn = item.url
3033
+ ? h("a", { className: "dph_btn", key: "link", href: item.url, target: "_blank", rel: "noopener noreferrer" }, "GitHub")
3034
+ : null;
3035
+
3036
+ if (wide) {
3037
+ /* 命令条通栏、复制按钮内嵌右端 —— 短命令不再拉出一条空白 */
3038
+ const bar = item.cmd
3039
+ ? h("div", { className: "dph_cmdbar", key: "cmd" }, [
3040
+ h("code", { className: "dph_cmdbarCode", key: "code" }, item.cmd),
3041
+ h("button", { className: "dph_btn dph_btnSm", key: "copy", type: "button", onClick: onCopy },
3042
+ copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
3043
+ ])
3044
+ : h("div", { className: "dph_cmdMissing", key: "cmd" }, t("cmd.missing"));
3045
+ return h("div", { className: "dph_cardLg", key: item.fullName || title }, [
3046
+ h("div", { className: "dph_cardLgMain", key: "main" }, [
3047
+ h("div", { className: "dph_cardTop", key: "top" }, [
3048
+ h("span", { className: "dph_name", key: "name" }, title),
3049
+ item.owner ? h("span", { className: "dph_owner", key: "owner" }, "@" + item.owner) : null,
3050
+ h("span", { className: "dph_stars", key: "stars" }, format(t("badge.stars"), { n: item.stars })),
3051
+ item.src === "repo" ? h("span", { className: "dph_tag", key: "src" }, t("label.repoSource")) : null,
3052
+ ]),
3053
+ tags.length ? h("div", { className: "dph_tags", key: "tags" }, tags) : null,
3054
+ installedRow,
3055
+ sellRow,
3056
+ descRow,
3057
+ h(InstallRow, { item: item, key: "install" }),
3058
+ bar,
3059
+ ]),
3060
+ h("div", { className: "dph_opRail", key: "ops" }, [cmpBtn, favBtn, linkBtn]),
3061
+ ]);
3062
+ }
3063
+
2770
3064
  const cmdRow = item.cmd
2771
3065
  ? h("div", { className: "dph_cmdWrap", key: "cmd" }, [
2772
3066
  h("div", { className: "dph_cmdRow", key: "row" }, [
@@ -2775,16 +3069,8 @@ window.__ModuleLoader__.load({
2775
3069
  ? h("span", { className: "dph_tag", key: "src" }, t("label.repoSource"))
2776
3070
  : null,
2777
3071
  h("code", { className: "dph_cmd", key: "code" }, item.cmd),
2778
- h("button", {
2779
- className: "dph_btn",
2780
- key: "copy",
2781
- type: "button",
2782
- onClick: () => copyText(item.cmd, () => {
2783
- onCopied(item.cmd);
2784
- // 与站点 InstallBlock 同口径:value 传整条命令
2785
- track("copy_install", { cmd: item.cmd, pkg: item.pkg || "" });
2786
- }),
2787
- }, copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
3072
+ h("button", { className: "dph_btn", key: "copy", type: "button", onClick: onCopy },
3073
+ copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
2788
3074
  ]),
2789
3075
  item.src === "repo" ? h("div", { className: "dph_instHint", key: "hint" }, t("hint.repoSource")) : null,
2790
3076
  ])
@@ -2792,43 +3078,16 @@ window.__ModuleLoader__.load({
2792
3078
 
2793
3079
  return h("div", { className: "dph_card" + (compact ? " dph_cardSm" : ""), key: item.fullName || title }, [
2794
3080
  h("div", { className: "dph_cardTop", key: "top" }, [
2795
- /* comparable = 这张卡片支持"选择类动作"(对比 + 收藏)。两处都放最左:
2796
- 多选/收藏的第一列位置固定,扫一眼就知道能选;第二列才是插件名。 */
2797
- comparable ? h("button", {
2798
- className: "dph_btn" + (inCompare(item) ? " dph_btnPrimary" : ""),
2799
- key: "cmp",
2800
- type: "button",
2801
- title: format(t("compare.toggle"), { max: COMPARE_MAX }),
2802
- onClick: () => {
2803
- /* 先读旧状态再改 —— toggleCompare 是同步写 hub,改完再判断就反了 */
2804
- const was = inCompare(item);
2805
- toggleCompare(item);
2806
- track("plugin_hub", { action: was ? "compare_off" : "compare_on" });
2807
- },
2808
- }, inCompare(item) ? t("compare.picked") : t("compare.pick")) : null,
2809
- comparable ? h("button", {
2810
- className: "dph_btn" + (inFav(item) ? " dph_btnPrimary" : ""),
2811
- key: "fav",
2812
- type: "button",
2813
- title: t("fav.toggle"),
2814
- onClick: () => {
2815
- const was = inFav(item);
2816
- toggleFav(item);
2817
- track("plugin_hub", { action: was ? "fav_off" : "fav_on" });
2818
- },
2819
- }, inFav(item) ? t("fav.added") : t("fav.add")) : null,
3081
+ cmpBtn,
3082
+ favBtn,
2820
3083
  h("span", { className: "dph_name", key: "name" }, title),
2821
3084
  item.owner ? h("span", { className: "dph_owner", key: "owner" }, "@" + item.owner) : null,
2822
3085
  h("span", { className: "dph_spacer", key: "gap" }),
2823
3086
  h("span", { className: "dph_stars", key: "stars" }, format(t("badge.stars"), { n: item.stars })),
2824
- item.url
2825
- ? h("a", { className: "dph_btn", key: "link", href: item.url, target: "_blank", rel: "noopener noreferrer" }, "GitHub")
2826
- : null,
3087
+ linkBtn,
2827
3088
  ]),
2828
3089
  tags.length ? h("div", { className: "dph_tags", key: "tags" }, tags) : null,
2829
- /* 已经装过就直说 —— 实测有用户对着一个早就装好的插件反复点「安装」,
2830
- 然后判定"安装不成功"(他无从知道那东西其实已经在跑了)。 */
2831
- item.installed ? h("div", { className: "dph_tags", key: "installed" }, h("span", { className: "dph_tag dph_tagOk" }, format(t("card.installed"), { v: item.installed }))) : null,
3090
+ installedRow,
2832
3091
  sellRow,
2833
3092
  descRow,
2834
3093
  h(InstallRow, { item: item, key: "install" }),
@@ -3833,6 +4092,9 @@ window.__ModuleLoader__.load({
3833
4092
  switchRow("daily", "settings.daily", "settings.dailyHint", state.daily, (next) => setDaily(next, "settings")),
3834
4093
  switchRow("check", "settings.check", "settings.checkHint", state.autoCheck, (next) => setAutoCheck(next, "settings")),
3835
4094
  switchRow("tel", "settings.telemetry", "settings.about", state.telemetry, setTelemetry),
4095
+ /* 社群 + 订阅:放在开关之后、更新日志之前 —— 它属于「这个插件还能给你什么」,
4096
+ 不是「版本改了什么」。inSet 去掉外框,只留一条分隔线,避免卡中卡。 */
4097
+ h(JoinCard, { key: "join", inSet: true }),
3836
4098
  changelogSection(cl, pending),
3837
4099
  h("div", { className: "dph_setGroup", key: "reset" }, [
3838
4100
  h("div", { className: "dph_setRow", key: "row" }, [
@@ -3862,6 +4124,150 @@ window.__ModuleLoader__.load({
3862
4124
  }, option.label)));
3863
4125
  }
3864
4126
 
4127
+ /**
4128
+ * 社群 + 订阅入口(2026-10-20)。
4129
+ *
4130
+ * 三处共用:会话页签(宽)/ 右下浮窗(compact)/ 设置 → 插件(宽、无外框)。
4131
+ *
4132
+ * 两个必须守住的点:
4133
+ * 1) **订阅必须经本机 host 转发**(`/api/dpharness/subscribe`)。站点
4134
+ * `/api/subscribe` 不带 CORS 头,浏览器跨源直发不成立 —— 与 track()
4135
+ * 下面那条注释是同一个实测结论。邮箱只发给站点、只用于周报,卡内写明。
4136
+ * 2) 二维码默认收起、点开才显示,尺寸不小于 84px(站点实测:64px 时
4137
+ * jsQR 已解不出)。「入口在但看不见」和「码扫不出来」都是把入口做成摆设。
4138
+ */
4139
+ function JoinCard(props) {
4140
+ const compact = !!(props && props.compact);
4141
+ const inSet = !!(props && props.inSet);
4142
+ const [open, setOpen] = react.useState(false);
4143
+ const [email, setEmail] = react.useState("");
4144
+ const [sub, setSub] = react.useState(null);
4145
+ const busy = !!sub && sub.phase === "sending";
4146
+
4147
+ function submit(event) {
4148
+ if (event && event.preventDefault) event.preventDefault();
4149
+ if (busy) return;
4150
+ const value = String(email || "").trim();
4151
+ if (!value) {
4152
+ setSub({ phase: "bad", text: t("join.needEmail") });
4153
+ return;
4154
+ }
4155
+ setSub({ phase: "sending" });
4156
+ track("plugin_hub", { action: "subscribe_submit" });
4157
+ fetch("/api/dpharness/subscribe", {
4158
+ method: "POST",
4159
+ headers: { "content-type": "application/json" },
4160
+ body: JSON.stringify({ email: value, source: "dsh-plugin" }),
4161
+ })
4162
+ .then((response) =>
4163
+ response.json().catch(() => ({})).then((data) => ({ response, data })),
4164
+ )
4165
+ .then((pair) => {
4166
+ const data = pair.data || {};
4167
+ if (!pair.response.ok || data.ok === false) {
4168
+ /* 服务端的 error 是中文人话(邮箱格式 / 频率限制),直接透出 */
4169
+ setSub({ phase: "bad", text: data.error || t("join.subscribeFailed") });
4170
+ return;
4171
+ }
4172
+ setEmail("");
4173
+ setSub({ phase: "ok", text: data.message || t("join.subscribeOk") });
4174
+ track("plugin_hub", { action: "subscribe_ok" });
4175
+ })
4176
+ .catch(() => setSub({ phase: "bad", text: t("join.subscribeFailed") }));
4177
+ }
4178
+
4179
+ const qrRow = open
4180
+ ? h("div", { className: "dph_qrRow", key: "qr" }, COMMUNITY_GROUPS.map((group) =>
4181
+ h("div", { className: "dph_qrItem", key: group.key }, [
4182
+ h("a", {
4183
+ key: "img",
4184
+ href: group.url,
4185
+ target: "_blank",
4186
+ rel: "noopener noreferrer",
4187
+ onClick: () => track("plugin_hub", { action: "community_join", scope: group.key }),
4188
+ }, h("img", {
4189
+ className: "dph_qrImg",
4190
+ src: group.qr,
4191
+ width: 84,
4192
+ height: 84,
4193
+ alt: group.name + " · " + t(group.scanKey),
4194
+ })),
4195
+ h("a", {
4196
+ className: "dph_qrLink",
4197
+ key: "link",
4198
+ href: group.url,
4199
+ target: "_blank",
4200
+ rel: "noopener noreferrer",
4201
+ onClick: () => track("plugin_hub", { action: "community_join", scope: group.key }),
4202
+ }, format(t("join.joinGroup"), { label: t(group.labelKey) })),
4203
+ h("span", { className: "dph_qrHint", key: "hint" }, t(group.scanKey)),
4204
+ ]),
4205
+ ))
4206
+ : null;
4207
+
4208
+ return h("div", {
4209
+ className: "dph_join" + (compact ? " dph_joinCompact" : "") + (inSet ? " dph_joinInSet" : ""),
4210
+ }, [
4211
+ h("div", { className: "dph_joinHead", key: "gh" }, [
4212
+ h("span", { className: "dph_joinTitle", key: "title" }, "💬 " + t("join.title")),
4213
+ h("span", { className: "dph_joinSub", key: "sub" }, t("join.sub")),
4214
+ h("span", { className: "dph_spacer", key: "gap" }),
4215
+ h("button", {
4216
+ className: "dph_btn dph_btnSm",
4217
+ key: "toggle",
4218
+ type: "button",
4219
+ "aria-expanded": open ? "true" : "false",
4220
+ onClick: () => {
4221
+ if (!open) track("plugin_hub", { action: "community_open" });
4222
+ setOpen(!open);
4223
+ },
4224
+ }, open ? t("join.hideQr") : t("join.showQr")),
4225
+ ]),
4226
+ qrRow,
4227
+ h("div", { className: "dph_joinHead", key: "nh" }, [
4228
+ h("span", { className: "dph_joinTitle", key: "title" }, "✉️ " + t("join.newsletter")),
4229
+ h("span", { className: "dph_joinSub", key: "sub" }, t("join.newsletterSub")),
4230
+ ]),
4231
+ h("form", { className: "dph_subForm", key: "form", onSubmit: submit }, [
4232
+ h("input", {
4233
+ className: "dph_subInput",
4234
+ key: "input",
4235
+ type: "email",
4236
+ value: email,
4237
+ placeholder: t("join.email"),
4238
+ autoComplete: "email",
4239
+ onChange: (event) => setEmail(event.target.value),
4240
+ }),
4241
+ h("button", {
4242
+ className: "dph_btn dph_btnPrimary",
4243
+ key: "go",
4244
+ type: "submit",
4245
+ disabled: busy,
4246
+ }, busy ? t("join.sending") : t("join.subscribe")),
4247
+ ]),
4248
+ sub
4249
+ ? h("div", {
4250
+ className:
4251
+ "dph_joinMsg" +
4252
+ (sub.phase === "ok" ? " dph_joinOk" : sub.phase === "bad" ? " dph_joinBad" : ""),
4253
+ key: "msg",
4254
+ role: "status",
4255
+ }, sub.text)
4256
+ : null,
4257
+ h("div", { className: "dph_joinNote", key: "note" }, [
4258
+ t("join.note") + " ",
4259
+ h("a", {
4260
+ className: "dph_qrLink",
4261
+ key: "past",
4262
+ href: NEWSLETTER_URL,
4263
+ target: "_blank",
4264
+ rel: "noopener noreferrer",
4265
+ onClick: () => track("plugin_hub", { action: "site_click", scope: "newsletter" }),
4266
+ }, t("join.past")),
4267
+ ]),
4268
+ ]);
4269
+ }
4270
+
3865
4271
  function controls(cat) {
3866
4272
  return h("div", { className: "dph_bar", key: "bar" }, [
3867
4273
  h("input", {
@@ -3922,6 +4328,70 @@ window.__ModuleLoader__.load({
3922
4328
  * `.dph_segWrap`(那是让两个按钮铺满 400px 面板用的)。页签宽 1080px,
3923
4329
  * 铺满会变成两个 500px 的巨大按钮。
3924
4330
  */
4331
+ /**
4332
+ * 侧栏版「今日推荐」——212px 宽。
4333
+ *
4334
+ * 与 dailyCard 同源(都走 pickDaily),只换版式:面板与「每日推荐」视图
4335
+ * 继续用带卡片壳的 dailyCard,这里去掉那层壳、把理由与刷新说明收进卡内,
4336
+ * 避免选取逻辑出现第二份实现。取数失败时同样要说清"暂不可用",
4337
+ * 不能静止消失 —— 它是侧栏里唯一"今天该装哪个"的答案。
4338
+ */
4339
+ function railDailyCard(best, copiedCmd, onCopied, dateKey) {
4340
+ const picked = best.state.data ? pickDaily(best.state.data, dateKey) : null;
4341
+ if (!picked) {
4342
+ return h("div", { className: "dph_railCard dph_railCardAccent", key: "daily" }, [
4343
+ h("div", { className: "dph_bar", key: "head" }, [
4344
+ h("span", { className: "dph_dailyTag", key: "tag" }, t("daily.title")),
4345
+ h("span", { className: "dph_dailyDate", key: "date" }, dateKey),
4346
+ ]),
4347
+ h("div", { className: "dph_instMsg", key: "msg" }, best.state.error ? t("daily.empty") : t("daily.loading")),
4348
+ ]);
4349
+ }
4350
+ const item = picked.item;
4351
+ const title = item.nameZh || item.name || item.fullName || "";
4352
+ const where = [picked.cat, picked.sub].filter(Boolean).join(" › ");
4353
+ const meta = [format(t("badge.stars"), { n: item.stars }), where].filter(Boolean).join(" · ");
4354
+ const desc = item.descZh || item.sell || "";
4355
+ const verify = item.verify ? tagLabel("verify", item.verify) : "";
4356
+ return h("div", { className: "dph_railCard dph_railCardAccent", key: "daily" }, [
4357
+ h("div", { className: "dph_bar", key: "head" }, [
4358
+ h("span", { className: "dph_dailyTag", key: "tag" }, t("daily.title")),
4359
+ h("span", { className: "dph_dailyDate", key: "date" }, dateKey),
4360
+ ]),
4361
+ h("div", { className: "dph_railName", key: "name" }, title),
4362
+ h("div", { className: "dph_railMeta", key: "meta" }, meta),
4363
+ verify ? h("div", { className: "dph_tags", key: "verify" }, h("span", { className: "dph_tag" + (item.verify === "pass" ? " dph_tagOk" : " dph_tagBad") }, verify)) : null,
4364
+ desc ? h("p", { className: "dph_railDesc", key: "desc" }, desc) : null,
4365
+ h(InstallRow, { item: item, key: "install" }),
4366
+ item.cmd
4367
+ ? h("div", { className: "dph_cmdbar dph_cmdbarCol", key: "cmd" }, [
4368
+ h("code", { className: "dph_cmdbarCode", key: "code", title: item.cmd }, item.cmd),
4369
+ h("button", {
4370
+ className: "dph_btn dph_btnSm",
4371
+ key: "copy",
4372
+ type: "button",
4373
+ onClick: () => copyText(item.cmd, () => {
4374
+ onCopied(item.cmd);
4375
+ track("copy_install", { cmd: item.cmd, pkg: item.pkg || "" });
4376
+ }),
4377
+ }, copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
4378
+ ])
4379
+ : null,
4380
+ item.reason ? h("p", { className: "dph_railWhy", key: "why" }, t("daily.why") + ":" + item.reason) : null,
4381
+ ]);
4382
+ }
4383
+
4384
+ /**
4385
+ * 入口 1:会话视图页签(完整页)。
4386
+ *
4387
+ * 2026-10-19 版式(A2):页头 + 页签 / 左主列 / 右 212px 侧栏。
4388
+ * 原来是一条 12px 等距的纵向流,今日推荐与列表卡同规格、理由行还漂在卡外,
4389
+ * 用户的原话是「模块分布不清晰、右侧空白太多」。
4390
+ * 现在:主列只做检索与列表(区标题 → 筛选 → 结果),侧栏放"今天装哪个"
4391
+ * 与"各小类冠军",横向空白由决策信息吸收。
4392
+ * 视图切换从分段按钮改成下划线页签:它管的是整页内容,不该长得像一个
4393
+ * 与正文平级的控件(浮窗仍用 .dph_seg,两处互不影响)。
4394
+ */
3925
4395
  function CatalogView() {
3926
4396
  const cat = useCatalog(t);
3927
4397
  /* 必须订阅共享 store:页签底部的「显示右下角浮窗」开关读的是同一个
@@ -3933,8 +4403,9 @@ window.__ModuleLoader__.load({
3933
4403
  /* 对比表开没开 ── 每个面各自记(选择集在 hub 上共享,表格的展开状态是本面的) */
3934
4404
  const [comparing, setComparing] = react.useState(false);
3935
4405
  const dateKey = useDateKey();
3936
- /* 默认视图顶部也要放「今日推荐」卡片,所以 daily 开着时必须取榜单数据 ——
3937
- 不取就没东西可渲染。关掉每日推荐后即回到「只有切到榜单/每日视图才请求」。 */
4406
+ /* 侧栏也要放「今日推荐」与「各小类冠军」,两处都来自 /api/best:
4407
+ daily 开着时必须取,关掉后即回到「只有切到榜单/每日视图才请求」。
4408
+ 不给侧栏新增任何请求 —— 全站只有这一个数据源。 */
3938
4409
  const best = useBest(t, mode === "best" || mode === "daily" || state.daily);
3939
4410
  const sets = useSets(t, mode === "sets");
3940
4411
  const data = cat.state.data;
@@ -3944,15 +4415,38 @@ window.__ModuleLoader__.load({
3944
4415
  const isDaily = mode === "daily";
3945
4416
  const isUpdate = mode === "update";
3946
4417
  const isSets = mode === "sets";
3947
- const sub = isSets
3948
- ? (setsData ? format(t("sets.count"), { n: setsData.total || 0 }) : "")
3949
- : isBest
3950
- ? (bestData ? format(t("best.month"), { m: bestData.month || "" }) : "")
3951
- : isDaily
3952
- ? t("daily.hint")
3953
- : isUpdate
3954
- ? ""
3955
- : countSub(data, t, cat.state.loading, t("view.sub"));
4418
+
4419
+ /* 页头副标题与区标题分工:页头说「这是什么」(固定口径),
4420
+ 区标题说「现在看到的是哪一段 + 多少条」。
4421
+ 两处都写"共 N 条"会让页面重复又啰嗦(原版就是这个毛病)。 */
4422
+ const headSub = isSets || isBest || isDaily || isUpdate ? "" : t("view.sub");
4423
+ const sectionTitle = isUpdate
4424
+ ? t("section.updates")
4425
+ : isSets
4426
+ ? t("section.sets")
4427
+ : isBest
4428
+ ? t("section.best")
4429
+ : isDaily
4430
+ ? t("section.daily")
4431
+ : t("section.browse");
4432
+ const sectionCount = isUpdate
4433
+ ? ""
4434
+ : isSets
4435
+ ? (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, "");
4441
+
4442
+ const TABS = [
4443
+ { value: "search", label: t("best.recommend") },
4444
+ { value: "best", label: t("best.picks") },
4445
+ { value: "sets", label: t("sets.tab") },
4446
+ { value: "daily", label: t("daily.tab") },
4447
+ { value: "update", label: t("updates.tab") },
4448
+ ];
4449
+
3956
4450
  /* 各分支各自成段。写成嵌套三元再 spread 已经难以核对,分支越多越该先算好 body。 */
3957
4451
  const body = isUpdate
3958
4452
  ? [h(UpdateView, { key: "update", scope: "tab" })]
@@ -3975,19 +4469,58 @@ window.__ModuleLoader__.load({
3975
4469
  h("div", { className: "dph_list", key: "blist" }, renderBest(bestData, best.copiedCmd, best.markCopied)),
3976
4470
  ]
3977
4471
  : [
3978
- state.daily ? dailyCard(best, cat.copiedCmd, cat.markCopied, { dateKey: dateKey }) : null,
3979
4472
  controls(cat),
3980
4473
  cat.state.error ? h(Notice, { key: "error", kind: "bad", text: t("state.failed") + ":" + cat.state.error }) : null,
3981
4474
  cat.state.loading && cat.plugins.length === 0 ? h(Notice, { key: "loading", text: t("state.loading") }) : null,
3982
4475
  !cat.state.loading && !cat.state.error && cat.plugins.length === 0 ? h(Notice, { key: "empty", text: t("state.empty") }) : null,
3983
4476
  h(CompareBar, { key: "cmpBar", open: comparing, onToggle: () => setComparing((value) => !value) }),
3984
4477
  comparing ? h(CompareTable, { key: "cmp", copiedCmd: cat.copiedCmd, markCopied: cat.markCopied }) : null,
3985
- h("div", { className: "dph_list", key: "list" }, cat.plugins.map((item) => renderCard(item, cat.copiedCmd, cat.markCopied, false, true))),
4478
+ h("div", { className: "dph_list", key: "list" }, cat.plugins.map((item) => renderCard(item, cat.copiedCmd, cat.markCopied, false, true, true))),
3986
4479
  ];
3987
- return h("div", { className: "dph_root" }, [
3988
- h("div", { className: "dph_header", key: "header" }, [
4480
+
4481
+ /* ── 侧栏:今日推荐(「每日推荐」视图里正文已经是这条,不重复)+ 各小类冠军 + 安装须知 ── */
4482
+ const showRailDaily = state.daily && !isDaily;
4483
+ const highlights = bestData ? pickHighlights(bestData, 3) : [];
4484
+ const subCount = bestData && Array.isArray(bestData.categories)
4485
+ ? bestData.categories.reduce((total, entry) => total + (Array.isArray(entry.subs) ? entry.subs.length : 0), 0)
4486
+ : 0;
4487
+ const highlightCard = highlights.length
4488
+ ? h("div", { className: "dph_railCard", key: "top3" }, [
4489
+ h("p", { className: "dph_railLabel", key: "label" }, t("rail.highlights")),
4490
+ ...highlights.map((entry, index) => {
4491
+ const name = entry.item.nameZh || entry.item.name || entry.item.fullName || "";
4492
+ const weekly = Number(entry.item.weeklyDownloads);
4493
+ return h("div", { className: "dph_top3", key: entry.key }, [
4494
+ h("span", { className: "dph_top3Rank", key: "rank" }, String(index + 1)),
4495
+ h("span", { className: "dph_top3Name", key: "name", title: name }, name),
4496
+ h("span", { className: "dph_top3Num", key: "num", title: format(t("rail.week"), { n: Number.isFinite(weekly) ? weekly.toLocaleString() : "—" }) },
4497
+ Number.isFinite(weekly) && weekly > 0 ? weekly.toLocaleString() : "—"),
4498
+ ]);
4499
+ }),
4500
+ h("div", { className: "dph_railDivider", key: "foot" }, [
4501
+ format(t("rail.highlightsHint"), { n: String(subCount), m: String(bestData.month || "") }),
4502
+ h("br", { key: "br" }),
4503
+ h("a", {
4504
+ className: "dph_railLink",
4505
+ key: "more",
4506
+ href: SITE + "/best",
4507
+ target: "_blank",
4508
+ rel: "noopener noreferrer",
4509
+ onClick: () => track("plugin_hub", { action: "site_click", scope: "rail_board" }),
4510
+ }, t("rail.viewBoard")),
4511
+ ]),
4512
+ ])
4513
+ : null;
4514
+ const installCard = h("div", { className: "dph_railCard", key: "install" }, [
4515
+ h("p", { className: "dph_railLabel", key: "label" }, t("rail.install")),
4516
+ h("p", { className: "dph_railDesc", key: "body" }, t("rail.installTip")),
4517
+ state.restartPending ? h("p", { className: "dph_railDesc dph_railWarn", key: "pending" }, t("rail.restartPending")) : null,
4518
+ ]);
4519
+
4520
+ return h("div", { className: "dph_work" }, [
4521
+ h("div", { className: "dph_workHead", key: "header" }, [
3989
4522
  h("h2", { className: "dph_title", key: "title" }, t("view.title")),
3990
- h("span", { className: "dph_sub", key: "sub" }, sub),
4523
+ headSub ? h("span", { className: "dph_sub", key: "sub" }, headSub) : null,
3991
4524
  h("span", { className: "dph_spacer", key: "gap" }),
3992
4525
  h("a", {
3993
4526
  className: "dph_btn",
@@ -3999,20 +4532,36 @@ window.__ModuleLoader__.load({
3999
4532
  }, t("action.openSite")),
4000
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")),
4001
4534
  ]),
4002
- /* 单元素不要写成数组:[seg(...)] 这种"数组里塞一个无 key 元素"会触发
4003
- React 的 key 警告(实测)。直接作为唯一子节点传入即可。 */
4004
- h("div", { className: "dph_bar", key: "seg" }, seg([
4005
- { value: "search", label: t("best.recommend") },
4006
- { value: "best", label: t("best.picks") },
4007
- { value: "sets", label: t("sets.tab") },
4008
- { value: "daily", label: t("daily.tab") },
4009
- { value: "update", label: t("updates.tab") },
4010
- ], mode, setMode)),
4011
- /* 待重启横幅挂在视图切换之下、结果区之上:不跟着卡片滚走,切视图也在 */
4012
- h(RestartBanner, { scope: "tab", key: "rbanner" }),
4013
- ...body,
4014
- h("div", { className: "dph_footer", key: "hint" }, t("footer.hint")),
4015
- h("div", { className: "dph_footer", key: "tel" }, h("div", { className: "dph_footToggles" }, [telemetryToggle(), floatToggle()])),
4535
+ /* 页签是页级导航:用下划线而不是分段按钮 —— 原来那枚 seg 与正文控件同规格,
4536
+ 读不出"它管着下面全部内容"(用户反馈"模块分布不清晰"的一部分)。 */
4537
+ h("div", { className: "dph_tabbar", key: "tabs" }, TABS.map((entry) =>
4538
+ h("button", {
4539
+ className: "dph_tab" + (mode === entry.value ? " dph_tabOn" : ""),
4540
+ key: entry.value,
4541
+ type: "button",
4542
+ "aria-current": mode === entry.value ? "page" : undefined,
4543
+ onClick: () => setMode(entry.value),
4544
+ }, entry.label))),
4545
+ h("div", { className: "dph_mainCol", key: "main" }, [
4546
+ h("div", { className: "dph_sectionHead", key: "sec" }, [
4547
+ h("h3", { className: "dph_sectionTitle", key: "t" }, sectionTitle),
4548
+ sectionCount ? h("span", { className: "dph_sectionCount", key: "c" }, sectionCount) : null,
4549
+ ]),
4550
+ /* 待重启横幅挂在区标题之下、结果区之上:不跟着卡片滚走,切视图也在 */
4551
+ h(RestartBanner, { scope: "tab", key: "rbanner" }),
4552
+ /* 社群 + 订阅:与待重启横幅同一层(常驻、不随列表滚走)。展开二维码后
4553
+ 会把列表往下推约 120px —— 可接受,因为它是点击后的主动结果。 */
4554
+ h(JoinCard, { key: "join" }),
4555
+ ...body,
4556
+ h("div", { className: "dph_footer", key: "hint" }, t("footer.hint")),
4557
+ h("div", { className: "dph_footer", key: "tel" }, h("div", { className: "dph_footToggles" }, [telemetryToggle(), floatToggle()])),
4558
+ ]),
4559
+ h("div", { className: "dph_rail", key: "rail" }, [
4560
+ showRailDaily
4561
+ ? h("div", { className: "dph_dailySlot", key: "dslot" }, railDailyCard(best, cat.copiedCmd, cat.markCopied, dateKey))
4562
+ : null,
4563
+ h("div", { className: "dph_railSlot", key: "rslot" }, [highlightCard, installCard].filter(Boolean)),
4564
+ ]),
4016
4565
  ]);
4017
4566
  }
4018
4567
 
@@ -4273,6 +4822,9 @@ window.__ModuleLoader__.load({
4273
4822
  h("div", { className: "dph_panelBody", key: "bbody" }, renderBest(bestData, best.copiedCmd, best.markCopied)),
4274
4823
  ]),
4275
4824
  h("div", { className: "dph_panelFoot", key: "foot" }, [
4825
+ /* 浮窗里也放一份:浮窗是曝光最高的入口,只有页签有等于大半用户看不到。
4826
+ compact 版省掉说明行,二维码默认收起(面板只有 400px 宽)。 */
4827
+ h(JoinCard, { key: "join", compact: true }),
4276
4828
  h("div", { className: "dph_footRow", key: "row" }, [
4277
4829
  telemetryToggle(),
4278
4830
  h("button", {
@@ -4373,6 +4925,8 @@ window.__ModuleLoader__.load({
4373
4925
  exports.hashKey = hashKey;
4374
4926
  exports.flattenBest = flattenBest;
4375
4927
  exports.pickDaily = pickDaily;
4928
+ /* 侧栏「各小类冠军」的口径是纯函数,单独导出便于断言排序与去重边界 */
4929
+ exports.pickHighlights = pickHighlights;
4376
4930
  /* 供测试使用:本机路由的响应解析要能容忍非 JSON 正文(host 未重启的窗口期) */
4377
4931
  exports.readHostJson = readHostJson;
4378
4932
  /* 供测试使用:升级目标要还原成裸包名才能查 profile 清单 */