dsh-modpack-kit 0.2.3 → 0.3.0

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/client.js CHANGED
@@ -1,3 +1,15 @@
1
+ /**
2
+ * @file client.js
3
+ * @role 客户端半边:左侧栏「整合包」的全部界面(单文件 React),页签 打包 / 安装导入 / 社区资源 / 插件管理 / 设置与记录,外加进度悬浮窗与插件树浮层
4
+ * @sub 界面、页签、插件管理面板、附属小插件清单、插件树浮层(分层 / 折叠 / 固定前后相关 / 只看有问题)、进度窗(只显示)、配色与界面风格(--mp-* 变量)
5
+ * @exports apply / Page / Home / MarketPanel / PluginBrowser / ModpackBrowser / PluginManagerPanel / SubpluginList / PluginTreeOverlay
6
+ * @reads 只读 /dsh-modpack-kit/api/* 的返回;不碰文件、不发第三方请求(市场 AI 搜索除外,转发给插件市场)
7
+ * @writes 不直接写任何东西:所有写操作都是 POST 给 host
8
+ * @risk 整文件在一个大 IIFE 里,组件间靠闭包顺序取值——把某个 const 挪到 useState 之后就会 TDZ 白屏(历史踩过两次);--check 抓不到这类错,只能靠 test/run.mjs 的假 React 渲染
9
+ * @touch 改界面文案要同步 docs/MARKET.txt 之外的 README/DETAIL;加组件要在文件末尾加 exports 并补 test/run.mjs 用例;动进度窗时注意「判定与清空」逻辑不要跟着改;动插件树时三处一起看:treeLayout(列)、treeFolds(折叠与共享计数)、treeRelated(固定后的前后相关),任何一处改了都要跑 test/run.mjs 里那条「插件树:分层看前后」
10
+ * @since 0.3.0
11
+ */
12
+
1
13
  /**
2
14
  * dsh-modpack-kit —— 客户端半边:左侧栏「整合包」。
3
15
  *
@@ -20,21 +32,191 @@ window.__ModuleLoader__.load({
20
32
  const { createElement: h, useCallback, useEffect, useMemo, useRef, useState } = React
21
33
 
22
34
  const API = "/dsh-modpack-kit/api"
35
+ // 配色改完立刻生效:设置页把新的一套(theme + uiStyle)推进来,Page 订阅后重挂 :root 变量,
36
+ // 不必等下一次 /status,也不用刷新页面。value 为 null 时一切照旧取 status 里的那份。
37
+ const liveTheme = { value: null, listeners: new Set() }
38
+ // 换色不经过任何一次渲染:直接把变量写到 <style> 与 <html> 上。
39
+ // 这样不管当前是哪块面板、哪个页面实例在显示,点完立刻变。
40
+ const THEME_STYLE_ID = "dsh-modpack-theme"
41
+ const clearThemeVars = () => {
42
+ if (typeof document === "undefined") return
43
+ const node = document.getElementById(THEME_STYLE_ID)
44
+ if (node && node.parentNode) node.parentNode.removeChild(node)
45
+ const rootStyle = document.documentElement && document.documentElement.style
46
+ if (!rootStyle) return
47
+ for (const name of Array.from(rootStyle)) {
48
+ if (name.indexOf("--mp-") === 0) rootStyle.removeProperty(name)
49
+ }
50
+ }
51
+ // 原生模式:把我们自己的令牌逐个指到宿主变量(名字取自 app.asar 里真实存在的那些)
52
+ const HOST_VARS = {
53
+ "--mp-primary": "var(--dsw-alias-brand-primary)",
54
+ "--mp-primary-strong": "var(--dsw-alias-brand-primary)",
55
+ "--mp-primary-soft": "var(--dsw-alias-bg-layer-2)",
56
+ "--mp-on-primary": "var(--dsw-alias-label-primary-inverted, #ffffff)",
57
+ "--mp-accent": "var(--dsw-alias-brand-primary)",
58
+ "--mp-accent-strong": "var(--dsw-alias-brand-primary)",
59
+ "--mp-accent-soft": "var(--dsw-alias-bg-layer-2)",
60
+ "--mp-on-accent": "var(--dsw-alias-label-primary-inverted, #ffffff)",
61
+ "--mp-on-soft": "var(--dsw-alias-label-primary)",
62
+ "--mp-line": "var(--dsw-alias-border-l2)",
63
+ "--mp-line-strong": "var(--dsw-alias-border-l3)",
64
+ "--mp-hover": "var(--dsw-alias-interactive-bg-hover)",
65
+ "--mp-text": "var(--dsw-alias-label-primary)",
66
+ "--mp-muted": "var(--dsw-alias-label-tertiary)",
67
+ "--mp-card": "var(--dsw-alias-card-fill)",
68
+ "--mp-card-soft": "var(--dsw-alias-bg-layer-1)",
69
+ "--mp-page": "var(--dsw-alias-bg-base)",
70
+ "--mp-page-grad": "none",
71
+ "--mp-header": "var(--dsw-alias-bg-layer-1)",
72
+ "--mp-header-soft": "var(--dsw-alias-bg-layer-2)",
73
+ "--mp-shadow": "none",
74
+ "--mp-shadow-strong": "none",
75
+ "--mp-radius": "8px",
76
+ "--mp-focus": "0 0 0 2px var(--dsw-alias-brand-primary)",
77
+ }
78
+ const hostVarsFor = (theme) => (theme && theme.id === "native" ? HOST_VARS : null)
79
+ // 经典(改版前):不是「换个颜色」,而是把美化整套撤掉——卡片底透明、方角、无阴影、标题带消失,
80
+ // 按钮退回宿主那种描边样式。这些值依然以 --mp-* 的形式注入,代码里所有 var(--mp-*) 才会一致地变朴素。
81
+ const CLASSIC_VARS = {
82
+ "--mp-card": "transparent",
83
+ "--mp-card-soft": "transparent",
84
+ "--mp-hover": "transparent",
85
+ "--mp-shadow": "none",
86
+ "--mp-shadow-strong": "none",
87
+ "--mp-radius": "0px",
88
+ "--mp-page": "transparent",
89
+ "--mp-page-grad": "none",
90
+ "--mp-header": "transparent",
91
+ "--mp-header-soft": "transparent",
92
+ "--mp-primary": "var(--dsw-alias-bg-layer-2)",
93
+ "--mp-primary-strong": "var(--dsw-alias-label-primary)",
94
+ "--mp-primary-soft": "transparent",
95
+ "--mp-on-primary": "var(--dsw-alias-label-primary)",
96
+ "--mp-accent": "var(--dsw-alias-label-secondary)",
97
+ "--mp-accent-soft": "transparent",
98
+ "--mp-accent-strong": "var(--dsw-alias-label-secondary)",
99
+ "--mp-on-accent": "var(--dsw-alias-label-primary)",
100
+ "--mp-line": "var(--dsw-alias-border-l2)",
101
+ "--mp-line-strong": "var(--dsw-alias-border-l2)",
102
+ "--mp-text": "var(--dsw-alias-label-primary)",
103
+ "--mp-muted": "var(--dsw-alias-label-tertiary)",
104
+ "--mp-on-soft": "var(--dsw-alias-label-primary)",
105
+ }
106
+ // 预览器要用同一张表,别各写一份(主题令牌唯一来源)
107
+ const applyThemeVars = (vars) => {
108
+ if (typeof document === "undefined") return
109
+ const entries = vars && typeof vars === "object" ? Object.entries(vars) : []
110
+ if (!entries.length) { clearThemeVars(); return }
111
+ let node = document.getElementById(THEME_STYLE_ID)
112
+ if (!node) {
113
+ node = document.createElement("style")
114
+ node.id = THEME_STYLE_ID
115
+ ;(document.head || document.documentElement).appendChild(node)
116
+ }
117
+ node.textContent = ":root{" + entries.map(([key, value]) => key + ":" + value).join(";") + "}"
118
+ // 再写一份到 <html> 的行内样式:万一有界面处在 shadow root 里,行内继承也能拿到
119
+ const rootStyle = document.documentElement && document.documentElement.style
120
+ if (rootStyle) for (const [key, value] of entries) rootStyle.setProperty(key, value)
121
+ }
122
+ // 客户端自己算一份主题:正常的宿主会在 /settings 回包里带 theme,
123
+ // 但老版本宿主不带——这时按同一套规则本地算,保证「点一下就变」不依赖宿主版本。
124
+ const THEME_FALLBACK = { mist: ["#1B7BE8", "#16C2C8"], forest: ["#2E7D6B", "#E0A33E"], dusk: ["#6A5AE0", "#F2A0A8"] } // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
125
+ const hexOk = (value) => /^#[0-9a-fA-F]{6}$/u.test(String(value || ""))
126
+ const shade = (hex, target, weight) => {
127
+ const num = Number.parseInt(String(hex).slice(1), 16)
128
+ const to = target === "white" ? 255 : 0
129
+ const channel = (part) => Math.round(part + (to - part) * weight)
130
+ return "#" + [channel((num >> 16) & 255), channel((num >> 8) & 255), channel(num & 255)].map((v) => v.toString(16).padStart(2, "0")).join("")
131
+ }
132
+ const alphaOf = (hex, alpha) => {
133
+ const num = Number.parseInt(String(hex).slice(1), 16)
134
+ return "rgba(" + ((num >> 16) & 255) + "," + ((num >> 8) & 255) + "," + (num & 255) + "," + alpha + ")"
135
+ }
136
+ // 与 lib/theme.mjs 的 readableOn 同一套算法:底色亮就用黑字,暗就用白字。
137
+ // 之前一律写死 #ffffff,遇到琥珀 / 樱粉 / 青这类浅色底就白字看不见。
138
+ const readableOn = (hex) => {
139
+ if (!hexOk(hex)) return "#ffffff" // lint-allow-color:前景色只有黑 / 白两种,不参与主题变量
140
+ const channel = (offset) => {
141
+ const value = Number.parseInt(String(hex).slice(offset, offset + 2), 16) / 255
142
+ return value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4)
143
+ }
144
+ const luminance = 0.2126 * channel(1) + 0.7152 * channel(3) + 0.0722 * channel(5)
145
+ // 0.35 是折中阈值,与 lib/theme.mjs 保持一致:深色底白字、浅色底黑字。
146
+ return luminance > 0.35 ? "#1b1d21" : "#ffffff" // lint-allow-color:同上,按底色亮度二选一
147
+ }
148
+ const localThemeVars = (primary, accent) => {
149
+ if (!hexOk(primary)) return {}
150
+ const page = shade(primary, "white", 0.94)
151
+ return {
152
+ "--mp-primary": primary,
153
+ "--mp-primary-strong": shade(primary, "black", 0.18),
154
+ "--mp-primary-soft": shade(primary, "white", 0.88),
155
+ "--mp-on-primary": readableOn(primary),
156
+ "--mp-accent": hexOk(accent) ? accent : primary,
157
+ "--mp-accent-strong": shade(hexOk(accent) ? accent : primary, "black", 0.62),
158
+ "--mp-accent-soft": shade(hexOk(accent) ? accent : primary, "white", 0.86),
159
+ "--mp-on-accent": readableOn(hexOk(accent) ? accent : primary),
160
+ "--mp-on-soft": shade(primary, "black", 0.74),
161
+ "--mp-line": shade(primary, "white", 0.8),
162
+ "--mp-line-strong": shade(primary, "white", 0.62),
163
+ "--mp-hover": shade(primary, "white", 0.92),
164
+ "--mp-text": "#2a2e35",
165
+ "--mp-muted": "#77839a",
166
+ "--mp-card": "#ffffff",
167
+ "--mp-card-soft": shade(primary, "white", 0.97),
168
+ "--mp-page": page,
169
+ "--mp-page-grad": "linear-gradient(180deg," + page + " 0%,#ffffff 78%)",
170
+ "--mp-header": primary,
171
+ "--mp-header-soft": shade(primary, "white", 0.88),
172
+ "--mp-shadow": "0 2px 12px " + alphaOf(primary, 0.1),
173
+ "--mp-shadow-strong": "0 6px 22px " + alphaOf(primary, 0.16),
174
+ "--mp-radius": "10px",
175
+ "--mp-focus": "0 0 0 2px " + alphaOf(primary, 0.25),
176
+ }
177
+ }
178
+ const localTheme = (cfg) => {
179
+ const wanted = String((cfg && cfg.themeId) || "mist")
180
+ if (wanted === "custom") {
181
+ const primary = hexOk(cfg && cfg.themePrimary) ? cfg.themePrimary : "#1B7BE8" // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
182
+ const accent = hexOk(cfg && cfg.themeAccent) ? cfg.themeAccent : "#16C2C8" // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
183
+ return { id: "custom", label: "自定义", primary, accent, vars: localThemeVars(primary, accent) }
184
+ }
185
+ const pair = THEME_FALLBACK[wanted]
186
+ if (!pair) return { id: "native", label: "跟 DSH 原生(黑 / 白)", primary: "", accent: "", vars: {} }
187
+ return { id: wanted, label: wanted, primary: pair[0], accent: pair[1], vars: localThemeVars(pair[0], pair[1]) }
188
+ }
189
+ const setLiveTheme = (next) => {
190
+ if (!next || !next.theme) return
191
+ liveTheme.value = { theme: next.theme, uiStyle: next.uiStyle === "classic" ? "classic" : "new" }
192
+ const classic = liveTheme.value.uiStyle === "classic"
193
+ applyThemeVars(classic ? null : (Object.keys(next.theme.vars || {}).length ? next.theme.vars : hostVarsFor(next.theme)))
194
+ for (const fn of liveTheme.listeners) fn(liveTheme.value)
195
+ }
23
196
 
24
- const box = { border: "0.5px solid var(--dsw-alias-border-l2)", borderRadius: "8px", padding: "12px 14px" }
25
- const hint = { color: "var(--dsw-alias-label-tertiary)", fontSize: "11.5px", lineHeight: "17px" }
26
- const label = { fontSize: "13px", lineHeight: "19px" }
27
- const strong = { fontSize: "13px", fontWeight: 600, lineHeight: "20px" }
28
- const btn = { height: "28px", padding: "0 12px", fontSize: "12.5px", borderRadius: "6px", cursor: "pointer", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-primary)" }
29
- const btnPrimary = { ...btn, background: "var(--dsw-alias-fill-primary, #3b6cf6)", borderColor: "transparent", color: "#fff" }
30
- const input = { height: "26px", padding: "0 8px", fontSize: "12.5px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-primary)", boxSizing: "border-box" }
31
- const mono = { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", fontSize: "11.5px", lineHeight: "17px" }
197
+ const box = {
198
+ border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
199
+ borderRadius: "var(--mp-radius, 8px)",
200
+ padding: "12px 14px",
201
+ background: "var(--mp-card, var(--dsw-alias-card-fill, transparent))",
202
+ boxShadow: "var(--mp-shadow, none)",
203
+ }
204
+ const hint = { color: "var(--mp-muted, var(--dsw-alias-label-tertiary))", fontSize: "11.5px", lineHeight: "17px" }
205
+ const cardSurface = "var(--mp-card, var(--dsw-alias-card-fill, var(--dsw-alias-bg-layer-1, transparent)))"
206
+ // 卡片底色由 --mp-card 决定(主题下调成白/浅色),文字必须跟着走 --mp-text;
207
+ // 不指定的话会继承宿主 label-primary——暗色宿主里就是白字,落在白卡上等于看不见。
208
+ const label = { fontSize: "13px", lineHeight: "19px", color: "var(--mp-text, var(--dsw-alias-label-primary))" }
209
+ const strong = { ...label, fontSize: "13px", fontWeight: 600, lineHeight: "20px" }
210
+ const btn = { height: "28px", padding: "0 12px", fontSize: "12.5px", borderRadius: "6px", cursor: "pointer", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "transparent", color: "var(--mp-text, var(--dsw-alias-label-primary))" }
211
+ const btnPrimary = { ...btn, background: "var(--mp-primary, var(--dsw-alias-brand-primary, #3b6cf6))", borderColor: "transparent", color: "var(--mp-on-primary, #fff)", fontWeight: 500 }
212
+ const input = { height: "26px", padding: "0 8px", fontSize: "12.5px", borderRadius: "6px", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-card-soft, transparent)", color: "var(--mp-text, var(--dsw-alias-label-primary))", boxSizing: "border-box" }
213
+ const mono = { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", fontSize: "11.5px", lineHeight: "17px", color: "var(--mp-text, var(--dsw-alias-label-primary))" }
32
214
  const row = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" }
33
- const chip = { fontSize: "11px", padding: "1px 6px", borderRadius: "999px", border: "0.5px solid var(--dsw-alias-border-l2)", color: "var(--dsw-alias-label-secondary)" }
215
+ const chip = { fontSize: "11px", padding: "1px 6px", borderRadius: "999px", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", color: "var(--mp-muted, var(--dsw-alias-label-secondary))", background: "var(--mp-card-soft, transparent)" }
34
216
  const chipBtn = { ...chip, cursor: "pointer", background: "transparent", fontFamily: "inherit" }
35
- const chipOn = { ...chipBtn, color: "var(--dsw-alias-label-primary)", borderColor: "var(--dsw-alias-fill-primary, #3b6cf6)" }
217
+ const chipOn = { ...chipBtn, color: "var(--mp-accent-strong, var(--mp-accent, #16C2C8))", borderColor: "var(--mp-accent, #16C2C8)", background: "var(--mp-accent-soft, transparent)", fontWeight: 600 }
36
218
 
37
- const LEVEL_COLOR = { high: "#ff6b6b", error: "#ff6b6b", medium: "#ffb020", warn: "#ffb020", low: "#8a8f98", info: "#8a8f98" }
219
+ const LEVEL_COLOR = { high: "var(--mp-danger, #ff6b6b)", error: "var(--mp-danger, #ff6b6b)", medium: "var(--mp-warn, #ffb020)", warn: "var(--mp-warn, #ffb020)", low: "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))", info: "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))" }
38
220
  const FORMAT_TEXT = { full: "完整版(含插件本体)", lite: "轻量版(联网取包)", hybrid: "混合包(联网取包 + 配置)" }
39
221
  // 三种打包策略的介绍:服务端 /pack/plan 会给可用性与不可用原因,这里只做兜底展示
40
222
  // ===== [区块] 打包策略与常量:STRATEGY_INFO =====
@@ -106,7 +288,7 @@ window.__ModuleLoader__.load({
106
288
  marketUi.value = { ...cur, [slice]: { ...(cur[slice] || {}), ...next } }
107
289
  }
108
290
  function saveMarketKind(kind) {
109
- marketUi.value = { ...readMarketUi(), kind: kind === "plugin" ? "plugin" : "modpack" }
291
+ marketUi.value = { ...readMarketUi(), kind: kind === "plugin" || kind === "manager" ? kind : "modpack" }
110
292
  }
111
293
 
112
294
  // 最近一次确认过的配置:设置页来回切时会重新挂载,只读 props.status 会退回旧值
@@ -143,6 +325,17 @@ window.__ModuleLoader__.load({
143
325
  return () => packStore.subs.delete(fn)
144
326
  }
145
327
 
328
+ // 页面级快照:离开插件页(切到别的页签、被卸载)再回来,原来选到哪儿、填了什么都在。
329
+ // 只有上传用的 GitHub token 例外——那份按规矩每次重进都要重新填,见 UploadPanel 的卸载清理。
330
+ const pageUi = { tab: "pack", pack: { query: "", category: "all" }, install: { source: null, options: null } }
331
+ function readPageUi() {
332
+ return pageUi
333
+ }
334
+ function setPageUi(slice, value) {
335
+ pageUi[slice] = value
336
+ }
337
+ const PAGE_TABS = ["pack", "install", "settings", "market", "manager"]
338
+
146
339
  // 插件市场的 AI 搜索:市场新版本用 POST /dsh-market/ai-search,让「你在 DSH 里配的模型」从目录里挑插件。
147
340
  // 我们不重复实现模型调用:旧版市场(或没装)没有这条路由,界面自动退回纯关键词搜索。
148
341
  const AI_SEARCH_KEY = "dsh-modpack-kit:ai-search"
@@ -380,7 +573,7 @@ window.__ModuleLoader__.load({
380
573
 
381
574
  function Switch(props) {
382
575
  return h("label", { title: props.title || undefined, style: { display: "inline-flex", gap: "6px", alignItems: "center", fontSize: "12.5px", cursor: props.disabled ? "not-allowed" : "pointer", opacity: props.disabled ? 0.45 : 1 } },
383
- h("input", { type: "checkbox", checked: !!props.checked, disabled: !!props.disabled, onChange: (e) => props.onChange(e.target.checked) }),
576
+ h("input", { type: "checkbox", checked: !!props.checked, disabled: !!props.disabled, style: { accentColor: "var(--mp-accent, var(--dsw-alias-brand-primary, #16C2C8))", width: "14px", height: "14px" }, onChange: (e) => props.onChange(e.target.checked) }),
384
577
  props.label)
385
578
  }
386
579
 
@@ -399,7 +592,7 @@ window.__ModuleLoader__.load({
399
592
 
400
593
  function NagText(props) {
401
594
  if (!props.text) return null
402
- return h("div", { style: { color: "#ff6b6b", fontSize: "12px", lineHeight: "18px" } }, props.text)
595
+ return h("div", { style: { color: "var(--mp-danger, #ff6b6b)", fontSize: "12px", lineHeight: "18px" } }, props.text)
403
596
  }
404
597
 
405
598
  // 强制项:开关照常显示(让人知道这项存在),但点不动——点一次弹红字。
@@ -414,11 +607,15 @@ window.__ModuleLoader__.load({
414
607
  }
415
608
 
416
609
  function Tag(props) {
417
- return h("span", { style: { ...chip, color: props.color || chip.color, borderColor: props.color || "var(--dsw-alias-border-l2)" } }, props.children)
610
+ return h("span", { style: { ...chip, color: props.color || chip.color, borderColor: props.color || "var(--mp-line, var(--dsw-alias-border-l2))" } }, props.children)
418
611
  }
419
612
 
420
613
  function Notice(props) {
421
- return h("div", { style: { ...box, borderColor: props.tone === "warn" ? "#ffb020" : props.tone === "bad" ? "#ff6b6b" : "var(--dsw-alias-border-l2)", background: "var(--dsw-alias-bg-l2, transparent)", fontSize: "12px", lineHeight: "18px" } }, props.children)
614
+ // 没有任何内容就别画空卡片:以前 children 为空时会留一个空边框块
615
+ const kids = Array.isArray(props.children) ? props.children : [props.children]
616
+ const blank = !kids.some((kid) => kid !== null && kid !== undefined && kid !== false && kid !== "")
617
+ if (blank) return null
618
+ return h("div", { style: { ...box, borderColor: props.tone === "warn" ? "var(--mp-warn, #ffb020)" : props.tone === "bad" ? "var(--mp-danger, #ff6b6b)" : "var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-hover, var(--dsw-alias-bg-layer-2, transparent))", fontSize: "12px", lineHeight: "18px" } }, props.children)
422
619
  }
423
620
 
424
621
  const ORIGIN_LABEL = { local: "本机", market: "市场", config: "配置", data: "数据", pack: "整合包" }
@@ -431,7 +628,7 @@ window.__ModuleLoader__.load({
431
628
  const summary = Array.isArray(props.summary) ? props.summary : [props.summary]
432
629
  // 标题行上的操作(比如「清空」):点它不该顺带把整块展开/收起
433
630
  const actions = Array.isArray(props.actions) ? props.actions.filter(Boolean) : []
434
- return h("div", { style: { display: "flex", flexDirection: "column", gap: "8px", border: "0.5px solid var(--dsw-alias-border-l2)", borderRadius: "8px", padding: "8px 10px" } },
631
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: "8px", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "8px", padding: "8px 10px" } },
435
632
  h("div", { style: { ...row, cursor: "pointer" }, onClick: () => setOpen((prev) => !prev) },
436
633
  h("div", { style: strong }, props.title),
437
634
  ...summary.filter(Boolean),
@@ -457,7 +654,7 @@ window.__ModuleLoader__.load({
457
654
  title: "安全检测",
458
655
  defaultOpen: counts.high > 0,
459
656
  summary: [
460
- h(Tag, { color: counts.high ? "#ff6b6b" : counts.medium ? "#ffb020" : "#2bb673" }, "高 " + counts.high + " · 中 " + counts.medium + " · 低 " + counts.low),
657
+ h(Tag, { color: counts.high ? "var(--mp-danger, #ff6b6b)" : counts.medium ? "var(--mp-warn, #ffb020)" : "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "高 " + counts.high + " · 中 " + counts.medium + " · 低 " + counts.low),
461
658
  h("span", { style: hint }, "扫了 " + (scan.scannedFiles || 0) + " 个文件"),
462
659
  ],
463
660
  hint: findings.length ? "展开(" + findings.length + " 条)" : "没有命中",
@@ -468,9 +665,9 @@ window.__ModuleLoader__.load({
468
665
  : h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
469
666
  groups.map((group) => {
470
667
  const expanded = openGroup[group.key] === true
471
- return h("div", { key: group.key, style: { border: "0.5px solid var(--dsw-alias-border-l2)", borderRadius: "6px", overflow: "hidden" } },
668
+ return h("div", { key: group.key, style: { border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "6px", overflow: "hidden" } },
472
669
  h("div", {
473
- style: { display: "flex", alignItems: "center", gap: "8px", padding: "6px 9px", cursor: "pointer", background: "var(--dsw-alias-bg-l2, transparent)" },
670
+ style: { display: "flex", alignItems: "center", gap: "8px", padding: "6px 9px", cursor: "pointer", background: "var(--mp-hover, var(--dsw-alias-bg-layer-2, transparent))" },
474
671
  onClick: () => toggleGroup(group.key),
475
672
  },
476
673
  h("span", { style: { ...label, fontSize: "12.5px" } }, group.label),
@@ -505,7 +702,7 @@ window.__ModuleLoader__.load({
505
702
  f.suggestion ? h("div", { style: hint }, "建议:" + f.suggestion) : null)))
506
703
  }
507
704
 
508
- const JOB_KIND_LABEL = { pack: "打包", install: "安装" }
705
+ const JOB_KIND_LABEL = { pack: "打包", install: "安装", upload: "上传", reinstall: "重装", update: "更新" }
509
706
  const JOB_STATUS_TEXT = { running: "进行中", paused: "等决定", acked: "已确认", done: "完成", failed: "失败", cancelled: "已取消" }
510
707
 
511
708
  function useJobs(intervalMs) {
@@ -530,7 +727,7 @@ window.__ModuleLoader__.load({
530
727
  function ProgressBar(props) {
531
728
  const pct = Math.max(0, Math.min(100, Math.round(props.pct || 0)))
532
729
  return h("div", { style: { height: "6px", borderRadius: "99px", background: "rgba(127,163,245,.18)", overflow: "hidden" } },
533
- h("div", { style: { width: pct + "%", height: "100%", borderRadius: "99px", transition: "width .25s ease", background: props.tone || "linear-gradient(90deg,#7FA3F5,#4C7DF0)" } }))
730
+ h("div", { style: { width: pct + "%", height: "100%", borderRadius: "99px", transition: "width .25s ease", background: props.tone || "linear-gradient(90deg, var(--mp-primary, var(--dsw-alias-brand-primary, #7FA3F5)) 0%, var(--mp-accent, #16C2C8) 100%)" } }))
534
731
  }
535
732
 
536
733
  // 进度窗:可以拖,拖过的位置记在浏览器本地;没有任务时自动收起,只留一枚唤出按钮。
@@ -730,10 +927,10 @@ window.__ModuleLoader__.load({
730
927
  gap: "6px",
731
928
  padding: "7px 11px",
732
929
  borderRadius: "999px",
733
- border: "0.5px solid var(--dsw-alias-border-l2)",
734
- background: "var(--dsw-alias-surface-1, rgba(24,26,31,.97))",
735
- color: "var(--dsw-alias-label-primary)",
736
- boxShadow: "0 6px 18px rgba(0,0,0,.28)",
930
+ border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
931
+ background: "var(--mp-card, var(--dsw-alias-card-fill, rgba(24,26,31,.97)))",
932
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
933
+ boxShadow: "var(--mp-shadow-strong, 0 6px 18px rgba(0,0,0,.28))",
737
934
  cursor: pos ? "grab" : "pointer",
738
935
  fontSize: "12px",
739
936
  touchAction: "none",
@@ -750,7 +947,7 @@ window.__ModuleLoader__.load({
750
947
  onPointerUp: endPillDrag,
751
948
  onPointerCancel: endPillDrag,
752
949
  },
753
- h("span", { style: { width: "7px", height: "7px", borderRadius: "99px", background: running.length ? "#4C7DF0" : "rgba(127,163,245,.5)" } }),
950
+ h("span", { style: { width: "7px", height: "7px", borderRadius: "99px", background: running.length ? "var(--mp-primary, #4C7DF0)" : "rgba(127,163,245,.5)" } }),
754
951
  "进度",
755
952
  badge ? h("span", { style: { ...hint, marginLeft: "0", fontVariantNumeric: "tabular-nums" } }, String(badge)) : null)
756
953
  }
@@ -815,10 +1012,10 @@ window.__ModuleLoader__.load({
815
1012
  overflow: "auto",
816
1013
  boxSizing: "border-box",
817
1014
  padding: "10px 12px",
818
- borderRadius: "10px",
819
- border: "0.5px solid var(--dsw-alias-border-l2)",
820
- background: "var(--dsw-alias-surface-1, rgba(24,26,31,.97))",
821
- boxShadow: "0 10px 30px rgba(0,0,0,.35)",
1015
+ borderRadius: "var(--mp-radius, 10px)",
1016
+ border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
1017
+ background: "var(--mp-card, var(--dsw-alias-card-fill, rgba(24,26,31,.97)))",
1018
+ boxShadow: "var(--mp-shadow-strong, 0 10px 30px rgba(0,0,0,.35))",
822
1019
  display: "flex",
823
1020
  flexDirection: "column",
824
1021
  gap: "7px",
@@ -833,7 +1030,7 @@ window.__ModuleLoader__.load({
833
1030
  onPointerUp: endDrag,
834
1031
  onPointerCancel: endDrag,
835
1032
  },
836
- h("span", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary, #b6bac3)", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, headText),
1033
+ h("span", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary, var(--mp-muted, var(--dsw-alias-label-tertiary, #b6bac3)))", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, headText),
837
1034
  h("span", { style: { marginLeft: "auto", fontSize: "12px", fontVariantNumeric: "tabular-nums" } }, headPct + "%"),
838
1035
  running.length > 1 ? h("span", { style: { ...hint, marginLeft: "0" } }, "+" + (running.length - 1)) : null,
839
1036
  jobs.length > 0
@@ -852,18 +1049,27 @@ window.__ModuleLoader__.load({
852
1049
  onPointerDown: (event) => { if (event && event.stopPropagation) event.stopPropagation() },
853
1050
  onClick: (event) => { if (event && event.stopPropagation) event.stopPropagation(); setHidden(true); setPinned(false) },
854
1051
  }, "收起")),
855
- current ? h(ProgressBar, { pct: headPct, tone: current.status === "failed" ? "#ff6b6b" : current.status === "cancelled" ? "#8b8f99" : undefined }) : null,
1052
+ current ? h(ProgressBar, { pct: headPct, tone: current.status === "failed" ? "var(--mp-danger, #ff6b6b)" : current.status === "cancelled" ? "var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99))" : undefined }) : null,
856
1053
  open
857
1054
  ? (jobs.length === 0
858
1055
  ? h("div", { style: hint }, "还没有打包或安装任务。开始一个就会出现在这里。")
859
1056
  : h("div", { style: { display: "flex", flexDirection: "column", gap: "8px", marginTop: "2px" } },
860
- jobs.map((job) => h("div", { key: job.id, style: { display: "flex", flexDirection: "column", gap: "4px", paddingTop: "7px", borderTop: "0.5px solid var(--dsw-alias-border-l2)" } },
1057
+ jobs.map((job) => h("div", { key: job.id, style: { display: "flex", flexDirection: "column", gap: "4px", paddingTop: "7px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" } },
861
1058
  h("div", { style: row },
862
1059
  h("span", { style: { ...label, fontSize: "12.5px" } }, job.label || JOB_KIND_LABEL[job.kind] || "任务"),
863
1060
  h("span", { style: { ...hint, marginLeft: "auto" } }, (JOB_STATUS_TEXT[job.status] || job.status) + " · " + Math.round(job.pct || 0) + "%")),
864
1061
  h("div", { style: hint }, job.note || ""),
1062
+ // 分步骤的任务(重装插件)把每一步摊开:只加显示,判定与清空逻辑不动
1063
+ job.steps && job.steps.length
1064
+ ? h("div", { style: { display: "flex", flexDirection: "column", gap: "1px" } },
1065
+ job.steps.map((step) => {
1066
+ const mark = step.state === "done" ? "✓" : step.state === "running" ? "◐" : step.state === "failed" ? "✗" : step.state === "cancelled" ? "–" : "·"
1067
+ const tone = step.state === "done" ? "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" : step.state === "running" ? "var(--mp-primary, #4C7DF0)" : step.state === "failed" ? "var(--mp-danger, #ff6b6b)" : "var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99))"
1068
+ return h("div", { key: step.key || step.label, style: { ...hint, fontSize: "11px", color: tone } }, mark + " " + (step.label || "") + (step.note ? ":" + step.note : ""))
1069
+ }))
1070
+ : null,
865
1071
  job.risk && job.status === "paused"
866
- ? h("div", { style: { ...hint, color: "#ff9b9b", display: "flex", flexDirection: "column", gap: "2px" } },
1072
+ ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff9b9b)", display: "flex", flexDirection: "column", gap: "2px" } },
867
1073
  h("div", null, "检测到风险:高 " + (job.risk.high || 0) + " · 中 " + (job.risk.medium || 0) + " · 低 " + (job.risk.low || 0)),
868
1074
  h("div", { style: { fontSize: "10.5px" } }, job.risk.message || ""),
869
1075
  job.risk.groups && job.risk.groups.length
@@ -871,27 +1077,36 @@ window.__ModuleLoader__.load({
871
1077
  job.risk.groups.map((g) => (g.label || "") + "(高 " + ((g.counts && g.counts.high) || 0) + " / 中 " + ((g.counts && g.counts.medium) || 0) + ")").join(" "))
872
1078
  : null)
873
1079
  : null,
874
- h(ProgressBar, { pct: job.pct, tone: job.status === "failed" || job.status === "paused" ? "#ff6b6b" : job.status === "cancelled" ? "#8b8f99" : undefined }),
1080
+ h(ProgressBar, { pct: job.pct, tone: job.status === "failed" || job.status === "paused" ? "var(--mp-danger, #ff6b6b)" : job.status === "cancelled" ? "var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99))" : undefined }),
875
1081
  h("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px" } },
876
1082
  job.status === "running" ? h("button", { style: { ...chipBtn }, onClick: () => stop(job.id) }, "终止") : null,
877
1083
  job.status === "done" && job.kind === "pack" && job.data && job.data.token
878
1084
  ? h("button", {
879
- style: { ...chipBtn, color: "#4C7DF0", borderColor: "#4C7DF0" },
1085
+ style: { ...chipBtn, color: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-primary, #4C7DF0)" },
880
1086
  title: "跳到打包页的下载部分",
881
1087
  onClick: () => { if (typeof props.onOpenResult === "function") props.onOpenResult(job) },
882
1088
  }, "下载安装包")
883
1089
  : null,
1090
+ job.kind === "upload" && job.status === "done" && job.data && job.data.pr && job.data.pr.url
1091
+ ? h("a", {
1092
+ style: { ...chipBtn, color: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-primary, #4C7DF0)", textDecoration: "none" },
1093
+ href: job.data.pr.url,
1094
+ target: "_blank",
1095
+ rel: "noreferrer",
1096
+ title: "在 GitHub 上打开这个 PR",
1097
+ }, "打开 PR #" + (job.data.pr.number || ""))
1098
+ : null,
884
1099
  job.canAck
885
- ? h("button", { style: { ...chipBtn, color: "#ff6b6b", borderColor: "#ff6b6b" }, title: "忽略风险,在同一个任务里接着跑完", onClick: () => ack(job.id) }, "我知道在干什么")
1100
+ ? h("button", { style: { ...chipBtn, color: "var(--mp-danger, #ff6b6b)", borderColor: "var(--mp-danger, #ff6b6b)" }, title: "忽略风险,在同一个任务里接着跑完", onClick: () => ack(job.id) }, "我知道在干什么")
886
1101
  : null,
887
1102
  job.status !== "running" && job.status !== "paused"
888
- ? h("button", { style: { ...chipBtn, color: "var(--dsw-alias-label-tertiary, #8b8f99)" }, title: "从列表里删掉这条记录", onClick: () => dismiss(job.id) }, "删除该进程")
1103
+ ? h("button", { style: { ...chipBtn, color: "var(--dsw-alias-label-tertiary, var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99)))" }, title: "从列表里删掉这条记录", onClick: () => dismiss(job.id) }, job.status === "failed" ? "我已知晓" : "删除该进程")
889
1104
  : null,
890
- job.error && job.status !== "paused" ? h("span", { style: { ...hint, color: "#ff6b6b" } }, job.error) : null)))))
1105
+ job.error && job.status !== "paused" ? h("span", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, job.error) : null)))))
891
1106
  : h("div", { style: { ...hint, fontSize: "10.5px" } },
892
1107
  (running.length ? running.length + " 个任务进行中 · " : "") + "按住标题能拖动,点标题展开看详情、也能中途终止"),
893
1108
  dockMsg
894
- ? h("div", { style: { ...hint, fontSize: "10.5px", color: "#ff6b6b", display: "flex", gap: "6px", alignItems: "center" } },
1109
+ ? h("div", { style: { ...hint, fontSize: "10.5px", color: "var(--mp-danger, #ff6b6b)", display: "flex", gap: "6px", alignItems: "center" } },
895
1110
  dockMsg,
896
1111
  h("button", { style: { ...chipBtn, marginLeft: "auto" }, onClick: () => setDockMsg("") }, "知道了"))
897
1112
  : null)
@@ -1150,7 +1365,6 @@ window.__ModuleLoader__.load({
1150
1365
  return next
1151
1366
  })
1152
1367
  }
1153
- const setSpec = (name, spec) => setSelected((prev) => ({ ...prev, [name]: { ...prev[name], spec } }))
1154
1368
  const setChoice = (name, choice) => setSelected((prev) => ({ ...prev, [name]: { ...prev[name], choice } }))
1155
1369
  // 同名市场版:装出来是上游原版代码 + 插件默认配置
1156
1370
  const switchMarket = (entry, toMarket) => setSelected((prev) => {
@@ -1206,9 +1420,9 @@ window.__ModuleLoader__.load({
1206
1420
  const chosenSource = on ? selected[entry.name].source : (entry.installed === false ? "npm" : "profile")
1207
1421
  const sourceText = on ? (chosenSource === "npm" ? "市场版" : "本机版") : (entry.installed === false ? "市场未装" : "已装")
1208
1422
  const sourceStyle = on
1209
- ? { ...chip, minWidth: "58px", textAlign: "center", fontWeight: 600, color: "var(--dsw-alias-label-primary)", borderColor: "var(--dsw-alias-border-l2)" }
1210
- : { ...chip, minWidth: "58px", textAlign: "center", color: "var(--dsw-alias-label-tertiary)" }
1211
- return h("div", { key: entry.name, style: { display: "flex", gap: "8px", alignItems: "center", padding: "5px 2px", borderTop: "0.5px solid var(--dsw-alias-border-l2)", flexWrap: "wrap" } },
1423
+ ? { ...chip, minWidth: "58px", textAlign: "center", fontWeight: 600, color: "var(--mp-text, var(--dsw-alias-label-primary))", borderColor: "var(--mp-line, var(--dsw-alias-border-l2))" }
1424
+ : { ...chip, minWidth: "58px", textAlign: "center", color: "var(--mp-muted, var(--dsw-alias-label-tertiary))" }
1425
+ return h("div", { key: entry.name, style: { display: "flex", gap: "8px", alignItems: "center", padding: "5px 2px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", flexWrap: "wrap" } },
1212
1426
  h("span", {
1213
1427
  style: sourceStyle,
1214
1428
  title: on
@@ -1219,9 +1433,9 @@ window.__ModuleLoader__.load({
1219
1433
  h("div", { style: { flex: "1 1 220px", minWidth: "180px" } },
1220
1434
  h("div", { style: label }, entry.title || entry.name, " ", h("span", { style: hint }, "@" + (entry.version || "?"))),
1221
1435
  h("div", { style: hint }, (entry.description || "").slice(0, 110))),
1222
- h("span", { style: { ...chip, color: "var(--dsw-alias-label-tertiary)" } }, labelOf(categoryOf(entry))),
1223
- entry.updateAvailable ? h(Tag, { color: "#2bb673" }, "市场版 " + (entry.marketVersion || entry.version) + " 更新") : null,
1224
- on ? h("span", { style: { ...chip, color: "var(--dsw-alias-label-secondary)", fontWeight: 600 } },
1436
+ h("span", { style: { ...chip, color: "var(--mp-muted, var(--dsw-alias-label-tertiary))" } }, labelOf(categoryOf(entry))),
1437
+ entry.updateAvailable ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "市场版 " + (entry.marketVersion || entry.version) + " 更新") : null,
1438
+ on ? h("span", { style: { ...chip, color: "var(--mp-muted, var(--dsw-alias-label-secondary))", fontWeight: 600 } },
1225
1439
  "版本 " + (selected[entry.name].source === "npm"
1226
1440
  ? (entry.marketVersion || (selected[entry.name].spec || "").replace(/^[^@]+@/u, "") || entry.version || "最新")
1227
1441
  : (entry.version || "本机"))) : null,
@@ -1229,7 +1443,7 @@ window.__ModuleLoader__.load({
1229
1443
  h("button", { style: selected[entry.name].choice !== "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "preset"), title: "只打插件默认配置:不带本机的配置与数据快照(代码按所选来源)" }, "插件预设"),
1230
1444
  h("button", { style: selected[entry.name].choice === "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "custom"), title: "带上本机这份插件的配置与数据快照;本机来源的连代码改动一起打" }, "自定义配置")) : null,
1231
1445
  entry.hasMarket && entry.source === "profile" && on ? h("button", {
1232
- style: { ...chipBtn, border: "none", fontSize: "10.5px", color: "var(--dsw-alias-label-tertiary)" },
1446
+ style: { ...chipBtn, border: "none", fontSize: "10.5px", color: "var(--mp-muted, var(--dsw-alias-label-tertiary))" },
1233
1447
  onClick: () => switchMarket(entry, selected[entry.name].source !== "npm"),
1234
1448
  title: "改用插件市场发的同名版本(上游原版代码 + 默认配置),装出来和从市场装一样",
1235
1449
  }, selected[entry.name].source === "npm" ? "改为本机版" : "改为市场版") : null)}
@@ -1242,10 +1456,10 @@ window.__ModuleLoader__.load({
1242
1456
  const isFolded = folded[section.name] === true
1243
1457
  out.push(h("div", {
1244
1458
  key: section.key,
1245
- style: { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap", padding: "7px 2px", borderTop: "0.5px solid var(--dsw-alias-border-l2)" },
1459
+ style: { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap", padding: "7px 2px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" },
1246
1460
  },
1247
1461
  h("button", {
1248
- style: { ...chipBtn, border: "none", padding: "0 4px", fontSize: "12px", color: "var(--dsw-alias-label-secondary)" },
1462
+ style: { ...chipBtn, border: "none", padding: "0 4px", fontSize: "12px", color: "var(--mp-muted, var(--dsw-alias-label-secondary))" },
1249
1463
  onClick: () => setFolded((prev) => ({ ...prev, [section.name]: !isFolded })),
1250
1464
  title: isFolded ? "展开「" + section.name + "」" : "收起「" + section.name + "」",
1251
1465
  }, isFolded ? "▸" : "▾"),
@@ -1272,7 +1486,7 @@ window.__ModuleLoader__.load({
1272
1486
  // 停在风险点的任务:按插件分栏列出命中项,确认/删除都在这里做
1273
1487
  const pausedRiskNodes = []
1274
1488
  if (pausedJobs.length > 0) {
1275
- pausedRiskNodes.push(h("div", { key: "title", style: { ...strong, color: "#ff6b6b" } }, `打包停在风险点(${pausedJobs.length} 个任务)`))
1489
+ pausedRiskNodes.push(h("div", { key: "title", style: { ...strong, color: "var(--mp-danger, #ff6b6b)" } }, `打包停在风险点(${pausedJobs.length} 个任务)`))
1276
1490
  pausedRiskNodes.push(h("div", { key: "hint", style: hint }, "下面是每个插件自己的命中项。确认后原任务从这个检测点接着跑完,不再重复检测。"))
1277
1491
  for (const job of pausedJobs) {
1278
1492
  const groupNodes = (job.risk.groups || []).map((group, index) => {
@@ -1296,7 +1510,7 @@ window.__ModuleLoader__.load({
1296
1510
  h("div", { style: { ...row, justifyContent: "space-between" } },
1297
1511
  h("div", { style: strong }, job.label || "打包任务"),
1298
1512
  h("div", { style: row },
1299
- h("button", { style: { ...btn, borderColor: "#ff6b6b", color: "#ff6b6b" }, onClick: () => ackJob(job.id) }, "我知道在干什么"),
1513
+ h("button", { style: { ...btn, borderColor: "var(--mp-danger, #ff6b6b)", color: "var(--mp-danger, #ff6b6b)" }, onClick: () => ackJob(job.id) }, "我知道在干什么"),
1300
1514
  h("button", { style: btn, onClick: () => dismissJob(job.id) }, "删除该进程"))),
1301
1515
  groupNodes))
1302
1516
  }
@@ -1448,26 +1662,26 @@ window.__ModuleLoader__.load({
1448
1662
  catalog.present && syncing ? h("div", { style: hint }, syncing) : null,
1449
1663
  catalog.present ? h(CategoryChips, { chips, value: category, onChange: setCategory }) : null,
1450
1664
  aiReady === false ? h("div", { style: hint }, "当前装的插件市场没有 AI 搜索(旧版本或未安装):这里只做关键词搜索。装新版 dshmarket 后开关会自动出现。") : null,
1451
- aiRun ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "6px", borderColor: aiRun.error ? "#ff6b6b" : "var(--dsw-alias-border-l2)" } },
1665
+ aiRun ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "6px", borderColor: aiRun.error ? "var(--mp-danger, #ff6b6b)" : "var(--mp-line, var(--dsw-alias-border-l2))" } },
1452
1666
  h("div", { style: row },
1453
1667
  h("div", { style: strong }, aiRun.error ? "AI 搜索没成功" : "AI 挑的插件"),
1454
1668
  h("span", { style: hint }, aiRun.model ? "模型:" + aiRun.model : ""),
1455
1669
  h("button", { style: btn, onClick: () => setAiRun(null) }, "收起")),
1456
- aiRun.error ? h("div", { style: { ...hint, color: "#ff6b6b" } }, aiRun.error + (aiRun.code === "no-model" ? " 先在「设置 → 模型」里配一个模型再试。" : "")) : null,
1670
+ aiRun.error ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, aiRun.error + (aiRun.code === "no-model" ? " 先在「设置 → 模型」里配一个模型再试。" : "")) : null,
1457
1671
  aiRun.intro ? h("div", { style: hint }, aiRun.intro) : null,
1458
1672
  aiRun.picks.length === 0 && !aiRun.error ? h("div", { style: hint }, "这次没挑出合适的插件,换个说法再试。") : null,
1459
1673
  aiRun.picks.map((item) => {
1460
1674
  const meta = marketInfo[item.name] || {}
1461
1675
  const on = Boolean(selected[item.name])
1462
1676
  const entry = { name: item.name, installed: false, hasMarket: true, marketVersion: meta.version || "", version: meta.version || "" }
1463
- return h("div", { key: item.name, style: { display: "flex", gap: "8px", alignItems: "flex-start", padding: "6px 2px", borderTop: "0.5px solid var(--dsw-alias-border-l2)" } },
1677
+ return h("div", { key: item.name, style: { display: "flex", gap: "8px", alignItems: "flex-start", padding: "6px 2px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" } },
1464
1678
  h("input", { type: "checkbox", checked: on, onChange: () => toggle(entry), style: { marginTop: "3px" } }),
1465
1679
  h("div", { style: { flex: "1 1 auto", minWidth: 0 } },
1466
1680
  h("div", { style: { ...strong, fontSize: "12.5px" } }, item.name + (meta.version ? " · v" + meta.version : "")),
1467
1681
  h("div", { style: hint }, item.description || ""),
1468
- item.why ? h("div", { style: { ...hint, color: "var(--dsw-alias-label-tertiary, #8b8f99)" } }, "为什么:" + item.why) : null))
1682
+ item.why ? h("div", { style: { ...hint, color: "var(--dsw-alias-label-tertiary, var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99)))" } }, "为什么:" + item.why) : null))
1469
1683
  })) : null,
1470
- search.error ? h("div", { style: { ...hint, color: "#ffb020" } }, search.error) : null,
1684
+ search.error ? h("div", { style: { ...hint, color: "var(--mp-warn, #ffb020)" } }, search.error) : null,
1471
1685
  h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", maxHeight: "320px", overflow: "auto" } },
1472
1686
  rows.length === 0
1473
1687
  ? h("div", { style: hint }, loading ? "读取中…" : active ? (searching ? "搜索中…" : "无匹配条目") : "本机尚未安装插件")
@@ -1485,7 +1699,7 @@ window.__ModuleLoader__.load({
1485
1699
  (planEntries.length ? planEntries : STRATEGY_INFO.map((item) => ({ ...item, ok: true }))).map((item) => {
1486
1700
  const disabled = item.ok === false
1487
1701
  const chosen = options.strategy === item.id
1488
- const muted = disabled ? "var(--dsw-alias-label-tertiary, #8b8f99)" : "var(--dsw-alias-label-secondary)"
1702
+ const muted = disabled ? "var(--dsw-alias-label-tertiary, var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99)))" : "var(--mp-muted, var(--dsw-alias-label-secondary))"
1489
1703
  return h("div", {
1490
1704
  key: item.id,
1491
1705
  role: "button",
@@ -1494,7 +1708,7 @@ window.__ModuleLoader__.load({
1494
1708
  style: {
1495
1709
  flex: "1 1 210px", minWidth: "190px", padding: "9px 10px", borderRadius: "8px",
1496
1710
  cursor: disabled ? "not-allowed" : "pointer",
1497
- border: "1px solid " + (chosen && !disabled ? "#4C7DF0" : "var(--dsw-alias-border-l2)"),
1711
+ border: "1px solid " + (chosen && !disabled ? "var(--mp-primary, #4C7DF0)" : "var(--mp-line, var(--dsw-alias-border-l2))"),
1498
1712
  borderStyle: disabled ? "dashed" : "solid",
1499
1713
  background: chosen && !disabled ? "rgba(76,125,240,0.08)" : "transparent",
1500
1714
  opacity: disabled ? 0.7 : 1,
@@ -1511,7 +1725,7 @@ window.__ModuleLoader__.load({
1511
1725
  },
1512
1726
  title: disabled ? (item.reason || "") : (item.online ? "安装时需要联网" : "不联网也能装"),
1513
1727
  },
1514
- h("div", { style: { display: "flex", gap: "6px", alignItems: "baseline", color: disabled ? muted : "var(--dsw-alias-label-primary)" } },
1728
+ h("div", { style: { display: "flex", gap: "6px", alignItems: "baseline", color: disabled ? muted : "var(--mp-text, var(--dsw-alias-label-primary))" } },
1515
1729
  h("span", { style: { fontWeight: 600 } }, item.title),
1516
1730
  h("span", { style: { fontSize: "11px", color: muted } }, item.online ? "需联网" : "不联网"),
1517
1731
  disabled ? h("span", { style: { ...chip, marginLeft: "auto", color: muted, cursor: "pointer" } }, "不可选") : null),
@@ -1531,7 +1745,7 @@ window.__ModuleLoader__.load({
1531
1745
  h("button", { style: btnPrimary, disabled: picked.length === 0 || busy === "start" || Boolean(currentBlocked), onClick: doPack }, busy === "start" ? "提交中…" : (currentBlocked ? "先换个可用的策略" : `打包 ${picked.length} 个插件`)),
1532
1746
  started ? h("span", { style: hint }, "已开始:" + started + "(进度在悬浮窗,可以接着选别的再打一个)") : null,
1533
1747
  status ? h("span", { style: hint }, "DSH " + (status.dshVersion || "?") + " · profile " + status.profile) : null)),
1534
- pausedRiskNodes.length ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px", borderColor: "#d9534f" } }, pausedRiskNodes) : null,
1748
+ pausedRiskNodes.length ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px", borderColor: "var(--mp-danger, #d9534f)" } }, pausedRiskNodes) : null,
1535
1749
  error ? h(Notice, { tone: "bad" }, error) : null,
1536
1750
  result ? h("div", { ref: resultRef, style: { ...box, display: "flex", flexDirection: "column", gap: "10px" } },
1537
1751
  result.refused || result.error
@@ -1539,13 +1753,13 @@ window.__ModuleLoader__.load({
1539
1753
  h("b", null, "已停止:"), result.error || "未通过检查",
1540
1754
  result.needsAck ? h("div", { style: { ...row, marginTop: "8px" } },
1541
1755
  h("button", {
1542
- style: { ...btn, borderColor: "#ff6b6b", color: "#ff6b6b" },
1756
+ style: { ...btn, borderColor: "var(--mp-danger, #ff6b6b)", color: "var(--mp-danger, #ff6b6b)" },
1543
1757
  disabled: busy === "start",
1544
1758
  onClick: () => doPack(true),
1545
1759
  }, busy === "start" ? "提交中…" : "我已知晓其中风险,继续打包")) : null)
1546
1760
  : h("div", { style: row },
1547
1761
  h("div", { style: strong }, result.fileName),
1548
- h(Tag, { color: "#2bb673" }, bytes(result.size)),
1762
+ h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, bytes(result.size)),
1549
1763
  h(Tag, null, FORMAT_TEXT[result.manifest && result.manifest.format] || ""),
1550
1764
  h("span", { style: hint }, "包内插件 " + ((result.manifest && result.manifest.plugins) || []).length + " 个")),
1551
1765
  result.scan ? h(ScanReport, { scan: result.scan, groups: result.scanGroups, footNote: "报告已写进包内 security/report.txt(只含类型与掩码)。" }) : null,
@@ -1566,8 +1780,15 @@ window.__ModuleLoader__.load({
1566
1780
 
1567
1781
  // —— 安装 / 导入 ——
1568
1782
  // ===== [区块] 页签二:安装 / 导入:InstallPanel =====
1783
+ // 安装页草稿:只活在内存里(刷新 / 重启即重置),离开插件页再回来不丢。
1784
+ const installDraft = { source: { kind: "url", url: "", file: "" }, options: null }
1785
+ function readInstallDraft() {
1786
+ return installDraft
1787
+ }
1788
+
1569
1789
  function InstallPanel(props) {
1570
- const [source, setSource] = useState({ kind: "url", url: "", file: "" })
1790
+ const installSaved = readInstallDraft()
1791
+ const [source, setSource] = useState(() => (installSaved.source ? { ...installSaved.source } : { kind: "url", url: "", file: "" }))
1571
1792
  const [packs, setPacks] = useState([])
1572
1793
  const [dirInput, setDirInput] = useState((props.status && props.status.paths && props.status.paths.packs) || "")
1573
1794
  const [dirInfo, setDirInfo] = useState({ dir: (props.status && props.status.paths && props.status.paths.packs) || "", error: "" })
@@ -1575,7 +1796,9 @@ window.__ModuleLoader__.load({
1575
1796
  const [busy, setBusy] = useState("")
1576
1797
  const [error, setError] = useState("")
1577
1798
  const [done, setDone] = useState(null)
1578
- const [options, setOptions] = useState({ keepLocal: true, applyConfig: true, force: false, dryRun: false, preferMarket: !!((props.status && props.status.config && props.status.config.preferMarketOnInstall !== false)), enableBundles: !!((props.status && props.status.config && props.status.config.enableOnInstall) === true) })
1799
+ const [options, setOptions] = useState(() => (installSaved.options ? { ...installSaved.options } : { keepLocal: true, applyConfig: true, force: false, dryRun: false, preferMarket: !!((props.status && props.status.config && props.status.config.preferMarketOnInstall !== false)), enableBundles: !!((props.status && props.status.config && props.status.config.enableOnInstall) === true) }))
1800
+ useEffect(() => { installDraft.options = options }, [options])
1801
+ useEffect(() => { installDraft.source = source }, [source])
1579
1802
  // 安装也走任务队列:进度直接显示在左下角那个窗里,这里留一份给页面内看
1580
1803
  const [progress, setProgress] = useState(null)
1581
1804
  const [deferred, setDeferred] = useState([])
@@ -1603,6 +1826,8 @@ window.__ModuleLoader__.load({
1603
1826
  if (!payload || !payload.token) return
1604
1827
  installRequest.value = null
1605
1828
  setSource({ kind: "token", token: payload.token, url: "", file: "" })
1829
+ // 下载时服务端会在 packs 目录留一份,列表顺手刷新一下就能在「已下载」里看到
1830
+ reloadPacks()
1606
1831
  setError("")
1607
1832
  setDone(null)
1608
1833
  setDeferred([])
@@ -1650,6 +1875,32 @@ window.__ModuleLoader__.load({
1650
1875
  } finally { setBusy("") }
1651
1876
  }
1652
1877
 
1878
+ // 已下载:社区资源里下过的包会留在插件自己的 packs 目录里。
1879
+ // 这里只做「读磁盘 + 交给同一条安装流程」,不碰网络。
1880
+ const pickDownloaded = async (item) => {
1881
+ if (!item || !item.path) return
1882
+ setBusy("import"); setError(""); setDone(null); setDeferred([]); setAskReplace(false)
1883
+ try {
1884
+ const data = await api("/inspect", { file: item.path })
1885
+ if (!data || data.ok !== true) throw new Error((data && data.error) || "这个包读不了,可能在下载时被删掉了")
1886
+ setSource({ kind: "file", file: item.path, token: "", url: "" })
1887
+ setPreview(data)
1888
+ } catch (e) {
1889
+ setError((e && e.message) || String(e))
1890
+ } finally { setBusy("") }
1891
+ }
1892
+
1893
+ const removeDownloaded = async (item) => {
1894
+ if (!item || !item.name) return
1895
+ try {
1896
+ const data = await api("/packs/remove", { name: item.name })
1897
+ if (data && Array.isArray(data.items)) setPacks(data.items)
1898
+ else await reloadPacks()
1899
+ } catch (e) {
1900
+ setError("删不掉:" + ((e && e.message) || e))
1901
+ }
1902
+ }
1903
+
1653
1904
  // 原生目录选择器:拿到绝对路径就填进去并列出该目录的 .dshpack
1654
1905
  const browseFolder = async () => {
1655
1906
  if (typeof pickDirectoryHost !== "function") {
@@ -1686,7 +1937,7 @@ window.__ModuleLoader__.load({
1686
1937
  const bodyFor = () => {
1687
1938
  if (source.kind === "url") return { url: source.url.trim() }
1688
1939
  if (source.kind === "token") return { token: source.token }
1689
- return { file: source.file }
1940
+ return { file: source.file, sourcePackFile: source.file }
1690
1941
  }
1691
1942
 
1692
1943
  const inspect = async () => {
@@ -1799,7 +2050,7 @@ window.__ModuleLoader__.load({
1799
2050
  gap: "3px",
1800
2051
  padding: "8px 10px",
1801
2052
  borderRadius: "8px",
1802
- border: "0.5px solid " + (source.kind === "token" && source.token === item.token ? "#4C7DF0" : "var(--dsw-alias-border-l2)"),
2053
+ border: "0.5px solid " + (source.kind === "token" && source.token === item.token ? "var(--mp-primary, #4C7DF0)" : "var(--mp-line, var(--dsw-alias-border-l2))"),
1803
2054
  },
1804
2055
  },
1805
2056
  h("div", { style: row },
@@ -1812,7 +2063,7 @@ window.__ModuleLoader__.load({
1812
2063
  onClick: () => pickImport(item),
1813
2064
  }, source.kind === "token" && source.token === item.token ? "当前选中" : "选择"),
1814
2065
  h("button", {
1815
- style: { ...chipBtn, color: "var(--dsw-alias-label-tertiary, #8b8f99)" },
2066
+ style: { ...chipBtn, color: "var(--dsw-alias-label-tertiary, var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99)))" },
1816
2067
  onClick: () => {
1817
2068
  removeImport(item.token)
1818
2069
  if (source.kind === "token" && source.token === item.token) {
@@ -1823,10 +2074,23 @@ window.__ModuleLoader__.load({
1823
2074
  }, "移除")),
1824
2075
  h("div", { style: { ...hint, fontSize: "10.5px" } },
1825
2076
  "作者:" + (item.author || "未填写") + " · 生成于 " + (item.createdAt ? when(item.createdAt) : "未知")),
1826
- item.description ? h("div", { style: { ...hint, fontSize: "11.5px", color: "var(--dsw-alias-label-secondary, #b6bac3)" } }, item.description) : null,
2077
+ item.description ? h("div", { style: { ...hint, fontSize: "11.5px", color: "var(--dsw-alias-label-secondary, var(--mp-muted, var(--dsw-alias-label-tertiary, #b6bac3)))" } }, item.description) : null,
1827
2078
  item.fileName ? h("div", { style: { ...hint, fontSize: "10px" } }, item.fileName) : null))))
1828
2079
  : null,
1829
2080
  h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px" } },
2081
+ // 已下载:社区资源里下载的包会留在插件自己的 packs 目录
2082
+ h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "6px" } },
2083
+ h("div", { style: row },
2084
+ h("div", { style: strong }, "已下载的整合包"),
2085
+ h("span", { style: hint }, packs.length > 0 ? "共 " + packs.length + " 份 · " + (dirInfo.dir || "插件自己的 packs 目录") : "还没有")),
2086
+ packs.length === 0
2087
+ ? h("div", { style: hint }, "在「社区资源」里点「下载并安装」,包会留一份在插件自己的 packs 目录;重启 DSH 之后也能从这里直接选。")
2088
+ : h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", maxHeight: "170px", overflow: "auto" } },
2089
+ packs.map((p) => h("div", { key: p.path || p.name, style: row },
2090
+ h("span", { style: { ...label, flex: "1 1 auto" } }, p.name),
2091
+ h("span", { style: hint }, bytes(p.size) + " · " + when(p.mtime)),
2092
+ h("button", { style: btn, disabled: busy !== "", onClick: () => pickDownloaded(p) }, source.kind === "file" && source.file === p.path ? "当前选中" : "选择"),
2093
+ h("button", { style: { ...btn, color: "var(--mp-danger, #ff6b6b)" }, disabled: busy !== "", onClick: () => removeDownloaded(p) }, "删除"))))),
1830
2094
  h("div", { style: row },
1831
2095
  h("button", { style: source.kind === "url" ? btnPrimary : btn, onClick: () => setSource({ ...source, kind: "url" }) }, "从链接读取"),
1832
2096
  h("button", { style: source.kind === "file" ? btnPrimary : btn, onClick: () => setSource({ ...source, kind: "file" }) }, "从本机文件读取"),
@@ -1859,7 +2123,7 @@ window.__ModuleLoader__.load({
1859
2123
  h("button", { style: btn, disabled: busy !== "", onClick: browseFolder }, busy === "dir" ? "选择中…" : "浏览文件夹…"),
1860
2124
  h("button", { style: btn, onClick: () => reloadPacks(dirInput) }, "读这个目录"),
1861
2125
  h("button", { style: btn, onClick: () => reloadPacks() }, "回到默认")),
1862
- dirInfo.error ? h("div", { style: { ...hint, color: "#ff6b6b" } }, dirInfo.error) : null,
2126
+ dirInfo.error ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, dirInfo.error) : null,
1863
2127
  h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", maxHeight: "170px", overflow: "auto" } },
1864
2128
  packs.length === 0 ? h("div", { style: hint }, "这个目录里没有 .dshpack。先去打包页生成一个,或者把文件拖到界面上。") : null,
1865
2129
  packs.map((p) => h("label", { key: p.path || p.name, style: { ...row, gap: "6px", cursor: "pointer" } },
@@ -1891,23 +2155,23 @@ window.__ModuleLoader__.load({
1891
2155
  h("div", { style: row },
1892
2156
  h("div", { style: strong }, preview.manifest.name),
1893
2157
  h(Tag, null, FORMAT_TEXT[preview.manifest.format] || preview.manifest.format),
1894
- h(Tag, { color: preview.integrity && preview.integrity.ok ? "#2bb673" : "#ffb020" }, preview.integrity && preview.integrity.present ? (preview.integrity.ok ? "完整性通过" : "完整性有出入") : "无完整性清单"),
2158
+ h(Tag, { color: preview.integrity && preview.integrity.ok ? "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" : "var(--mp-warn, #ffb020)" }, preview.integrity && preview.integrity.present ? (preview.integrity.ok ? "完整性通过" : "完整性有出入") : "无完整性清单"),
1895
2159
  h("span", { style: hint }, "生成于 " + when(preview.manifest.createdAt) + (preview.manifest.author ? " · " + preview.manifest.author : ""))),
1896
2160
  preview.manifest.description ? h("div", { style: label }, preview.manifest.description) : null,
1897
2161
  preview.blockingReasons && preview.blockingReasons.length
1898
2162
  ? h(Notice, { tone: "bad" }, h("b", null, "阻断:" ), preview.blockingReasons.join(";"), " (真要装,勾上面的「忽略阻断」)")
1899
2163
  : null,
1900
2164
  h("div", { style: { display: "flex", flexDirection: "column", gap: "4px", maxHeight: "280px", overflow: "auto" } },
1901
- previewProblems.length ? h("div", { style: { ...hint, color: "#ffb020" } }, "有 " + previewProblems.length + " 条问题/提醒,相关插件已排在最前面") : null,
2165
+ previewProblems.length ? h("div", { style: { ...hint, color: "var(--mp-warn, #ffb020)" } }, "有 " + previewProblems.length + " 条问题/提醒,相关插件已排在最前面") : null,
1902
2166
  previewRows.map((row) => {
1903
2167
  const p = row.plugin
1904
2168
  const checked = pickedNames[p.name] !== false
1905
- return h("div", { key: p.name, style: { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap", padding: "4px 0", borderTop: "0.5px solid var(--dsw-alias-border-l2)" } },
2169
+ return h("div", { key: p.name, style: { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap", padding: "4px 0", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" } },
1906
2170
  h("input", { type: "checkbox", checked, onChange: () => setPickedNames((prev) => ({ ...prev, [p.name]: !checked })) }),
1907
2171
  h("div", { style: { flex: "1 1 220px", minWidth: "170px" } },
1908
2172
  h("div", { style: label }, p.name, " ", h("span", { style: hint }, p.latest ? "@市场最新(装的时候按名字取)" : "@" + (p.version || "?"))),
1909
2173
  h("div", { style: hint }, [p.localEdits ? "含本机修改" : "", p.configIncluded ? "有配置" : "", p.dataIncluded ? "有数据快照" : ""].filter(Boolean).join(" · ")),
1910
- row.problems.length ? h("div", { style: { ...hint, color: row.problems.some((f) => f.level === "error") ? "#ff6b6b" : "#ffb020" } },
2174
+ row.problems.length ? h("div", { style: { ...hint, color: row.problems.some((f) => f.level === "error") ? "var(--mp-danger, #ff6b6b)" : "var(--mp-warn, #ffb020)" } },
1911
2175
  row.problems.slice(0, 3).map((f) => "· " + f.message).join(";") + (row.problems.length > 3 ? "(还有 " + (row.problems.length - 3) + " 条)" : "")) : null),
1912
2176
  p.configIncluded ? h("div", { style: { display: "flex", gap: "4px" } },
1913
2177
  h("button", { style: (configChoice[p.name] || "pack") === "pack" ? chipOn : chipBtn, onClick: () => setConfigChoice((prev) => ({ ...prev, [p.name]: "pack" })), title: "用包里的配置条目覆盖/补上" }, "包内配置"),
@@ -1922,7 +2186,7 @@ window.__ModuleLoader__.load({
1922
2186
  : null,
1923
2187
  askReplace && deferred.length > 0
1924
2188
  ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
1925
- h("div", { style: { ...label, color: "#ffb020" } }, "以下 " + deferred.length + " 个插件本机已经装了,这次先跳过没动它们:"),
2189
+ h("div", { style: { ...label, color: "var(--mp-warn, #ffb020)" } }, "以下 " + deferred.length + " 个插件本机已经装了,这次先跳过没动它们:"),
1926
2190
  deferred.map((d) => h("div", { key: d.name, style: mono },
1927
2191
  "· " + d.name + " 本机 " + (d.localVersion || "未知") + " → 包内 " + (d.packVersion || "未知") + (d.sameVersion ? "(版本相同)" : ""))),
1928
2192
  h("div", { style: hint }, "要保留本机版本就直接完成;要换成包内版本点下面这个(会覆盖本机那份)。"),
@@ -1933,14 +2197,20 @@ window.__ModuleLoader__.load({
1933
2197
  done ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
1934
2198
  h("div", { style: row },
1935
2199
  h("div", { style: strong }, done.ok ? "安装完成" : "没有装成"),
1936
- done.needsRestart ? h(Tag, { color: "#ffb020" }, "需要重启 DSH 生效") : null),
1937
- done.error ? h("div", { style: { ...label, color: "#ff6b6b" } }, done.error) : null,
1938
- (done.actions || []).map((a, i) => h("div", { key: i, style: { ...mono, color: a.ok ? "inherit" : "#ff6b6b" } },
2200
+ done.needsRestart ? h(Tag, { color: "var(--mp-warn, #ffb020)" }, "需要重启 DSH 生效") : null),
2201
+ done.error ? h("div", { style: { ...label, color: "var(--mp-danger, #ff6b6b)" } }, done.error) : null,
2202
+ (done.actions || []).map((a, i) => h("div", { key: i, style: { ...mono, color: a.ok ? "inherit" : "var(--mp-danger, #ff6b6b)" } },
1939
2203
  (a.ok ? "✓ " : "✗ ") + a.plugin + " · " + a.action + " · " + a.message)),
1940
2204
  (done.lines || []).length ? h("details", null, h("summary", { style: hint }, "命令输出(" + done.lines.length + " 行)"),
1941
2205
  h("pre", { style: { ...mono, maxHeight: "200px", overflow: "auto", whiteSpace: "pre-wrap" } }, done.lines.join("\n"))) : null,
1942
2206
  done.scan ? h(ScanReport, { scan: done.scan, groups: done.scanGroups }) : null)
1943
- : null)
2207
+ : null,
2208
+ // 装完之后顺手能管:开关、更新、重装都在这一块(和「社区资源 → 插件管理」是同一个组件)
2209
+ h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2210
+ h("div", { style: row },
2211
+ h("div", { style: strong }, "插件管理"),
2212
+ h("span", { style: hint }, "装好的插件在这里开关、更新、重装")),
2213
+ h(PluginManagerPanel, { compact: true })))
1944
2214
  }
1945
2215
 
1946
2216
  // —— 设置与记录 ——
@@ -1952,13 +2222,13 @@ window.__ModuleLoader__.load({
1952
2222
  style: {
1953
2223
  marginTop: "6px",
1954
2224
  paddingTop: "12px",
1955
- borderTop: "1px solid var(--dsw-alias-border-l2)",
2225
+ borderTop: "1px solid var(--mp-line, var(--dsw-alias-border-l2))",
1956
2226
  display: "flex",
1957
2227
  alignItems: "baseline",
1958
2228
  gap: "8px",
1959
2229
  flexWrap: "wrap",
1960
2230
  fontSize: "12px",
1961
- color: "var(--dsw-alias-label-tertiary)",
2231
+ color: "var(--mp-muted, var(--dsw-alias-label-tertiary))",
1962
2232
  },
1963
2233
  },
1964
2234
  h("span", null, "项目地址:"),
@@ -1966,7 +2236,7 @@ window.__ModuleLoader__.load({
1966
2236
  href: REPO_URL,
1967
2237
  target: "_blank",
1968
2238
  rel: "noreferrer",
1969
- style: { color: "var(--dsw-alias-label-primary)", textDecoration: "underline", textUnderlineOffset: "2px" },
2239
+ style: { color: "var(--mp-text, var(--dsw-alias-label-primary))", textDecoration: "underline", textUnderlineOffset: "2px" },
1970
2240
  }, "github.com/Vesna-Strivozha-cn/dsh-modpack-kit"),
1971
2241
  h("span", null, "如果这个插件省了时间,顺手点个 Star,能让更多人找到它。"))
1972
2242
  }
@@ -1974,6 +2244,17 @@ window.__ModuleLoader__.load({
1974
2244
  // ===== [区块] 页签四:设置与记录:SettingsPanel =====
1975
2245
  function SettingsPanel(props) {
1976
2246
  const [cfg, setCfg] = useState(() => ({ ...((props.status && props.status.config) || {}), ...(liveCfg.value || {}) }))
2247
+ const packsDirLine = ((props.status || {}).paths || {}).packs || ""
2248
+ const [folderMsg, setFolderMsg] = useState("")
2249
+ const openPackFolder = async () => {
2250
+ try {
2251
+ const data = await api("/packs/open", {})
2252
+ if (data && data.ok) setFolderMsg("已打开:" + (data.dir || packsDirLine))
2253
+ else setFolderMsg((data && data.error) || "打不开")
2254
+ } catch (e) {
2255
+ setFolderMsg("打不开:" + ((e && e.message) || e))
2256
+ }
2257
+ }
1977
2258
  const [saved, setSaved] = useState("")
1978
2259
  const [busy, setBusy] = useState(false)
1979
2260
  const [scanNag, fireScanNag] = useNag()
@@ -2005,6 +2286,9 @@ window.__ModuleLoader__.load({
2005
2286
  if (data && data.ok) {
2006
2287
  setCfg(data.config)
2007
2288
  mergeLiveConfig(data.config)
2289
+ // 配色 / 界面风格就在这一份回包里:直接换上,不用等人再点一次刷新
2290
+ if (data.theme) setLiveTheme({ theme: data.theme, uiStyle: data.uiStyle })
2291
+ else if (data.config) setLiveTheme({ theme: localTheme(data.config), uiStyle: data.uiStyle || data.config.uiStyle })
2008
2292
  // 「社区资源」这一栏的开关键在这里:一关,标签立刻消失,不用等重新拉状态
2009
2293
  if (Object.prototype.hasOwnProperty.call(p, "showModpackMarket")) setMarketVisible(data.config.showModpackMarket !== false)
2010
2294
  setSaved("已保存")
@@ -2067,8 +2351,155 @@ window.__ModuleLoader__.load({
2067
2351
 
2068
2352
  const textList = (key) => (Array.isArray(cfg[key]) ? cfg[key].join("\n") : "")
2069
2353
 
2070
- return h("div", { style: { display: "flex", flexDirection: "column", gap: "14px" } },
2071
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px" } },
2354
+ // 测试模式:所有会真的下载 / 安装 / 改本机的操作只走流程,进度与弹窗照常(服务端见 lib/testmode.mjs)
2355
+ const testModeBox = h("div", {
2356
+ style: { ...box, display: "flex", flexDirection: "column", gap: "8px", border: cfg.testMode === true ? "1px solid var(--mp-warn, #ff9a3c)" : "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" },
2357
+ },
2358
+ h("div", { style: { ...strong, color: cfg.testMode === true ? "var(--mp-warn, #ff9a3c)" : undefined } }, "测试模式" + (cfg.testMode === true ? "(已开启)" : "")),
2359
+ h(Switch, {
2360
+ checked: cfg.testMode === true,
2361
+ label: "所有操作只走流程,不真下载、不真安装、不改本机",
2362
+ title: "开着时:打包不写文件、下载给占位文件、安装只读包不写 profile、一键更新与重装只演步骤、启停不落盘、上传一律按演练走。进度窗与确认弹窗照常出现。",
2363
+ onChange: (v) => { setField("testMode", v); patch({ testMode: v }) },
2364
+ }),
2365
+ h("div", { style: hint }, "方便试流程:打包 / 下载 / 安装 / 一键更新 / 重装 / 启停 / 上传都只演一遍,进度与弹窗照常;真下载、真写 profile、真改插件市场那份状态都不做。装包时的「读包 + 校验 + 扫描」仍是真的(只读),所以检查结果照常能看。"),
2366
+ cfg.testMode === true ? h("div", { style: { ...hint, color: "var(--mp-warn, #ff9a3c)" } }, "注意:现在整台机器看到的都是流程,做完测试记得关掉。") : null)
2367
+
2368
+ // 设置页的排布:顶部一句说明 + 一排能跳的章节,下面每块都是同一张卡片(左侧一条附属色)。
2369
+ // 卡片顺序按「常改的在上」:配色 → 测试模式 → 附属小插件 → 显示位置 → 扫描 → 网络 → 信任 → 目录 → 社区 → 记录 → 位置。
2370
+ const classicUiNow = (((liveTheme.value && liveTheme.value.uiStyle) || (props.status && props.status.uiStyle)) === "classic")
2371
+ // classic:卡片回到改版前的朴素样式(没有左侧色条、间距更松),也不显示配色块与章节跳转
2372
+ const settingsCard = classicUiNow
2373
+ ? { ...box, display: "flex", flexDirection: "column", gap: "8px" }
2374
+ : { ...box, display: "flex", flexDirection: "column", gap: "10px" }
2375
+ const SETTINGS_NAV = [["theme", "配色"], ["test", "测试模式"], ["sub", "附属小插件"], ["place", "显示位置"], ["scan", "扫描与安装"], ["net", "网络"], ["trust", "信任清单"], ["catalog", "插件目录"], ["market", "社区资源"], ["history", "记录"], ["paths", "位置"]]
2376
+ const jumpTo = (id) => {
2377
+ try {
2378
+ const doc = typeof document === "undefined" ? null : document
2379
+ const node = doc && doc.getElementById("mp-set-" + id)
2380
+ if (node && node.scrollIntoView) node.scrollIntoView({ behavior: "smooth", block: "start" })
2381
+ } catch (err) { /* 没有 document 时(测试里)跳不过去就算了 */ }
2382
+ }
2383
+
2384
+ // 配色:预设卡片 + 自定义两个颜色。整套配色只在客户端用 --mp-* 变量取,宿主其它面板不受影响。
2385
+ const theme = (liveTheme.value && liveTheme.value.theme) || localTheme(cfg)
2386
+ const LOCAL_PRESETS = [
2387
+ { id: "mist", label: "雾蓝(PCL 色系)", recommended: true, primary: "#1B7BE8", accent: "#16C2C8", note: "标题栏蓝 + 青,白卡片、浅蓝渐变底", swatch: ["#1B7BE8", "#16C2C8", "#EEF5FF"] }, // lint-allow-color:预设色板
2388
+ { id: "forest", label: "墨绿 + 琥珀", primary: "#2E7D6B", accent: "#E0A33E", note: "安静一点,适合长时间看列表", swatch: ["#2E7D6B", "#E0A33E", "#F2F7F5"] }, // lint-allow-color:预设色板
2389
+ { id: "dusk", label: "暮紫 + 樱粉", primary: "#6A5AE0", accent: "#F2A0A8", note: "夜间观感更柔,暗色下偏蓝紫", swatch: ["#6A5AE0", "#F2A0A8", "#F4F2FF"] }, // lint-allow-color:预设色板
2390
+ { id: "native", label: "跟 DSH 原生(黑 / 白)", primary: "", accent: "", note: "底色是黑是白,跟着系统的夜间 / 白天走;不注入任何颜色", swatch: [] },
2391
+ ] // lint-allow-color:预设色板,就是这几个颜色本身
2392
+ const providedPresets = Array.isArray(props.status && props.status.themePresets) ? props.status.themePresets : []
2393
+ const presets = providedPresets.length ? providedPresets : LOCAL_PRESETS
2394
+ const themeVarsNow = (theme && theme.vars && Object.keys(theme.vars).length)
2395
+ ? theme.vars
2396
+ : (theme && theme.id === "native" ? HOST_VARS : (classicUiNow ? CLASSIC_VARS : {}))
2397
+ const themeBox = h("div", { style: settingsCard },
2398
+ h("div", { style: row },
2399
+ h("span", { style: strong }, "配色与外观"),
2400
+ h("span", { style: { ...hint, marginLeft: "auto" } }, "只改本插件自己的界面")),
2401
+ h("div", { style: { display: "flex", height: "34px", borderRadius: "8px", overflow: "hidden", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" } },
2402
+ h("span", { style: { flex: "2", background: themeVarsNow["--mp-primary"] || "var(--dsw-alias-bg-layer-1, var(--mp-on-primary, #fff))" } }),
2403
+ h("span", { style: { flex: "1", background: themeVarsNow["--mp-accent"] || "var(--mp-line, var(--dsw-alias-bg-layer-2, #eee))" } }),
2404
+ h("span", { style: { flex: "3", background: themeVarsNow["--mp-page"] || "var(--dsw-alias-bg-layer-1, var(--mp-on-primary, #fff))" } })),
2405
+ h("div", { style: hint }, "主色管重点(主按钮、选中页签),附属色管强调(筛选胶囊、开关、进度条)。选「跟 DSH 原生(黑 / 白)」时一个颜色都不注入,底色是黑是白跟着系统的夜间 / 白天走。"),
2406
+ h("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" } },
2407
+ presets.map((preset) => {
2408
+ const on = String(cfg.themeId || "mist") === preset.id
2409
+ return h("button", {
2410
+ key: "theme-" + preset.id,
2411
+ type: "button",
2412
+ disabled: busy,
2413
+ onClick: () => patch({ themeId: preset.id }),
2414
+ style: {
2415
+ textAlign: "left", cursor: busy ? "default" : "pointer", fontFamily: "inherit", padding: "10px", borderRadius: "10px",
2416
+ display: "flex", flexDirection: "column", gap: "6px",
2417
+ // 用预设自己的颜色画边框与底:不管当前是哪套配色,卡片上看到的就是点下去的样子
2418
+ border: on ? "1.5px solid " + (preset.primary || "var(--mp-muted, var(--dsw-alias-label-tertiary))") : "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
2419
+ background: cardSurface,
2420
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
2421
+ },
2422
+ },
2423
+ h("span", { style: { ...strong, fontSize: "12.5px", color: "var(--mp-text, var(--dsw-alias-label-primary))" } }, preset.label + (preset.recommended ? " · 推荐" : "")),
2424
+ h("span", { style: { display: "flex", gap: "4px" } },
2425
+ (preset.swatch || []).map((color, index) => h("span", {
2426
+ key: "sw-" + preset.id + "-" + index,
2427
+ style: { width: "26px", height: "10px", borderRadius: "3px", background: color, border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" },
2428
+ }))),
2429
+ h("span", { style: { ...hint, fontSize: "11.5px" } }, preset.note || ""))
2430
+ })),
2431
+ h("div", { style: row },
2432
+ h("span", { style: label }, "主色"),
2433
+ h("input", { style: { ...input, width: "104px" }, value: String(cfg.themePrimary || ""), placeholder: "#1B7BE8", onChange: (e) => setField("themePrimary", e.target.value) }), // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
2434
+ h("span", { style: label }, "附属色"),
2435
+ h("input", { style: { ...input, width: "104px" }, value: String(cfg.themeAccent || ""), placeholder: "#16C2C8", onChange: (e) => setField("themeAccent", e.target.value) }), // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
2436
+ h("button", {
2437
+ style: btn, type: "button", disabled: busy,
2438
+ onClick: () => patch({ themeId: "custom", themePrimary: String(cfg.themePrimary || ""), themeAccent: String(cfg.themeAccent || "") }),
2439
+ }, "套用自定义"),
2440
+ h("button", { style: btn, type: "button", disabled: busy, onClick: () => patch({ themeId: "mist", themePrimary: "", themeAccent: "" }) }, "恢复默认")),
2441
+ h("div", { style: hint }, "自定义要两个颜色都填成 #RRGGBB;填错会被忽略、退回预设色。暗色模式下用同色系深一点的那版。"))
2442
+
2443
+ // 界面风格:做成跟「打包策略」一样的三选一卡片;每张卡的配色用的是它自己那套(写死的 hex),
2444
+ // 所以不管当前是哪种风格,卡片上看到的就是点下去之后的样子。
2445
+ // 新版卡片的色带:上了主题就跟着主题走(所见即所得);经典 / 原生这两档没有我们的主题色,就用固定的展示色
2446
+ const followTheme = !classicUiNow && !(theme && theme.id === "native")
2447
+ const UI_CHOICES = [
2448
+ { id: "new", title: "新版", note: "分区卡片、章节跳转;卡片、页签、按钮和文字都跟着下面选的主题走。", primary: followTheme ? "var(--mp-primary, #1B7BE8)" : "#1B7BE8", accent: followTheme ? "var(--mp-accent, #16C2C8)" : "#16C2C8", page: followTheme ? "var(--mp-card, #ffffff)" : "#EEF5FF" }, // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
2449
+ { id: "classic", title: "经典(改版前)", note: "不上美化:方角、无卡片底、无阴影、页签平铺。", primary: "#8A919C", accent: "#C2C8D2", page: "transparent" }, // lint-allow-color:取色表 / 示例色,不是界面里直接上色的地方
2450
+ ]
2451
+ const styleBox = h("div", { id: "mp-set-style", style: settingsCard },
2452
+ h("div", { style: row },
2453
+ h("span", { style: strong }, "界面风格"),
2454
+ h("span", { style: { ...hint, marginLeft: "auto" } }, classicUiNow ? "现在是改版前的样子" : "现在是新版")),
2455
+ h("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" } },
2456
+ UI_CHOICES.map((choice) => {
2457
+ const on = choice.id === (classicUiNow ? "classic" : "new")
2458
+ const pick = () => { if (!busy) patch({ uiStyle: choice.id }) }
2459
+ return h("div", {
2460
+ key: "ui-" + choice.id,
2461
+ role: "button",
2462
+ tabIndex: 0,
2463
+ "aria-disabled": busy ? "true" : "false",
2464
+ title: on ? "现在用的就是这个" : "点一下换成这个",
2465
+ style: {
2466
+ flex: "1 1 210px", minWidth: "190px", padding: "9px 10px", borderRadius: "8px",
2467
+ cursor: busy ? "default" : "pointer",
2468
+ border: on ? "1.5px solid " + choice.primary : "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
2469
+ background: cardSurface,
2470
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
2471
+ },
2472
+ onClick: pick,
2473
+ onKeyDown: (event) => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); pick() } },
2474
+ },
2475
+ h("div", { style: { display: "flex", gap: "6px", alignItems: "baseline" } },
2476
+ h("span", { style: { fontWeight: 600, fontSize: "12.5px" } }, choice.title),
2477
+ on ? h("span", { style: { ...chip, color: choice.primary, borderColor: choice.primary } }, "在用") : null),
2478
+ h("div", { style: { display: "flex", height: "18px", borderRadius: "5px", overflow: "hidden", marginTop: "6px", border: "0.5px solid " + choice.page } },
2479
+ h("span", { style: { flex: "2", background: choice.primary } }),
2480
+ h("span", { style: { flex: "1", background: choice.accent } }),
2481
+ h("span", { style: { flex: "3", background: choice.page } })),
2482
+ h("div", { style: { ...hint, marginTop: "5px" } }, choice.note))
2483
+ })),
2484
+ h("div", { style: hint }, "两边随时能换,不影响已存的配置与整合包。"))
2485
+
2486
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: classicUiNow ? "14px" : "12px" } },
2487
+ h("div", { style: { ...settingsCard } },
2488
+ h("div", { style: { ...strong, fontSize: "15px" } }, "设置"),
2489
+ h("div", { style: hint }, "改了就生效(除注明要重启 DSH 的)。下面按「常改的在上」排,点标签直接跳过去。"),
2490
+ saved ? h("div", { style: { ...hint, color: "var(--mp-primary, #2f6bf3)" } }, saved) : null),
2491
+ classicUiNow
2492
+ ? null
2493
+ : h("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px" } },
2494
+ SETTINGS_NAV.map(([key, label]) => h("button", {
2495
+ key: "snav-" + key, type: "button",
2496
+ style: { ...chipBtn, fontSize: "12px", borderColor: "var(--mp-accent-soft, #D7F6F8)", color: "var(--mp-accent-strong, var(--mp-accent, #16C2C8))", background: "var(--mp-accent-soft, #D7F6F8)" },
2497
+ onClick: () => jumpTo(key),
2498
+ }, label))),
2499
+ styleBox,
2500
+ classicUiNow ? null : themeBox,
2501
+ h("div", { id: "mp-set-test", style: { display: "flex", flexDirection: "column", gap: "6px" } }, testModeBox),
2502
+ h("div", { id: "mp-set-scan", style: settingsCard },
2072
2503
  h("div", { style: strong }, "扫描与安装策略"),
2073
2504
  h("div", { style: row },
2074
2505
  h(ForcedSwitch, { label: "打包前扫描(强制)", onNag: () => fireScanNag("你想干什么") }),
@@ -2103,6 +2534,8 @@ window.__ModuleLoader__.load({
2103
2534
  }, "保存数值"),
2104
2535
  h("span", { style: hint }, "默认 256 MB,可填 16~4096"),
2105
2536
  saved ? h("span", { style: hint }, saved) : null)),
2537
+ h("div", { id: "mp-set-net", style: settingsCard },
2538
+ h("div", { style: strong }, "网络与请求上限"),
2106
2539
  h("div", { style: row },
2107
2540
  h("span", { style: label }, "网络超时(秒)"),
2108
2541
  h("input", { style: { ...input, width: "70px" }, type: "number", min: "5", max: "120", value: String(cfg.netTimeoutSeconds || 20), onChange: (e) => setField("netTimeoutSeconds", Number(e.target.value)) }),
@@ -2115,8 +2548,8 @@ window.__ModuleLoader__.load({
2115
2548
  label: "fetch 失败时用系统 curl 兜底",
2116
2549
  onChange: (v) => { setField("curlFallback", v); patch({ curlFallback: v }) },
2117
2550
  })),
2118
- h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl 兜底(走系统证书库)。提示「下载超过上限」时是版本清单太大(billion-context 这类包的清单十几 MB):把「版本清单上限」调大,或改用确定的版本号(插件会直接取单版本清单,体积最小)。保存后立即生效。"),
2119
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2551
+ h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl 兜底(走系统证书库)。提示「下载超过上限」时是版本清单太大(billion-context 这类包的清单十几 MB):把「版本清单上限」调大,或改用确定的版本号(插件会直接取单版本清单,体积最小)。保存后立即生效。")),
2552
+ h("div", { id: "mp-set-trust", style: settingsCard },
2120
2553
  h("div", { style: strong }, "信任清单"),
2121
2554
  h("div", { style: hint }, "允许的许可证(一行一个,例如 MIT):"),
2122
2555
  h("textarea", { style: { ...input, height: "62px", padding: "6px 8px", width: "100%", resize: "vertical" }, value: textList("licenseAllow"), onChange: (e) => setField("licenseAllow", e.target.value.split("\n")) }),
@@ -2126,7 +2559,7 @@ window.__ModuleLoader__.load({
2126
2559
  h("textarea", { style: { ...input, height: "62px", padding: "6px 8px", width: "100%", resize: "vertical" }, value: textList("registries"), onChange: (e) => setField("registries", e.target.value.split("\n")) }),
2127
2560
  h("div", { style: row },
2128
2561
  h("button", { style: btn, disabled: busy, onClick: () => patch({ licenseAllow: cfg.licenseAllow.filter(Boolean), allowHosts: cfg.allowHosts.filter(Boolean), registries: cfg.registries.filter(Boolean) }) }, "保存清单"))),
2129
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2562
+ h("div", { id: "mp-set-paths", style: settingsCard },
2130
2563
  h("div", { style: strong }, "位置"),
2131
2564
  h("div", { style: mono }, "profile:" + ((props.status && props.status.paths && props.status.paths.profile) || "?")),
2132
2565
  h("div", { style: mono }, "整合包:" + ((props.status && props.status.paths && props.status.paths.packs) || "?")),
@@ -2150,7 +2583,7 @@ window.__ModuleLoader__.load({
2150
2583
  history.length === 0
2151
2584
  ? h("div", { style: hint }, "还没有记录。")
2152
2585
  : h("div", { style: { display: "flex", flexDirection: "column", gap: "2px" } },
2153
- history.map((item, i) => h("div", { key: String(item.at || i) + i, style: { ...mono, display: "flex", gap: "8px", alignItems: "baseline", borderTop: "0.5px solid var(--dsw-alias-border-l2)", paddingTop: "4px" } },
2586
+ history.map((item, i) => h("div", { key: String(item.at || i) + i, style: { ...mono, display: "flex", gap: "8px", alignItems: "baseline", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", paddingTop: "4px" } },
2154
2587
  h("span", { style: { flex: "1 1 auto" } },
2155
2588
  "[" + (item.kind || "?") + "] " + (item.name || item.pack || "") + " · " + when(item.at) + (item.size ? " · " + bytes(item.size) : "") + (item.ok === false ? " · 失败" : "")),
2156
2589
  h("button", {
@@ -2162,14 +2595,14 @@ window.__ModuleLoader__.load({
2162
2595
  h("div", { style: row },
2163
2596
  h("button", { type: "button", style: btn, onClick: () => dropHistory(null, true) }, "清空记录"),
2164
2597
  historyMsg ? h("span", { style: hint }, historyMsg) : null))),
2165
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2598
+ h("div", { id: "mp-set-place", style: settingsCard },
2166
2599
  h("div", { style: strong }, "显示位置"),
2167
2600
  h("div", { style: hint }, "三处互相独立,一点就生效,不用重启。关掉只是不挂载入口,功能与接口都还在。至少留一处:只剩一个时,那个开关会变灰、点不动。"),
2168
2601
  h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
2169
2602
  h(Switch, { checked: cfg.showInSettings !== false, disabled: placementLocked("showInSettings"), label: "在设置里显示(插件设置页内一栏「整合包」)" + (placementLocked("showInSettings") ? "(最后剩这一个,不能关)" : ""), onChange: (v) => savePlacement("showInSettings", v) }),
2170
2603
  h(Switch, { checked: cfg.showInSidebar !== false, disabled: placementLocked("showInSidebar"), label: "在侧边栏显示(左侧栏「整合包」入口)" + (placementLocked("showInSidebar") ? "(最后剩这一个,不能关)" : ""), onChange: (v) => savePlacement("showInSidebar", v) }),
2171
2604
  h(Switch, { checked: cfg.showInPluginsTab === true, disabled: placementLocked("showInPluginsTab"), label: "在插件页内显示(与插件市场同一位置,单开一栏「整合包」)" + (placementLocked("showInPluginsTab") ? "(最后剩这一个,不能关)" : ""), onChange: (v) => savePlacement("showInPluginsTab", v) })),
2172
- h("div", { style: { ...hint, borderTop: "0.5px solid var(--dsw-alias-border-l2)", paddingTop: "8px", marginTop: "2px" } }, "插件市场自己那一行(与上面整合包的入口无关):"),
2605
+ h("div", { style: { ...hint, borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", paddingTop: "8px", marginTop: "2px" } }, "插件市场自己那一行(与上面整合包的入口无关):"),
2173
2606
  h(Switch, {
2174
2607
  checked: cfg.forceHideMarketSidebar === true,
2175
2608
  label: "强制关闭侧栏里的插件市场显示",
@@ -2179,8 +2612,9 @@ window.__ModuleLoader__.load({
2179
2612
  h("div", { style: hint }, "只关市场自己的,不动整合包:改的是它存在 .dsh-market/state.json 里的 sidebarEntry,不动它的安装,也不动整合包的入口。"),
2180
2613
  marketSidebarMsg ? h("div", { style: hint }, marketSidebarMsg) : null,
2181
2614
  saved ? h("span", { style: hint }, saved) : null),
2182
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2615
+ h("div", { id: "mp-set-market", style: settingsCard },
2183
2616
  h("div", { style: strong }, "社区资源(附属功能)"),
2617
+ h("div", { style: hint }, "这是「整合包」的附属小插件:自己一层代码(community/)、自己一套接口;关掉只是把它的接口和这一栏一起下线,打包/安装/进度窗都不受影响。"),
2184
2618
  h(Switch, {
2185
2619
  checked: cfg.showModpackMarket !== false,
2186
2620
  label: "显示「社区资源」这一栏",
@@ -2192,8 +2626,38 @@ window.__ModuleLoader__.load({
2192
2626
  h("span", { style: label }, "自动更新(小时)"),
2193
2627
  h("input", { style: { ...input, width: "78px" }, type: "number", min: "1", max: "168", value: cfg.modpackRefreshHours || 24, onChange: (e) => setField("modpackRefreshHours", Number(e.target.value)) }),
2194
2628
  h("button", { style: btn, disabled: busy, onClick: () => patch({ modpackRefreshHours: cfg.modpackRefreshHours }) }, "保存")),
2629
+ h("div", { style: { ...hint, borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", paddingTop: "8px", marginTop: "2px" } }, "下载与安装包:"),
2630
+ h(Switch, {
2631
+ checked: cfg.autoClearPack === true,
2632
+ label: "装完自动清除安装包(默认关闭)",
2633
+ title: "只删插件自己 packs 目录里、由社区下载留下的那份 .dshpack;别处的文件不碰",
2634
+ onChange: (v) => patch({ autoClearPack: v }),
2635
+ }),
2636
+ h("div", { style: row },
2637
+ h("button", { type: "button", style: btn, disabled: busy, onClick: openPackFolder }, "打开整合包下载文件夹"),
2638
+ h("span", { style: hint }, packsDirLine || "")),
2195
2639
  h("div", { style: hint }, "搜索、分类、详情与下载码都在「社区资源」那一栏里;上传方式与规则点那一栏右上角。")),
2196
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2640
+ h("div", { id: "mp-set-sub", style: settingsCard },
2641
+ h("div", { style: strong }, "附属小插件"),
2642
+ h("div", { style: hint }, "「整合包」下面挂着几个能单独关掉的小插件。每个都有自己一层代码和自己的接口清单:关掉只下线它,打包、安装、进度窗都不受影响。下面按「属于 dsh-modpack-kit › 名字」标清谁是谁。"),
2643
+ h(Switch, {
2644
+ checked: cfg.showSubplugins !== false,
2645
+ label: "在这里显示附属小插件清单",
2646
+ title: "关掉只是不列出来,不改变任何一个小插件的实际开关",
2647
+ onChange: (v) => patch({ showSubplugins: v }),
2648
+ }),
2649
+ cfg.showSubplugins === false
2650
+ ? h("div", { style: hint }, "已隐藏。打开上面这个开关,才会列出本插件下面有哪些附属小插件。")
2651
+ : h(SubpluginList, {
2652
+ status: props.status,
2653
+ native: theme.id === "native",
2654
+ onToggle: (sub, value) => {
2655
+ if (!sub || !sub.configKey) return
2656
+ patch({ [sub.configKey]: value })
2657
+ },
2658
+ onOpenTree: props.onOpenTree,
2659
+ })),
2660
+ h("div", { id: "mp-set-catalog", style: settingsCard },
2197
2661
  h("div", { style: strong }, "插件目录(分类 · 搜索 · 分页)"),
2198
2662
  h("div", { style: hint }, (() => {
2199
2663
  const c = props.status && props.status.catalog
@@ -2211,6 +2675,561 @@ window.__ModuleLoader__.load({
2211
2675
  )
2212
2676
  }
2213
2677
 
2678
+ // ===== [区块] 附属小插件:设置里的清单卡(属于谁、几条接口、开关)=====
2679
+ // 每个附属小插件都是自己一层代码(community/、annotate/、plugin-tree/):卡片只负责把「它属于主体」说清楚,
2680
+ // 开关回写的是设置里的 configKey,关掉后 host 那边整层 404(这里不做假隐藏)。
2681
+ function subTone(sub, props) {
2682
+ const id = String((sub && sub.id) || "")
2683
+ // 原生模式下不硬塞自己的颜色:圆点跟宿主次要文字色,卡片本身就吃 HOST_VARS
2684
+ if (props && props.native) return "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))"
2685
+ if (id.indexOf("community") >= 0) return "var(--mp-ok, var(--dsw-alias-state-success-primary, #3AA675))"
2686
+ if (id.indexOf("annotate") >= 0) return "var(--mp-accent, #8B5CF6)"
2687
+ return "var(--mp-primary, #4C7DF0)"
2688
+ }
2689
+
2690
+ function SubpluginCard(props) {
2691
+ const sub = props.sub || {}
2692
+ const [open, setOpen] = useState(false)
2693
+ const [busy, setBusy] = useState(false)
2694
+ const [note, setNote] = useState("")
2695
+ const [bad, setBad] = useState("")
2696
+ const routes = Array.isArray(sub.routes) ? sub.routes : []
2697
+ const enabled = sub.enabled !== false
2698
+ const check = async () => {
2699
+ setBusy(true); setBad(""); setNote("")
2700
+ try {
2701
+ const data = await api("/annotate/check", {})
2702
+ setNote("检查了 " + Number(data.checked || 0) + " 个文件:已标注 " + Number(data.annotated || 0) + " 个,缺 " + ((data.missing || []).length) + " 个" + (data.passed ? ",全部合格" : ""))
2703
+ if (!data.passed) setBad((data.problems || []).slice(0, 8).map((p) => (p.file || "?") + ":" + (p.reason || "")).join("\n"))
2704
+ } catch (e) {
2705
+ setBad(e && e.message ? e.message : String(e))
2706
+ } finally {
2707
+ setBusy(false)
2708
+ }
2709
+ }
2710
+ return h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "6px" } },
2711
+ h("div", { style: row },
2712
+ h("span", { style: { width: "8px", height: "8px", borderRadius: "999px", flex: "0 0 auto", background: subTone(sub, props) } }),
2713
+ h("span", { style: strong }, sub.label || sub.id || "附属小插件"),
2714
+ h("span", { style: { ...mono, color: "var(--mp-muted, var(--dsw-alias-label-tertiary))" } }, sub.id || ""),
2715
+ h("span", { style: chip }, "apiVersion " + (sub.apiVersion || 1)),
2716
+ h("span", { style: chip }, sub.mode === "external" ? "外部实现" : "内置"),
2717
+ h("span", { style: chip }, sub.standalone ? "可独立运行" : "随主体运行"),
2718
+ h("span", { style: chip }, routes.length + " 条接口"),
2719
+ h("span", { style: { ...hint, marginLeft: "auto" } }, "属于 dsh-modpack-kit › " + (sub.label || sub.id || ""))),
2720
+ sub.note ? h("div", { style: hint }, sub.note) : null,
2721
+ h("div", { style: row },
2722
+ sub.configKey
2723
+ ? h(Switch, {
2724
+ checked: enabled,
2725
+ label: enabled ? "已启用" : "已关闭",
2726
+ title: "关掉只下线这一个附属小插件的接口与界面,打包/安装/进度窗照常",
2727
+ onChange: (v) => props.onToggle(v),
2728
+ })
2729
+ : h("span", { style: hint }, "常开(不单独给开关)"),
2730
+ routes.length ? h("button", { type: "button", style: chipBtn, onClick: () => setOpen(!open) }, open ? "收起接口" : "看 " + routes.length + " 条接口") : null,
2731
+ sub.id === "dsh-modpack-annotate" ? h("button", { type: "button", style: chipBtn, disabled: busy, onClick: check }, busy ? "自检中…" : "自检标注") : null,
2732
+ sub.id === "dsh-modpack-plugin-tree" ? h("button", { type: "button", style: chipBtn, onClick: props.onOpenTree }, "打开插件树") : null),
2733
+ open && routes.length
2734
+ ? h("div", { style: { display: "flex", flexDirection: "column", gap: "2px" } },
2735
+ routes.map((r) => h("div", { key: r, style: { ...mono, color: "var(--mp-muted, var(--dsw-alias-label-secondary))" } }, String(r))))
2736
+ : null,
2737
+ note ? h("div", { style: hint }, note) : null,
2738
+ bad ? h("div", { style: { ...mono, whiteSpace: "pre-wrap", color: "var(--mp-danger, #ff6b6b)" } }, bad) : null)
2739
+ }
2740
+
2741
+ function SubpluginList(props) {
2742
+ const subs = (props.status && Array.isArray(props.status.subplugins)) ? props.status.subplugins : []
2743
+ if (!subs.length) return h("div", { style: hint }, "当前运行的 DSH 还没加载附属小插件清单(重启一次 DSH 后再看)。")
2744
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
2745
+ subs.map((sub) => h(SubpluginCard, { key: sub.id, sub, native: props.native === true, onToggle: (v) => props.onToggle(sub, v), onOpenTree: props.onOpenTree })))
2746
+ }
2747
+
2748
+ // 插件树:根不是「整合包」,而是你自己勾的那些插件——看它们的依赖、被依赖、peers 与兼容判定。
2749
+ // 布局照 AE2 的配方树:SVG 分列、滚轮围绕鼠标缩放、按住空白拖动,点节点看详情。
2750
+ const TREE_NODE_W = 190
2751
+ const TREE_NODE_H = 56
2752
+ const TREE_COL = 340
2753
+ const TREE_ROW = 86
2754
+ const TREE_KIND_COLOR = { plugin: "var(--mp-primary, #4C7DF0)", dep: "var(--mp-warn, #B08900)", peer: "var(--mp-accent, #8B5CF6)", user: "var(--mp-ok, var(--dsw-alias-state-success-primary, #3AA675))", subplugin: "var(--mp-accent, #8B5CF6)", route: "var(--mp-ok, var(--dsw-alias-state-success-primary, #3AA675))", main: "var(--mp-primary, #4C7DF0)", ok: "var(--mp-ok, var(--dsw-alias-state-success-primary, #3AA675))", warn: "var(--mp-warn, #E0771B)", unknown: "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))" }
2755
+ const TREE_KIND_TEXT = { plugin: "插件", dep: "依赖", peer: "版本要求", user: "被谁用", subplugin: "附属小插件", route: "接口" }
2756
+ const TREE_VERDICT_TEXT = { ok: "兼容", warn: "可能不兼容", unknown: "看不出来" }
2757
+
2758
+ // 折叠:从勾中的插件往外走,一步以内总是可见,再深要它自己展开过。
2759
+ function treeFolds(nodes, edges, roots, expanded) {
2760
+ const list = Array.isArray(nodes) ? nodes : []
2761
+ const link = Array.isArray(edges) ? edges : []
2762
+ const rootIds = Array.isArray(roots) ? roots.filter((id) => list.some((node) => node.id === id)) : []
2763
+ const neighbors = new Map()
2764
+ // 「共享 ×N」按「有几个不同的来源要它」算,不是数边——一个插件要 15 个前置,
2765
+ // 是它自己有 15 个前置,不是这 15 个都被共享了。
2766
+ const sources = new Map()
2767
+ for (const edge of link) {
2768
+ if (!neighbors.has(edge.from)) neighbors.set(edge.from, [])
2769
+ neighbors.get(edge.from).push(edge.to)
2770
+ if (!neighbors.has(edge.to)) neighbors.set(edge.to, [])
2771
+ neighbors.get(edge.to).push(edge.from)
2772
+ if (!sources.has(edge.to)) sources.set(edge.to, new Set())
2773
+ sources.get(edge.to).add(edge.from)
2774
+ }
2775
+ const shareCount = new Map()
2776
+ for (const [id, set] of sources) if (set.size > 1) shareCount.set(id, set.size)
2777
+ const ring = new Map(rootIds.map((id) => [id, 0]))
2778
+ const queue = rootIds.slice()
2779
+ while (queue.length) {
2780
+ const id = queue.shift()
2781
+ for (const next of neighbors.get(id) || []) {
2782
+ if (ring.has(next)) continue
2783
+ ring.set(next, (ring.get(id) || 0) + 1)
2784
+ queue.push(next)
2785
+ }
2786
+ }
2787
+ const visible = new Set(rootIds)
2788
+ const expandQueue = rootIds.slice()
2789
+ while (expandQueue.length) {
2790
+ const id = expandQueue.shift()
2791
+ if ((ring.get(id) || 0) >= 1 && (!expanded || expanded[id] !== true)) continue
2792
+ for (const next of neighbors.get(id) || []) {
2793
+ if (visible.has(next)) continue
2794
+ visible.add(next)
2795
+ expandQueue.push(next)
2796
+ }
2797
+ }
2798
+ const canExpand = (id) => (neighbors.get(id) || []).some((next) => !visible.has(next))
2799
+ return { visible, ring, shareCount, neighbors, canExpand, rootIds }
2800
+ }
2801
+
2802
+ // 固定某些节点后,只保留「它们 + 全部祖先 + 全部后代」这条线
2803
+ function treeRelated(edges, pinned) {
2804
+ const link = Array.isArray(edges) ? edges : []
2805
+ const picks = Array.isArray(pinned) ? pinned : []
2806
+ const byFrom = new Map()
2807
+ const byTo = new Map()
2808
+ for (const edge of link) {
2809
+ if (!byFrom.has(edge.from)) byFrom.set(edge.from, [])
2810
+ byFrom.get(edge.from).push(edge.to)
2811
+ if (!byTo.has(edge.to)) byTo.set(edge.to, [])
2812
+ byTo.get(edge.to).push(edge.from)
2813
+ }
2814
+ const related = new Set()
2815
+ const climb = (start, map) => {
2816
+ const stack = (map.get(start) || []).slice()
2817
+ while (stack.length) {
2818
+ const id = stack.pop()
2819
+ if (related.has(id)) continue
2820
+ related.add(id)
2821
+ for (const next of map.get(id) || []) stack.push(next)
2822
+ }
2823
+ }
2824
+ for (const id of picks) {
2825
+ related.add(id)
2826
+ climb(id, byTo)
2827
+ climb(id, byFrom)
2828
+ }
2829
+ return related
2830
+ }
2831
+
2832
+ // 布局按「关系方向」分列,而不是按离根几步:
2833
+ // 第 0 列 = 它自己要的东西(依赖 / 版本要求),第 1 列 = 勾中的插件,第 2 列 = 要它的(插件 / 接口)。
2834
+ // 同一列里先按「父节点排到第几行」取平均,再把没算出来的按名字补在末尾,保证勾选变化时顺序不乱跳。
2835
+ const TREE_COL_OF_KIND = { dep: 0, peer: 0, plugin: 1, main: 1, user: 2, route: 2, subplugin: 2 }
2836
+
2837
+ function treeLayout(nodes, edges, roots) {
2838
+ const list = Array.isArray(nodes) ? nodes : []
2839
+ const link = Array.isArray(edges) ? edges.filter((edge) => list.some((n) => n.id === edge.from) && list.some((n) => n.id === edge.to)) : []
2840
+ const rootIds = Array.isArray(roots) && roots.length ? roots : list.filter((node) => node.kind === "plugin" || node.kind === "main").map((node) => node.id)
2841
+ const col = new Map()
2842
+ for (const node of list) {
2843
+ const fallback = TREE_COL_OF_KIND[node.kind] === undefined ? 1 : TREE_COL_OF_KIND[node.kind]
2844
+ col.set(node.id, rootIds.includes(node.id) ? 1 : fallback)
2845
+ }
2846
+ // 勾中的插件在中间:它要的排第 0 列,要它的排第 2 列(node.kind 已经这么标了,这里只兜底)
2847
+ const placed = new Map()
2848
+ const byCol = new Map([[0, []], [1, []], [2, []], [3, []]])
2849
+ for (const node of list) {
2850
+ // 注意别用 `col.get(id) || 1`:第 0 列是合法值,会被 || 吃掉变成 1
2851
+ const rawCol = col.has(node.id) ? col.get(node.id) : 1
2852
+ const c = Math.max(0, Math.min(3, rawCol))
2853
+ byCol.get(c).push(node)
2854
+ }
2855
+ const yOf = new Map()
2856
+ const cols = [...byCol.keys()].filter((c) => byCol.get(c).length).sort((a, b) => a - b)
2857
+ for (const c of cols) {
2858
+ const items = byCol.get(c)
2859
+ const bary = new Map()
2860
+ for (const node of items) {
2861
+ const around = link.filter((edge) => edge.to === node.id || edge.from === node.id)
2862
+ .map((edge) => yOf.get(edge.to === node.id ? edge.from : edge.to))
2863
+ .filter((value) => typeof value === "number")
2864
+ bary.set(node.id, around.length ? around.reduce((sum, v) => sum + v, 0) / around.length : Number.MAX_SAFE_INTEGER)
2865
+ }
2866
+ items.sort((a, b) => {
2867
+ const delta = (bary.get(a.id) || 0) - (bary.get(b.id) || 0)
2868
+ if (Math.abs(delta) > 0.5) return delta
2869
+ return String(a.label || a.id).localeCompare(String(b.label || b.id), "zh")
2870
+ })
2871
+ let y = 24
2872
+ for (const node of items) {
2873
+ placed.set(node.id, { x: 24 + c * TREE_COL, y, node })
2874
+ yOf.set(node.id, y)
2875
+ y += TREE_ROW
2876
+ }
2877
+ }
2878
+ return { placed, cols, rootIds }
2879
+ }
2880
+
2881
+ // 名字用「中间省略」:长名字前面几个字都一样(dsh-plugin-wallpaper-…)时,
2882
+ // 砍尾巴会砍成一排相同的盒子,留头留尾才分得清是哪个。
2883
+ function treeEllipsis(text, max) {
2884
+ const value = String(text === undefined || text === null ? "" : text)
2885
+ const chars = Array.from(value)
2886
+ if (chars.length <= max) return value
2887
+ const keep = Math.max(2, max - 1)
2888
+ const head = Math.ceil(keep / 2)
2889
+ const tail = Math.floor(keep / 2)
2890
+ return chars.slice(0, head).join("") + "…" + chars.slice(chars.length - tail).join("")
2891
+ }
2892
+
2893
+ function treeCut(text, max) {
2894
+ const value = String(text === undefined || text === null ? "" : text)
2895
+ const chars = Array.from(value)
2896
+ return chars.length > max ? chars.slice(0, max - 1).join("") + "…" : value
2897
+ }
2898
+
2899
+ // 勾选哪些插件要看哪棵树:勾选结果留在 managerUi 里,关掉浮层再打开还在
2900
+ const treeUi = { value: { picked: [], query: "", view: "plugin", expanded: {}, pinned: [], onlyIssues: false, linesOnTop: false } }
2901
+
2902
+ function PluginTreeOverlay(props) {
2903
+ const initial = treeUi.value || { picked: [], query: "", view: "plugin" }
2904
+ const [kind, setKind] = useState(initial.view === "compat" ? "compat" : "plugin")
2905
+ const [picked, setPicked] = useState(Array.isArray(initial.picked) ? initial.picked : [])
2906
+ const [pickQuery, setPickQuery] = useState(initial.query || "")
2907
+ const [candidates, setCandidates] = useState(null)
2908
+ const [data, setData] = useState(null)
2909
+ const [busy, setBusy] = useState(false)
2910
+ const [error, setError] = useState("")
2911
+ const [view, setView] = useState({ x: 150, y: 320, k: 1 })
2912
+ const [active, setActive] = useState("")
2913
+ const [showRoutes, setShowRoutes] = useState(false)
2914
+ const [expanded, setExpanded] = useState(initial.expanded && typeof initial.expanded === "object" ? initial.expanded : {})
2915
+ const [pinned, setPinned] = useState(Array.isArray(initial.pinned) ? initial.pinned : [])
2916
+ const [onlyIssues, setOnlyIssues] = useState(initial.onlyIssues === true)
2917
+ const [linesOnTop, setLinesOnTop] = useState(initial.linesOnTop === true)
2918
+ const [query, setQuery] = useState("")
2919
+ const holder = useRef(null)
2920
+ const drag = useRef(null)
2921
+
2922
+ useEffect(() => { treeUi.value = { picked, query: pickQuery, view: kind, expanded, pinned, onlyIssues, linesOnTop } }, [picked, pickQuery, kind, expanded, pinned, onlyIssues, linesOnTop])
2923
+
2924
+ // 先拿候选:已装的 + 市场里支持的(都是只读声明,不联网)
2925
+ useEffect(() => {
2926
+ let alive = true
2927
+ ;(async () => {
2928
+ try {
2929
+ const next = await api("/tree/plugins")
2930
+ if (!alive) return
2931
+ setCandidates(next)
2932
+ if (!picked.length) {
2933
+ const self = (next.items || []).find((item) => item.self) || (next.items || [])[0]
2934
+ if (self) setPicked([self.name])
2935
+ }
2936
+ } catch (e) {
2937
+ if (alive) setError(String((e && e.message) || e))
2938
+ }
2939
+ })()
2940
+ return () => { alive = false }
2941
+ }, [])
2942
+
2943
+ const load = useCallback(async (which, names) => {
2944
+ if (!names || !names.length) { setData(null); return }
2945
+ setBusy(true); setError("")
2946
+ try {
2947
+ const path = "/tree/" + (which === "compat" ? "compat" : "plugin") + "?names=" + encodeURIComponent(names.join(","))
2948
+ const next = await api(path)
2949
+ setData(next)
2950
+ setActive("")
2951
+ } catch (e) {
2952
+ setError(e && e.message ? e.message : String(e))
2953
+ } finally {
2954
+ setBusy(false)
2955
+ }
2956
+ }, [])
2957
+
2958
+ useEffect(() => { load(kind, picked) }, [kind, picked, load])
2959
+
2960
+ // wheel 要 preventDefault 才能拦住页面滚动,React 的 onWheel 是 passive,只能自己挂
2961
+ useEffect(() => {
2962
+ const node = holder.current
2963
+ if (!node) return undefined
2964
+ const onWheel = (event) => {
2965
+ event.preventDefault()
2966
+ const rect = node.getBoundingClientRect()
2967
+ setView((prev) => {
2968
+ const factor = Math.exp(-event.deltaY * 0.0015)
2969
+ const k = Math.min(2.5, Math.max(0.35, prev.k * factor))
2970
+ const px = event.clientX - rect.left
2971
+ const py = event.clientY - rect.top
2972
+ const ratio = k / prev.k
2973
+ return { k, x: px - (px - prev.x) * ratio, y: py - (py - prev.y) * ratio }
2974
+ })
2975
+ }
2976
+ node.addEventListener("wheel", onWheel, { passive: false })
2977
+ return () => node.removeEventListener("wheel", onWheel)
2978
+ }, [])
2979
+
2980
+ const zoom = (factor) => setView((prev) => {
2981
+ const k = Math.min(2.5, Math.max(0.35, prev.k * factor))
2982
+ const ratio = k / prev.k
2983
+ const px = 460
2984
+ const py = 300
2985
+ return { k, x: px - (px - prev.x) * ratio, y: py - (py - prev.y) * ratio }
2986
+ })
2987
+
2988
+ const onPointerDown = (event) => {
2989
+ if (event.button !== 0) return
2990
+ drag.current = { sx: event.clientX, sy: event.clientY, vx: view.x, vy: view.y, moved: false }
2991
+ if (event.target && event.target.setPointerCapture) { try { event.target.setPointerCapture(event.pointerId) } catch (e) { /* 捕获失败不影响拖动 */ } }
2992
+ }
2993
+ const onPointerMove = (event) => {
2994
+ const state = drag.current
2995
+ if (!state) return
2996
+ const dx = event.clientX - state.sx
2997
+ const dy = event.clientY - state.sy
2998
+ if (Math.abs(dx) + Math.abs(dy) > 3) state.moved = true
2999
+ setView((prev) => ({ ...prev, x: state.vx + dx, y: state.vy + dy }))
3000
+ }
3001
+ const onPointerUp = () => { drag.current = null }
3002
+
3003
+ const togglePick = (name) => {
3004
+ setPicked((prev) => (prev.includes(name) ? prev.filter((item) => item !== name) : prev.concat([name]).slice(0, 12)))
3005
+ }
3006
+
3007
+ // 相关性视图只留「插件 / 依赖 / 版本要求 / 被谁用」;接口那 13 个节点默认收起来,
3008
+ // 否则一屏全是 /api/…,真正想知道的前置条件被挤到看不见。
3009
+ const rawNodes = (data && Array.isArray(data.nodes)) ? data.nodes : []
3010
+ const rawEdges = (data && Array.isArray(data.edges)) ? data.edges : []
3011
+ const hideRoutes = kind !== "compat" && !showRoutes && !query.trim()
3012
+ const nodes = hideRoutes ? rawNodes.filter((node) => node.kind !== "route" && node.kind !== "subplugin") : rawNodes
3013
+ const kept = new Set(nodes.map((node) => node.id))
3014
+ const edges = hideRoutes ? rawEdges.filter((edge) => kept.has(edge.from) && kept.has(edge.to)) : rawEdges
3015
+ const rootIds = (data && Array.isArray(data.roots)) ? data.roots : []
3016
+ const folds = treeFolds(nodes, edges, rootIds, expanded)
3017
+ const visible = folds.visible
3018
+ const ring = folds.ring
3019
+ const shareCount = folds.shareCount
3020
+ const canExpand = folds.canExpand
3021
+ const shownNodes = ring.size ? nodes.filter((node) => visible.has(node.id)) : nodes
3022
+ const shownIds = new Set(shownNodes.map((node) => node.id))
3023
+ const shownEdges = edges.filter((edge) => shownIds.has(edge.from) && shownIds.has(edge.to))
3024
+ const related = treeRelated(edges, pinned)
3025
+ const layout = treeLayout(shownNodes, shownEdges, rootIds)
3026
+
3027
+ const needle = query.trim().toLowerCase()
3028
+ const hit = (node) => !needle || String(node.label || "").toLowerCase().indexOf(needle) >= 0 || String(node.id || "").toLowerCase().indexOf(needle) >= 0
3029
+ const activeNode = active ? (layout.placed.get(active) || {}).node : null
3030
+ const counts = (data && data.counts) || {}
3031
+ const all = (candidates && Array.isArray(candidates.items)) ? candidates.items : []
3032
+ const keyword = pickQuery.trim().toLowerCase()
3033
+ const listHit = (item) => !keyword || (item.name + " " + (item.title || "") + " " + (item.category || "")).toLowerCase().includes(keyword)
3034
+
3035
+ const pickRow = (item) => h("label", {
3036
+ key: "pick-" + item.name,
3037
+ style: { display: "flex", gap: "6px", alignItems: "flex-start", padding: "4px 2px", cursor: "pointer", borderRadius: "6px", background: picked.includes(item.name) ? "rgba(76,125,240,0.10)" : "transparent" },
3038
+ },
3039
+ h("input", { type: "checkbox", checked: picked.includes(item.name), onChange: () => togglePick(item.name), style: { marginTop: "2px" } }),
3040
+ h("span", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: "1px" } },
3041
+ h("span", { style: { fontSize: "12.5px", wordBreak: "break-all" } }, item.title || item.name),
3042
+ h("span", { style: { ...hint, fontSize: "11px" } },
3043
+ (item.self ? "本插件 · " : item.installed ? "已装 · " : "市场 · ") + (item.version || "?") + (item.category ? " · " + item.category : ""),
3044
+ item.installed && item.requires
3045
+ ? h("span", { style: { marginLeft: "6px", color: item.missing ? "var(--mp-warn, #E0771B)" : "var(--mp-ok, #2bb673)" } },
3046
+ "前置 " + item.requires + (item.missing ? " · 缺 " + item.missing : " · 齐"))
3047
+ : null)))
3048
+
3049
+ // 边的层级可以切到节点上面:同一个列表画两遍,靠 display 互斥,避免重排 SVG 子节点
3050
+ const edgeNode = (edge, index) => {
3051
+ const a = layout.placed.get(edge.from)
3052
+ const b = layout.placed.get(edge.to)
3053
+ if (!a || !b) return null
3054
+ // 一律「左边节点的右边 → 右边节点的左边」:依赖在左、勾中的在右时不绕到背后
3055
+ const left = a.x <= b.x ? a : b
3056
+ const right = a.x <= b.x ? b : a
3057
+ const x1 = left.x + TREE_NODE_W
3058
+ const y1 = left.y + TREE_NODE_H / 2
3059
+ const x2 = right.x
3060
+ const y2 = right.y + TREE_NODE_H / 2
3061
+ const mid = (x1 + x2) / 2
3062
+ const bad = edge.label === "不满足"
3063
+ return h("path", {
3064
+ key: "e" + index,
3065
+ d: "M" + x1 + "," + y1 + " C" + mid + "," + y1 + " " + mid + "," + y2 + " " + x2 + "," + y2,
3066
+ fill: "none",
3067
+ stroke: bad ? "var(--mp-warn, #E0771B)" : edge.kind === "requires" ? "var(--mp-warn, #B08900)" : "rgba(128,128,128,0.55)",
3068
+ strokeWidth: bad ? 2 : 1.4,
3069
+ strokeDasharray: edge.kind === "requires" || edge.kind === "uses" ? "5 4" : undefined,
3070
+ })
3071
+
3072
+ }
3073
+ const nodeNode = (node) => {
3074
+ const spot = layout.placed.get(node.id)
3075
+ if (!spot) return null
3076
+ const color = TREE_KIND_COLOR[node.kind] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))"
3077
+ const isPinned = pinned.includes(node.id)
3078
+ const keep = !pinned.length || related.has(node.id)
3079
+ const issueDim = onlyIssues && node.compat === "ok" ? 0.3 : 1
3080
+ const dim = (hit(node) ? 1 : 0.25) * (keep ? 1 : 0.2) * issueDim
3081
+ const chosen = active === node.id
3082
+ return h("g", {
3083
+ key: node.id,
3084
+ transform: "translate(" + spot.x + "," + spot.y + ")",
3085
+ style: { cursor: "pointer", opacity: dim },
3086
+ onPointerDown: (event) => event.stopPropagation(),
3087
+ onClick: () => {
3088
+ if (canExpand(node.id)) setExpanded((prev) => ({ ...prev, [node.id]: prev[node.id] !== true }))
3089
+ setActive(chosen ? "" : node.id)
3090
+ },
3091
+ },
3092
+ h("rect", { width: TREE_NODE_W, height: TREE_NODE_H, rx: 9, fill: "var(--dsw-alias-bg-base, var(--mp-on-primary, #fff))", stroke: chosen ? color : color, strokeWidth: chosen ? 2.6 : 1.4 }),
3093
+ h("rect", { width: 4, height: TREE_NODE_H, rx: 2, fill: color }),
3094
+ h("text", { x: 12, y: 21, fontSize: 12.5, fontWeight: 600, fill: "currentColor" }, treeEllipsis(node.label, 26)),
3095
+ h("text", { x: 12, y: 38, fontSize: 10, fill: "rgba(128,128,128,0.95)" }, treeEllipsis(node.sub || TREE_KIND_TEXT[node.kind] || node.kind, 30)),
3096
+ h("text", { x: 12, y: 50, fontSize: 9, fill: color },
3097
+ treeEllipsis((TREE_KIND_TEXT[node.kind] || node.kind)
3098
+ + ((shareCount.get(node.id) || 0) > 1 ? " · 共享 ×" + shareCount.get(node.id) : "")
3099
+ + (canExpand(node.id) ? (expanded[node.id] ? " · 已展开" : " · 点开") : ""), 26)),
3100
+ h("g", {
3101
+ style: { cursor: "pointer" },
3102
+ onPointerDown: (event) => event.stopPropagation(),
3103
+ onClick: (event) => {
3104
+ event.stopPropagation()
3105
+ setPinned((prev) => (prev.includes(node.id) ? prev.filter((item) => item !== node.id) : prev.concat([node.id])))
3106
+ },
3107
+ },
3108
+ h("circle", {
3109
+ cx: TREE_NODE_W - 13,
3110
+ cy: TREE_NODE_H - 13,
3111
+ r: 7,
3112
+ fill: isPinned ? "var(--mp-primary, #4C7DF0)" : "transparent",
3113
+ stroke: isPinned ? "var(--mp-primary, #4C7DF0)" : "rgba(128,128,128,0.55)",
3114
+ strokeWidth: 1.2,
3115
+ }),
3116
+ h("title", {}, isPinned ? "取消固定" : "固定它:只高亮这条线的前后关系"),
3117
+ isPinned ? h("circle", { cx: TREE_NODE_W - 13, cy: TREE_NODE_H - 13, r: 2.6, fill: "var(--mp-on-primary, #fff)" }) : null),
3118
+ node.compat && node.compat !== "ok"
3119
+ ? h("circle", { cx: TREE_NODE_W - 12, cy: 12, r: 4.5, fill: TREE_KIND_COLOR[node.compat] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))" })
3120
+ : null)
3121
+
3122
+ }
3123
+
3124
+ return h("div", { style: { position: "fixed", inset: 0, zIndex: 9999, background: "rgba(8, 10, 16, 0.55)", display: "flex", alignItems: "center", justifyContent: "center", padding: "24px" } },
3125
+ h("div", { style: { position: "relative", width: "min(1320px, 97vw)", height: "min(800px, 93vh)", background: "var(--mp-card, var(--dsw-alias-bg-base, #fff))", color: "var(--mp-text, var(--dsw-alias-label-primary))", borderRadius: "12px", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", display: "flex", flexDirection: "column", overflow: "hidden" } },
3126
+ h("div", { style: { display: "flex", alignItems: "center", gap: "10px", padding: "12px 14px", borderBottom: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", flexWrap: "wrap" } },
3127
+ h("span", { style: { fontSize: "14px", fontWeight: 600 } }, "插件树"),
3128
+ h("span", { style: hint }, "勾插件看它的相关性 · 点节点看详情 · 滚轮缩放 · 按住空白拖动"),
3129
+ h("span", { style: { ...hint, fontSize: "11px" } }, "左列=它要的、中间=勾中的、右列=要它的;蓝=插件、黄=依赖、紫=版本要求、绿=被谁用;橙边=不满足、灰点=看不出来;点节点展开下一层,右下角小圆钉住它只看这条线"),
3130
+ h("div", { style: { ...row, marginLeft: "10px" } },
3131
+ h("button", { type: "button", style: kind === "plugin" ? chipOn : chipBtn, onClick: () => setKind("plugin") }, "相关性"),
3132
+ h("button", { type: "button", style: kind === "compat" ? chipOn : chipBtn, onClick: () => setKind("compat") }, "兼容性"),
3133
+ kind === "plugin"
3134
+ ? h("button", { type: "button", style: showRoutes ? chipOn : chipBtn, title: "把附属小插件与它们各自的接口也画出来(节点会多很多)", onClick: () => setShowRoutes(!showRoutes) }, showRoutes ? "收起接口" : "显示接口")
3135
+ : null),
3136
+ h("button", { type: "button", style: onlyIssues ? chipOn : chipBtn, title: "把完全兼容的节点压淡,只留下要注意的", onClick: () => setOnlyIssues(!onlyIssues) }, onlyIssues ? "只看有问题 ✓" : "只看有问题"),
3137
+ h("button", { type: "button", style: chipBtn, title: "折回到默认的一层", onClick: () => setExpanded({}) }, "收起到一层"),
3138
+ h("button", {
3139
+ type: "button",
3140
+ style: chipBtn,
3141
+ title: "把所有节点一次展开",
3142
+ onClick: () => {
3143
+ const all = {}
3144
+ for (const node of nodes) all[node.id] = true
3145
+ setExpanded(all)
3146
+ },
3147
+ }, "全部展开"),
3148
+ pinned.length ? h("button", { type: "button", style: chipBtn, onClick: () => setPinned([]) }, "清空固定 (" + pinned.length + ")") : null,
3149
+ h("input", { style: { ...input, width: "170px", marginLeft: "auto" }, placeholder: "搜节点名或 id", value: query, onChange: (e) => setQuery(e.target.value) }),
3150
+ h("button", { type: "button", style: chipBtn, onClick: () => setView({ x: 150, y: 320, k: 1 }) }, "居中"),
3151
+ h("button", { type: "button", style: chipBtn, onClick: () => zoom(1.2) }, "放大"),
3152
+ h("button", { type: "button", style: chipBtn, onClick: () => zoom(0.8) }, "缩小"),
3153
+ h("button", { type: "button", style: chipBtn, disabled: busy, onClick: () => load(kind, picked) }, busy ? "刷新中…" : "刷新"),
3154
+ h("button", { type: "button", style: linesOnTop ? chipOn : chipBtn, title: "连线压在节点上面更清楚,压在下面不挡字", onClick: () => setLinesOnTop(!linesOnTop) }, linesOnTop ? "连线在上" : "连线在下"),
3155
+ h("button", { type: "button", style: btn, onClick: props.onClose }, "关闭")),
3156
+ h("div", { style: { flex: 1, display: "flex", minHeight: 0 } },
3157
+ h("div", { style: { width: "272px", flexShrink: 0, borderRight: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", display: "flex", flexDirection: "column", gap: "6px", padding: "10px" } },
3158
+ h("div", { style: { display: "flex", alignItems: "center", gap: "6px" } },
3159
+ h("span", { style: strong }, "要看的插件"),
3160
+ h("span", { style: hint }, "已勾 " + picked.length + (candidates ? " · 共 " + all.length : ""))),
3161
+ h("input", { type: "search", style: { ...input, width: "100%" }, placeholder: "搜插件名 / 分类", value: pickQuery, onChange: (e) => setPickQuery(e.target.value || "") }),
3162
+ h("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap" } },
3163
+ h("button", { type: "button", style: chipBtn, onClick: () => setPicked(all.filter((item) => item.installed).slice(0, 12).map((item) => item.name)) }, "勾已装(最多 12)"),
3164
+ h("button", { type: "button", style: chipBtn, onClick: () => setPicked([]) }, "清空")),
3165
+ h("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", display: "flex", flexDirection: "column", gap: "1px" } },
3166
+ !candidates
3167
+ ? h("div", { style: hint }, "读取候选…")
3168
+ : all.filter(listHit).slice(0, 300).map(pickRow)),
3169
+ h("div", { style: { ...hint, fontSize: "11px" } }, "列表 = 本机已装的插件 + 插件市场目录里支持的插件(没装的只有声明可看,兼容判定会标「看不出来」)。")),
3170
+ h("div", {
3171
+ ref: holder,
3172
+ style: { flex: 1, minWidth: 0, cursor: "grab", touchAction: "none", backgroundImage: "radial-gradient(circle, rgba(128,128,128,0.18) 1px, transparent 1px)", backgroundSize: "22px 22px" },
3173
+ onPointerDown,
3174
+ onPointerMove,
3175
+ onPointerUp,
3176
+ onPointerLeave: onPointerUp,
3177
+ },
3178
+ error
3179
+ ? h("div", { style: { padding: "16px", color: "var(--mp-danger, #ff6b6b)", ...mono } }, error)
3180
+ : !picked.length
3181
+ ? h("div", { style: { padding: "18px", ...hint } }, "左边勾一个插件,这里就会出现它跟别人的关系。")
3182
+ : h("svg", { style: { width: "100%", height: "100%", display: "block" } },
3183
+ h("g", { transform: "translate(" + view.x + "," + view.y + ") scale(" + view.k + ")" },
3184
+ h("g", { key: "edges-under", style: { display: linesOnTop ? "none" : "inline" } }, edges.map(edgeNode)),
3185
+ nodes.map(nodeNode),
3186
+ h("g", { key: "edges-over", style: { display: linesOnTop ? "inline" : "none" } }, edges.map(edgeNode)))),),
3187
+ activeNode
3188
+ ? h("div", { style: { width: "268px", borderLeft: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", padding: "12px", display: "flex", flexDirection: "column", gap: "6px", overflowY: "auto" } },
3189
+ h("div", { style: strong }, activeNode.label || activeNode.id),
3190
+ h("div", { style: { ...mono, color: "var(--mp-muted, var(--dsw-alias-label-tertiary))", wordBreak: "break-all" } }, activeNode.id || ""),
3191
+ h("div", { style: row },
3192
+ h("span", { style: chip }, TREE_KIND_TEXT[activeNode.kind] || activeNode.kind || "节点"),
3193
+ activeNode.compat ? h("span", { style: { ...chip, borderColor: TREE_KIND_COLOR[activeNode.compat] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))", color: TREE_KIND_COLOR[activeNode.compat] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #8a8f98))" } }, TREE_VERDICT_TEXT[activeNode.compat] || activeNode.compat) : null,
3194
+ activeNode.version ? h("span", { style: chip }, String(activeNode.version)) : null),
3195
+ // 右侧按「谁要什么 → 本机有没有 → 从哪条线过来」排:
3196
+ // 前五行是读一条关系必须看到的,后面(简介 / 目录 / 判定…)算补充,压淡。
3197
+ (() => {
3198
+ const detail = activeNode.detail || {}
3199
+ const keyOrder = ["版本要求", "要求方", "已装版本", "树来源", "是否安装"]
3200
+ const keyRows = keyOrder.filter((key) => detail[key] !== undefined).map((key) => {
3201
+ const value = String(detail[key])
3202
+ const color = key === "是否安装" ? (value === "是" ? "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" : "var(--mp-muted, var(--dsw-alias-label-tertiary))") : key === "版本要求" && value !== "无来源" ? "var(--mp-primary, #4C7DF0)" : undefined
3203
+ return h("div", { key: "k-" + key, style: { display: "flex", gap: "8px", alignItems: "baseline", lineHeight: "18px" } },
3204
+ h("span", { style: { ...hint, minWidth: "58px", flexShrink: 0 } }, key),
3205
+ h("span", { style: { fontSize: "12px", fontWeight: key === "是否安装" || key === "已装版本" ? 600 : 500, color, wordBreak: "break-all" } }, value))
3206
+ })
3207
+ const others = Object.entries(detail).filter(([key, value]) => !keyOrder.includes(key) && value !== "" && value !== null && value !== undefined)
3208
+ return [
3209
+ keyRows.length ? h("div", { key: "keyrows", style: { display: "flex", flexDirection: "column", gap: "3px", padding: "8px 9px", borderRadius: "8px", border: "0.5px solid var(--mp-line, var(--mp-line, var(--dsw-alias-border-l2)))", background: "var(--mp-hover, rgba(128,128,128,0.06))" } }, keyRows) : null,
3210
+ others.length
3211
+ ? h("div", { key: "others", style: { display: "flex", flexDirection: "column", gap: "3px" } },
3212
+ others.map(([key, value]) => h("div", { key: "d-" + key, style: { display: "flex", gap: "6px", alignItems: "baseline" } },
3213
+ h("span", { style: { ...hint, minWidth: "58px", flexShrink: 0 } }, key),
3214
+ h("span", { style: { fontSize: "11.5px", color: "var(--mp-muted, var(--dsw-alias-label-secondary))", wordBreak: "break-all" } }, String(value)))))
3215
+ : null,
3216
+ ]
3217
+ })(),
3218
+ h("div", { style: { ...hint, borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", paddingTop: "6px" } },
3219
+ "连出去 " + edges.filter((edge) => edge.from === activeNode.id).length + " 条 · 连进来 " + edges.filter((edge) => edge.to === activeNode.id).length + " 条"))
3220
+ : null),
3221
+ h("div", { style: { display: "flex", alignItems: "center", gap: "12px", padding: "8px 14px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", flexWrap: "wrap" } },
3222
+ h("span", { style: hint }, "插件 " + Number(counts.plugins || picked.length) + " · 节点 " + nodes.length + " · 边 " + edges.length),
3223
+ h("span", { style: hint }, "缩放 " + Math.round(view.k * 100) + "%"),
3224
+ ["plugin", "dep", "peer", "user", "subplugin", "route"].map((key) => h("span", { key: "lg-" + key, style: { ...hint, display: "inline-flex", alignItems: "center", gap: "5px" } },
3225
+ h("span", { style: { width: "9px", height: "9px", borderRadius: "3px", background: TREE_KIND_COLOR[key], display: "inline-block" } }),
3226
+ TREE_KIND_TEXT[key])),
3227
+ kind === "compat"
3228
+ ? h("span", { style: hint }, "兼容 " + Number(counts.ok || 0) + " · 可能不兼容 " + Number(counts.warn || 0) + " · 看不出来 " + Number(counts.unknown || 0))
3229
+ : Number(counts.warn || 0) > 0 ? h("span", { style: { ...hint, color: "var(--mp-warn, #E0771B)" } }, "有 " + counts.warn + " 处版本要求对不上(点橙色节点看原因)") : null,
3230
+ h("span", { style: { ...hint, marginLeft: "auto" } }, "来源:插件的 package.json 声明(依赖、peerDependencies、engines 与 dsh 清单)"))))
3231
+ }
3232
+
2214
3233
  // —— 社区资源 ——
2215
3234
  // 「从市场下载」到「安装页」之间只有一次交接:市场负责下载、校验、把 token 递过去,
2216
3235
  // 识别 / 扫描 / 兼容 / 许可证 / 安装这些仍然由安装页那条老路做,不另起一套。
@@ -2231,23 +3250,448 @@ window.__ModuleLoader__.load({
2231
3250
 
2232
3251
  const MARKET_SORTS = [["new", "最新"], ["downloads", "下载量"], ["size", "体积"], ["name", "名称"]]
2233
3252
  const MARKET_RULES = [
2234
- "只收轻量包(strategy: lite):只记插件名与版本、不带插件本体,十几 KB;装的人联网按版本取包。",
2235
- "第 1 步:在本插件「打包」页选「轻量包」、勾插件、打包并下载成 <名字>-<日期>-lite.dshpack。",
2236
- "第 2 步:算 sha256(Windows:certutil -hashfile 名字.dshpack SHA256;macOS/Linux:shasum -a 256 名字.dshpack),再记下字节数(≤ 64 MB)。",
2237
- "第 3 步:fork github.com/Vesna-Strivozha-cn/dsh-modpack-catalog,切一个分支,把包放进 packs/,再写一份 data/packs/<id>.json(只写 id、类型、文件名、sha256、日期)。",
2238
- "第 4 步:本地跑 node scripts/build.mjs,看到「packs.json: N 个整合包」才算过;报「构建失败」按提示改(多半是 sha256/size 对不上或分类写错)。",
2239
- "第 5 步:提交、push、开 PR;CI 会重跑构建,合并后每天 03:17 UTC 自动重建目录,也可以在 Actions 里手动 Run workflow 立刻扫一轮。",
2240
- "条目里不要写介绍、名称、作者、插件清单:目录直接显示包内 dsh-modpack.json(也就是打包那一刻填的内容),写了两边会不一致,构建会挡下。",
2241
- "包内插件可以不写死版本:清单里写 { \"name\": \"dsh-context\", \"latest\": true },安装时按名字取市场最新版(插件市场认市场版);写 version 就必须是 x.y.z。",
3253
+ "两条提交方式,内容一样:插件里一键上传(不用命令行),或者自己 fork 提 PR。",
3254
+ "只收两种包:轻量包(lite,只记版本、十几 KB,装的人联网按版本取)与混合包(hybrid,部分插件连本体一起带走,常见几十 MB)。完整包(full)不收,请自己放发布页。",
3255
+ "清单里的 customization 是必填项:轻量包写 none(词条「无修改」),混合包写 custom(词条「有自定义」)。填的和包里的 format 对不上,构建会挡下。",
3256
+ "方式一·第 1 步:社区资源 → 整合包 → 上传我的整合包,填一次自己的 GitHub token(classic 勾 repo;fine-grained 给 contents 与 pull requests 读写)。凭据只在内存里,离开上传页或上传结束就清掉,下次重填。",
3257
+ "方式一·第 2 步:选包(选择文件… 或 浏览文件夹…);可以顺手改名称 / 作者 / 简介 / 主页——改了会写回包内清单并重算 sha256。",
3258
+ "方式一·第 3 步:封面可选。选图后在框里拖动、缩放,挑出要的那块;输出 256×256 或 512×512,只上传框里那一块(PNG,300 KB 以内),存成 covers/<id>.png。",
3259
+ "方式一·第 4 步:选放哪——放进目录仓库(插件算 sha256、写条目、fork 本仓库、开 PR,一次带包 + 条目 + 可选封面);或者放进我的 Release(包传到你自己的 Release 资产,条目写 host: release、repo、tag,目录读资产的 download_count,列表能显示真实下载量)。",
3260
+ "方式一·第 5 步:提交是后台任务,进度在左下角悬浮窗;完成给「打开 PR #N」,出错给「我已知晓」。合并后每天一轮或手动 Run workflow。",
3261
+ "方式二·手动:打包页出包 → 算 sha256(Windows:certutil -hashfile 名字.dshpack SHA256;macOS/Linux:shasum -a 256)与字节数(≤ 64 MB)→ fork 本仓库、切分支 → 把包放 packs/、写 data/packs/<id>.json、封面放 covers/ → 本地 node scripts/build.mjs → 提 PR;合并后每天 03:17 UTC 自动重建,也可以在 Actions 里 Run workflow 立刻扫一轮。",
3262
+ "条目只写定位:id、category、customization、file、sha256、size、createdAt、updatedAt、homepage,可选 cover、repo、host、tag。条目里不要写介绍、名称、作者、插件清单——目录直接显示包内 dsh-modpack.json(打包那一刻填的内容),写了两边会不一致,构建会挡下。",
3263
+ "封面可选:png/jpg,≤ 300 KB,建议正方形;没有封面时列表显示分类色块 + 名字前两字。",
2242
3264
  "分类按使用场景:工作办公、性能优化、界面美化、实用功能、开发调试、娱乐休闲、学习资料、水槽(插件横跨三类以上会自动归这里)、其它。",
3265
+ "下载量指的是这个 .dshpack 安装文件本身被下载的次数,不是包里插件的 npm 下载量。放 Git 仓库没有逐文件计数,显示「下载量未统计」;想要真实计数就放 Release 并写 host/tag。",
3266
+ "收录门槛:存放包文件的仓库(默认本目录仓库,写了 repo 就查那个)必须建满 24 小时,跟插件市场同一条,挡当天开号刷包。",
3267
+ "混合包请在包里写清楚哪些插件带本体(离线能装)、哪些只记版本(要联网),装的人才不会拔了网才发现缺东西。",
2243
3268
  "只提交你自己打的包,或者你有权再分发的插件组合;作者没写许可证的组合请先问作者。",
2244
3269
  ]
2245
3270
 
2246
- // ===== [区块] 页签三:社区资源:MarketPanel =====
3271
+
3272
+ // 附属件(apiVersion 1):接口全在 /market 与 /upload 下,关掉就整层下线,主体不受影响
2247
3273
  // 两层:外层管左侧「插件 / 整合包」两个大类,里层各自是独立的浏览面板。
2248
3274
  // 整合包这层就是原来的整包浏览(列表 / 详情 / 上传规则)。
3275
+ // ===== [区块] 社区资源小插件:MarketPanel =====
3276
+ // ===== [区块] 插件管理:本机已装插件的列表 / 启用禁用 / 更新 / 重装 =====
3277
+ // 数据是「已装插件 + 插件市场那份状态」:装了市场就与市场同步(停用名单是同一份),
3278
+ // 没装市场也能开关(退回配置层的 disabled)。只在下一启动生效,不做热挂载。
3279
+ const managerUi = { value: { loaded: false, at: 0, tab: "all", query: "", data: null, collapsed: {} } }
3280
+ // 行首图标按插件名缓存:name -> dataUrl(null = 这个包里没有图,别再问第二次)
3281
+ const pluginIcons = { value: new Map() }
3282
+ const MANAGER_TABS = [
3283
+ { id: "all", label: "全部" },
3284
+ { id: "enabled", label: "启用" },
3285
+ { id: "disabled", label: "禁用" },
3286
+ { id: "update", label: "可更新" },
3287
+ ]
3288
+
3289
+ function pluginInitial(item) {
3290
+ const text = String((item && (item.title || item.name)) || "?").trim()
3291
+ const char = text.slice(0, 1).toUpperCase()
3292
+ return /[A-Z0-9\u4e00-\u9fff]/u.test(char) ? char : "•"
3293
+ }
3294
+
3295
+ function PluginManagerPanel(props) {
3296
+ const compact = props && props.compact === true
3297
+ const cached = managerUi.value
3298
+ // props.initialTab:给测试与深链用(默认回到上次那一栏)
3299
+ const [tab, setTab] = useState((props && props.initialTab) || cached.tab || "all")
3300
+ // 子包折叠:{ 父插件名: true } 表示这组子包收起不画
3301
+ const [subFold, setSubFold] = useState(() => ({ ...(cached.subFold || {}) }) )
3302
+ useEffect(() => { cached.subFold = { ...subFold } }, [subFold])
3303
+ const [query, setQuery] = useState(cached.query || "")
3304
+ // props.snapshot 可以直接塞一份列表进来(测试 / 预渲染用);平时走 /plugins
3305
+ const [data, setData] = useState(cached.data || (props && props.snapshot) || null)
3306
+ const [collapsed, setCollapsed] = useState(cached.collapsed || {})
3307
+ const [busy, setBusy] = useState("")
3308
+ const [error, setError] = useState("")
3309
+ const [msg, setMsg] = useState("")
3310
+ // 重装前的那次确认:{ item, mode: "latest"|"current", keepConfig }
3311
+ const [ask, setAsk] = useState(null)
3312
+ // 一键更新前的那次确认:{ names: [...] }
3313
+ const [askBulk, setAskBulk] = useState(null)
3314
+ // 点图标看大图:{ name, dataUrl }
3315
+ const [zoomIcon, setZoomIcon] = useState(null)
3316
+ const [icons, setIcons] = useState(() => new Map(pluginIcons.value))
3317
+
3318
+ // 切页签会把面板整个卸载,列表和页签选择留在模块里,回来不用重拉
3319
+ useEffect(() => { managerUi.value = { ...managerUi.value, tab, query, data, collapsed } }, [tab, query, data, collapsed])
3320
+
3321
+ const load = async (silent) => {
3322
+ if (!silent) setBusy("load")
3323
+ try {
3324
+ const next = await api("/plugins")
3325
+ setData(next)
3326
+ managerUi.value = { ...managerUi.value, data: next, at: Date.now(), loaded: true }
3327
+ } catch (e) {
3328
+ setError(String((e && e.message) || e))
3329
+ } finally {
3330
+ if (!silent) setBusy("")
3331
+ }
3332
+ }
3333
+
3334
+ useEffect(() => {
3335
+ // 刚看过(20 秒内)就直接用缓存,避免每次切回来都打一次请求
3336
+ if (!managerUi.value.loaded || Date.now() - (managerUi.value.at || 0) > 20000) load()
3337
+ }, [])
3338
+
3339
+ // 图标:先查缓存,再一个个问(每个插件最多问一次;宿主没这个接口时整批静默跳过)
3340
+ useEffect(() => {
3341
+ const list = data && Array.isArray(data.items) ? data.items : []
3342
+ if (!list.length) return undefined
3343
+ let alive = true
3344
+ ;(async () => {
3345
+ for (const item of list.slice(0, 200)) {
3346
+ if (pluginIcons.value.has(item.name)) continue
3347
+ if (!alive) return
3348
+ try {
3349
+ const res = await api("/plugins/icon?name=" + encodeURIComponent(item.name))
3350
+ pluginIcons.value.set(item.name, res && res.dataUrl ? res.dataUrl : null)
3351
+ } catch (e) {
3352
+ pluginIcons.value.set(item.name, null)
3353
+ }
3354
+ }
3355
+ if (alive) setIcons(new Map(pluginIcons.value))
3356
+ })()
3357
+ return () => { alive = false }
3358
+ }, [data])
3359
+
3360
+ // 装 / 更新 / 重装都在后台任务里跑:跑完自动重读列表,
3361
+ // 否则「可更新」还是旧数字,非得手动点一下刷新才变——这就是「点完要刷新才更新按钮状态」的根源。
3362
+ const [watching, setWatching] = useState(false)
3363
+ useEffect(() => {
3364
+ if (!watching) return undefined
3365
+ let alive = true
3366
+ const timer = setInterval(async () => {
3367
+ try {
3368
+ const res = await fetch(API + "/jobs")
3369
+ if (!res.ok) return
3370
+ const body = await res.json()
3371
+ const list = body && Array.isArray(body.jobs) ? body.jobs : []
3372
+ const running = list.some((job) => job && job.status === "running" && ["install", "update", "reinstall", "backup"].includes(job.kind))
3373
+ if (alive && !running) { setWatching(false); await load(true) }
3374
+ } catch { /* 轮询失败下次再试 */ }
3375
+ }, 1200)
3376
+ return () => { alive = false; clearInterval(timer) }
3377
+ }, [watching])
3378
+
3379
+ // 刚进这个页面时如果已经在装 / 在更新,也要盯上,装完同样自动重读
3380
+ useEffect(() => {
3381
+ let alive = true
3382
+ ;(async () => {
3383
+ try {
3384
+ const res = await fetch(API + "/jobs")
3385
+ if (!res.ok) return
3386
+ const body = await res.json()
3387
+ const list = body && Array.isArray(body.jobs) ? body.jobs : []
3388
+ const running = list.some((job) => job && job.status === "running" && ["install", "update", "reinstall", "backup"].includes(job.kind))
3389
+ if (alive && running) setWatching(true)
3390
+ } catch { /* 读不到就算了,不影响列表 */ }
3391
+ })()
3392
+ return () => { alive = false }
3393
+ }, [])
3394
+
3395
+ const toggle = async (item) => {
3396
+ setBusy(item.name)
3397
+ setError("")
3398
+ setMsg("")
3399
+ try {
3400
+ const res = await api("/plugins/toggle", { name: item.name, enabled: !item.enabled })
3401
+ const notes = Array.isArray(res.notes) && res.notes.length ? "(" + res.notes.join(";") + ")" : ""
3402
+ setMsg(item.name + " 已" + (item.enabled ? "停用" : "启用") + notes + " · 重启 DSH 后生效")
3403
+ await load(true)
3404
+ } catch (e) {
3405
+ setError(String((e && e.message) || e))
3406
+ } finally {
3407
+ setBusy("")
3408
+ }
3409
+ }
3410
+
3411
+ const reveal = async (item) => {
3412
+ try {
3413
+ await api("/plugins/reveal", { name: item.name })
3414
+ } catch (e) {
3415
+ setError(String((e && e.message) || e))
3416
+ }
3417
+ }
3418
+
3419
+ const openAsk = (item, mode) => {
3420
+ // 按路径装的插件没有「最新版」可选,默认就是当前版本重装
3421
+ const hasLatest = Boolean(item.latestVersion) && !item.installSpec
3422
+ setAsk({
3423
+ item,
3424
+ // 默认:有新版就装新版,没新版就原版本再装一遍
3425
+ mode: item.installSpec ? "current" : mode || (hasLatest ? "latest" : "current"),
3426
+ keepConfig: true,
3427
+ })
3428
+ }
3429
+
3430
+ const startBulk = async () => {
3431
+ if (!askBulk) return
3432
+ setBusy("bulk")
3433
+ setError("")
3434
+ setMsg("")
3435
+ try {
3436
+ const res = await api("/plugins/update-all", { names: askBulk.names })
3437
+ setMsg("已开始一键更新 " + ((res.names || []).length) + " 个插件:进度在悬浮窗里,装完要重启 DSH 生效")
3438
+ setAskBulk(null)
3439
+ if (res.job) setWatching(true)
3440
+ await load(true)
3441
+ } catch (e) {
3442
+ setError(String((e && e.message) || e))
3443
+ } finally {
3444
+ setBusy("")
3445
+ }
3446
+ }
3447
+
3448
+ const startReinstall = async () => {
3449
+ if (!ask) return
3450
+ const item = ask.item
3451
+ // 按路径装的插件没有「市场版」这一说:重装就是重读那份目录
3452
+ const version = item.installSpec ? "" : ask.mode === "current" ? item.version : (item.latestVersion || item.version)
3453
+ setBusy(item.name)
3454
+ setError("")
3455
+ setMsg("")
3456
+ try {
3457
+ const res = await api("/plugins/reinstall", { name: item.name, version: version || undefined, keepConfig: ask.keepConfig })
3458
+ const label = (res.job && res.job.label) || ("重装 " + item.name)
3459
+ setMsg("已开始" + label + ":进度在悬浮窗里,装完要重启 DSH 生效")
3460
+ setAsk(null)
3461
+ if (res.job) setWatching(true)
3462
+ await load(true)
3463
+ } catch (e) {
3464
+ setError(String((e && e.message) || e))
3465
+ } finally {
3466
+ setBusy("")
3467
+ }
3468
+ }
3469
+
3470
+ const items = data && Array.isArray(data.items) ? data.items : []
3471
+ const counts = (data && data.counts) || { all: 0, enabled: 0, disabled: 0, updatable: 0 }
3472
+ const tabCount = (id) => (id === "all" ? counts.all : id === "enabled" ? counts.enabled : id === "disabled" ? counts.disabled : counts.updatable)
3473
+ const keyword = query.trim().toLowerCase()
3474
+ const matches = (item) => !keyword || (item.name + " " + (item.title || "") + " " + (item.description || "") + " " + (item.group || "")).toLowerCase().includes(keyword)
3475
+ const byTab = (item) => (tab === "all" ? true : tab === "enabled" ? item.enabled : tab === "disabled" ? !item.enabled : item.hasUpdate)
3476
+
3477
+ // 子包不单独进分组列表:只挂在父项下面那层可折叠区里。默认收起,点父项的「▸ 子包 N」才展开。
3478
+ // 父项自己没命中筛选、但名下有子包命中时,父项也留着当壳,否则在「可更新 / 停用」栏里就看不到它们。
3479
+ // 折叠状态存 session 级缓存,切页签回来还保持。
3480
+ const childrenOf = (name) => items.filter((item) => item.transitiveOf === name)
3481
+ const childShown = (item) => byTab(item) && matches(item)
3482
+ const parentShown = (item) => !item.transitiveOf && ((byTab(item) && matches(item)) || childrenOf(item.name).some(childShown))
3483
+ const ordered = items.filter(parentShown).sort((a, b) => (a.hasUpdate === b.hasUpdate ? String(a.name).localeCompare(String(b.name)) : a.hasUpdate ? -1 : 1))
3484
+ // 一键更新只动「可更新 + 启用中 + 不是按路径装」的:停用的插件不该被批量改
3485
+ const bulkReady = items.filter((item) => item.hasUpdate && item.enabled !== false && !item.installSpec)
3486
+ const bulkSkipped = items.filter((item) => item.hasUpdate && (item.enabled === false || Boolean(item.installSpec)))
3487
+ const groupNames = data && Array.isArray(data.groups) ? data.groups : []
3488
+ const sections = []
3489
+ if (tab === "all" && !keyword && groupNames.length) {
3490
+ for (const name of groupNames) {
3491
+ const rows = ordered.filter((item) => item.group === name)
3492
+ if (rows.length) sections.push({ key: name, label: name, rows })
3493
+ }
3494
+ const rest = ordered.filter((item) => !item.group)
3495
+ if (rest.length) sections.push({ key: "__ungrouped", label: "未分组", rows: rest })
3496
+ } else {
3497
+ sections.push({ key: "__all", label: "", rows: ordered })
3498
+ }
3499
+
3500
+ const actionBtn = (text, onClick, opts) => h("button", {
3501
+ type: "button",
3502
+ style: {
3503
+ ...chipBtn,
3504
+ padding: "2px 8px",
3505
+ ...(opts && opts.primary ? { color: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-primary, #4C7DF0)" } : null),
3506
+ ...(opts && opts.danger ? { color: "var(--mp-danger, #ff6b6b)", borderColor: "var(--mp-danger, #ff6b6b)" } : null),
3507
+ },
3508
+ title: (opts && opts.title) || "",
3509
+ disabled: Boolean(opts && opts.disabled),
3510
+ onClick,
3511
+ }, text)
3512
+ const chipTag = (text, color) => h("span", { style: { ...chip, ...(color ? { color, borderColor: color } : null) } }, text)
3513
+
3514
+ const managerRow = (item, nested) => h("div", {
3515
+ key: (nested ? "sub-" : "row-") + item.name,
3516
+ style: {
3517
+ display: "flex", gap: "10px", alignItems: "flex-start",
3518
+ padding: "7px 2px 7px " + (nested ? "9px" : "2px"),
3519
+ borderTop: nested ? "0.5px dashed var(--mp-line, var(--dsw-alias-border-l2))" : "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
3520
+ opacity: item.enabled ? 1 : 0.62,
3521
+ },
3522
+ },
3523
+ icons.get(item.name)
3524
+ ? h("img", {
3525
+ src: icons.get(item.name),
3526
+ alt: item.title || item.name,
3527
+ title: "点一下看大图",
3528
+ onClick: () => setZoomIcon({ name: item.title || item.name, dataUrl: icons.get(item.name) }),
3529
+ style: { width: "34px", height: "34px", borderRadius: "8px", flexShrink: 0, objectFit: "cover", cursor: "zoom-in", background: "rgba(128,128,128,0.10)", opacity: item.enabled ? 1 : 0.62 },
3530
+ })
3531
+ : h("div", {
3532
+ style: {
3533
+ width: "34px", height: "34px", borderRadius: "8px", flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center",
3534
+ fontSize: "15px", fontWeight: 600, color: "var(--mp-on-primary, #fff)",
3535
+ background: item.hasUpdate ? "linear-gradient(135deg,var(--mp-warn, #ffb36b),var(--mp-warn, #ff7a59))" : item.enabled ? "linear-gradient(135deg,var(--mp-primary, var(--dsw-alias-brand-primary, #7FA3F5)),var(--mp-primary, #4C7DF0))" : "linear-gradient(135deg,var(--mp-muted, #b9bec9),var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99)))",
3536
+ },
3537
+ }, pluginInitial(item)),
3538
+ h("div", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: "2px" } },
3539
+ h("div", { style: { display: "flex", gap: "6px", alignItems: "baseline", flexWrap: "wrap" } },
3540
+ h("span", { style: { ...strong, fontSize: "13.5px" } }, item.title || item.name),
3541
+ item.title ? h("span", { style: hint }, "| " + item.name) : null,
3542
+ h("span", { style: { ...mono, color: item.hasUpdate ? "var(--mp-warn, #ff9b52)" : "var(--mp-muted, var(--dsw-alias-label-tertiary))" } }, item.version || "?"),
3543
+ item.hasUpdate ? h("span", { style: { color: "var(--mp-warn, #ff9b52)", fontSize: "12px" }, title: "插件市场目录里的最新版" }, "↑ " + item.latestVersion) : null,
3544
+ childrenOf(item.name).length
3545
+ ? h("button", {
3546
+ type: "button",
3547
+ title: subFold[item.name] ? "收起这 " + childrenOf(item.name).length + " 个子包(它们只是随父包装进来的内部组件)" : "展开这 " + childrenOf(item.name).length + " 个子包(它们只是随父包装进来的内部组件)",
3548
+ onClick: () => setSubFold({ ...subFold, [item.name]: !subFold[item.name] }),
3549
+ style: { ...chipBtn, padding: "0 6px", fontSize: "11.5px", color: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-line, var(--mp-line, var(--dsw-alias-border-l2)))" },
3550
+ }, (subFold[item.name] ? "▾ " : "▸ ") + "子包 " + childrenOf(item.name).length)
3551
+ : null),
3552
+ h("div", { style: { display: "flex", gap: "5px", flexWrap: "wrap", alignItems: "center" } },
3553
+ chipTag(item.enabled ? "启用" : "禁用", item.enabled ? "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" : "var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99))"),
3554
+ item.source === "market" ? chipTag("市场", "var(--mp-primary, #4C7DF0)") : chipTag("本地", "var(--mp-muted, var(--dsw-alias-label-tertiary, #8b8f99))"),
3555
+ item.isDirect === false ? chipTag("子包 · 跟随 " + (item.transitiveOf || "父插件"), "var(--mp-warn, #ffb020)") : null,
3556
+ item.isOrphan ? chipTag("残留包", "var(--mp-warn, #ffb020)") : null,
3557
+ item.hasConfig ? chipTag("有配置", "") : null),
3558
+ item.description ? h("div", { style: { ...hint, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, item.description) : null),
3559
+ h("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap", justifyContent: "flex-end", maxWidth: compact ? "150px" : "240px" } },
3560
+ item.hasUpdate ? actionBtn("更新", () => openAsk(item, "latest"), { primary: true, disabled: busy !== "", title: "按插件市场的版本重装一次(" + item.latestVersion + ")" }) : null,
3561
+ actionBtn("重装", () => openAsk(item, item.latestVersion && item.hasUpdate ? "latest" : "current"), { disabled: busy !== "", title: "先卸载再安装;可以选要不要保留本机配置" }),
3562
+ item.isDirect === false ? null : actionBtn(item.enabled ? "禁用" : "启用", () => toggle(item), { disabled: busy !== "", danger: item.enabled, title: "写下停用状态,下次启动 DSH 生效" }),
3563
+ actionBtn("目录", () => reveal(item), { title: "在资源管理器里打开这个插件的目录" })))
3564
+
3565
+ // 父项 + 它名下的子包:子包永远缩进在父项下面这一条虚线框里,收起时整组不画。
3566
+ const managerBlock = (item) => {
3567
+ const kids = childrenOf(item.name).filter(childShown)
3568
+ const open = Boolean(subFold[item.name]) && kids.length > 0
3569
+ return h("div", { key: "blk-" + item.name, style: { display: "flex", flexDirection: "column" } },
3570
+ managerRow(item),
3571
+ open
3572
+ ? h("div", { style: { display: "flex", flexDirection: "column", paddingLeft: "12px", marginLeft: "24px", borderLeft: "2px solid var(--mp-line, rgba(128,128,128,0.25))" } },
3573
+ kids.map((child) => managerRow(child, true)))
3574
+ : null)
3575
+ }
3576
+
3577
+ const bulkBox = askBulk ? h("div", {
3578
+ style: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.38)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 4000 },
3579
+ onClick: (event) => { if (event && event.target === event.currentTarget) setAskBulk(null) },
3580
+ },
3581
+ h("div", { style: { width: "min(460px, 92vw)", background: "var(--mp-card, var(--dsw-alias-bg-layer-1, #fff))", color: "var(--mp-text, var(--dsw-alias-label-primary))", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "10px", boxShadow: "0 12px 32px rgba(0,0,0,0.22)" } },
3582
+ h("div", { style: strong }, "一键更新 " + askBulk.names.length + " 个插件"),
3583
+ h("div", { style: hint }, "只更新启用中且能按市场版本装的那几个;不卸载、不动配置,装完要重启 DSH 才生效。"),
3584
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "2px", maxHeight: "220px", overflowY: "auto" } },
3585
+ items.filter((item) => askBulk.names.includes(item.name)).map((item) => h("div", { key: "bulk-" + item.name, style: { display: "flex", gap: "8px", alignItems: "baseline", fontSize: "12px" } },
3586
+ h("span", { style: { ...mono, flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis" } }, item.name),
3587
+ h("span", { style: { ...hint, color: "var(--mp-warn, #ff9b52)" } }, (item.version || "?") + " → " + (item.latestVersion || "最新"))))),
3588
+ bulkSkipped.length
3589
+ ? h("div", { style: hint }, "这次不动:" + bulkSkipped.map((item) => item.name + (item.installSpec ? "(按路径装)" : "(已停用)")).join("、"))
3590
+ : null,
3591
+ h("div", { style: { ...row, justifyContent: "flex-end" } },
3592
+ actionBtn("取消", () => setAskBulk(null)),
3593
+ actionBtn("开始更新", startBulk, { primary: true, disabled: busy !== "" }))))
3594
+ : null
3595
+
3596
+ const zoomBox = zoomIcon ? h("div", {
3597
+ style: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.62)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 5000 },
3598
+ onClick: () => setZoomIcon(null),
3599
+ },
3600
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "8px", alignItems: "center" } },
3601
+ h("img", { src: zoomIcon.dataUrl, alt: zoomIcon.name, style: { maxWidth: "min(70vw, 560px)", maxHeight: "70vh", borderRadius: "12px", background: "var(--mp-card, var(--dsw-alias-bg-base, #fff))", padding: "8px" } }),
3602
+ h("span", { style: { color: "var(--mp-on-primary, #fff)", fontSize: "12.5px" } }, zoomIcon.name + " · 点任意处关闭")))
3603
+ : null
3604
+
3605
+ const askBox = ask ? h("div", {
3606
+ style: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.38)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 4000 },
3607
+ onClick: (event) => { if (event && event.target === event.currentTarget) setAsk(null) },
3608
+ },
3609
+ h("div", { style: { width: "min(440px, 92vw)", background: "var(--mp-card, var(--dsw-alias-bg-layer-1, #fff))", color: "var(--mp-text, var(--dsw-alias-label-primary))", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "10px", boxShadow: "0 12px 32px rgba(0,0,0,0.22)" } },
3610
+ h("div", { style: strong }, "重装 " + (ask.item.title || ask.item.name)),
3611
+ h("div", { style: hint }, "会先卸载再安装(和插件市场装的是同一条路),做完要重启 DSH 才生效。"),
3612
+ h("div", { style: row },
3613
+ h("span", { style: label }, "装哪个版本"),
3614
+ actionBtn("最新版 " + (ask.item.latestVersion || "(目录里没有)"), () => setAsk({ ...ask, mode: "latest" }), { primary: ask.mode === "latest", disabled: Boolean(ask.item.installSpec) || !ask.item.latestVersion, title: "插件市场目录里的最新版" }),
3615
+ actionBtn("当前版本 " + (ask.item.version || "?"), () => setAsk({ ...ask, mode: "current" }), { primary: ask.mode === "current" })),
3616
+ ask.item.installSpec
3617
+ ? h("div", { style: hint }, "这个插件是按路径装的(" + ask.item.installSpec + "),重装只会重读这份目录,不会换成市场版。")
3618
+ : null,
3619
+ h("div", { style: row },
3620
+ h("span", { style: label }, "本机配置"),
3621
+ actionBtn("保留本机配置", () => setAsk({ ...ask, keepConfig: true }), { primary: ask.keepConfig, title: "重装后照旧用你现在这份设置" }),
3622
+ actionBtn("清掉配置,用默认值", () => setAsk({ ...ask, keepConfig: false }), { primary: !ask.keepConfig, danger: !ask.keepConfig, title: "把 cordis.patch.yml 里这个插件的条目一起删掉" })),
3623
+ h("div", { style: hint }, ask.keepConfig ? "保留配置:只换插件本体,设置不动。" : "不保留配置:插件在 cordis.patch.yml 里的条目会被删掉,回到默认设置。"),
3624
+ h("div", { style: { ...row, justifyContent: "flex-end" } },
3625
+ actionBtn("取消", () => setAsk(null)),
3626
+ actionBtn("开始重装", startReinstall, { primary: true, disabled: busy !== "" }))))
3627
+ : null
3628
+
3629
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
3630
+ h("div", { style: row },
3631
+ h("div", { style: { ...strong, fontSize: compact ? "13px" : "14px" } }, "插件管理"),
3632
+ data ? h("span", { style: hint }, data.marketPresent ? "与插件市场同一份停用名单 · 共 " + counts.all + " 个" : "没装插件市场:停用写配置层 · 共 " + counts.all + " 个") : h("span", { style: hint }, "读取中…")),
3633
+ h("input", {
3634
+ type: "search",
3635
+ style: { ...input, width: "100%" },
3636
+ placeholder: "搜索插件名称 / 描述 / 分组",
3637
+ value: query,
3638
+ onChange: (event) => setQuery(event.target.value || ""),
3639
+ }),
3640
+ h("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap", alignItems: "center" } },
3641
+ MANAGER_TABS.map((entry) => h("button", {
3642
+ type: "button",
3643
+ key: "mtab-" + entry.id,
3644
+ onClick: () => setTab(entry.id),
3645
+ style: {
3646
+ height: "26px", padding: "0 12px", borderRadius: "999px", cursor: "pointer", fontFamily: "inherit", fontSize: "12.5px",
3647
+ border: tab === entry.id ? "1px solid transparent" : "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
3648
+ background: tab === entry.id ? "var(--mp-primary, #2f6bf3)" : "transparent",
3649
+ color: tab === entry.id ? "var(--mp-on-primary, #fff)" : "var(--mp-muted, var(--dsw-alias-label-secondary))",
3650
+ fontWeight: tab === entry.id ? 600 : 400,
3651
+ },
3652
+ }, entry.label + " (" + tabCount(entry.id) + ")")),
3653
+ // 一键更新只属于「可更新」这一栏,而且只在真有可更新项时才出现:
3654
+ // 没有可更新的插件就不该有个灰按钮杵在那儿,让人怀疑是不是坏了。
3655
+ data && tab === "updated" && bulkReady.length > 0
3656
+ ? h("button", {
3657
+ type: "button",
3658
+ style: {
3659
+ height: "26px", padding: "0 12px", borderRadius: "999px", cursor: busy === "" ? "pointer" : "default",
3660
+ fontFamily: "inherit", fontSize: "12.5px", fontWeight: 600,
3661
+ border: "1px solid var(--mp-primary, #2f6bf3)", background: "var(--mp-primary, #2f6bf3)", color: "var(--mp-on-primary, #fff)",
3662
+ },
3663
+ disabled: busy !== "",
3664
+ title: "更新这 " + bulkReady.length + " 个插件(停用的、按路径装的不在内)",
3665
+ onClick: () => setAskBulk({ names: bulkReady.map((item) => item.name) }),
3666
+ }, "一键更新 (" + bulkReady.length + ")")
3667
+ : null,
3668
+ data && data.marketPresent === false ? h("span", { style: { ...hint, marginLeft: "auto" } }, "没装插件市场也能开关,只是停用写进配置层") : null),
3669
+ error ? h(Notice, { tone: "bad" }, error) : null,
3670
+ msg ? h(Notice, { tone: "ok" }, msg) : null,
3671
+ !data
3672
+ ? h("div", { style: hint }, busy === "load" ? "正在读取本机插件…" : "还没读到插件列表。用页签行的「刷新」重来一次。")
3673
+ : ordered.length === 0
3674
+ ? h("div", { style: hint }, items.length === 0 ? "这个 profile 里还没有装任何插件。" : "没有符合当前筛选的插件。")
3675
+ : h("div", { style: { display: "flex", flexDirection: "column", gap: "2px", maxHeight: compact ? "340px" : "none", overflow: compact ? "auto" : "visible" } },
3676
+ sections.map((section) => h("div", { key: "sec-" + section.key, style: { display: "flex", flexDirection: "column", gap: "2px", marginTop: section.label ? "6px" : 0 } },
3677
+ section.label
3678
+ ? h("button", {
3679
+ type: "button",
3680
+ style: { display: "flex", gap: "6px", alignItems: "center", background: "transparent", border: "none", padding: "2px 0", cursor: "pointer", color: "var(--mp-text, var(--dsw-alias-label-primary))", fontSize: "12px", fontWeight: 600, fontFamily: "inherit" },
3681
+ onClick: () => setCollapsed({ ...collapsed, [section.key]: !collapsed[section.key] }),
3682
+ }, (collapsed[section.key] ? "▸ " : "▾ ") + section.label + "(" + section.rows.length + ")")
3683
+ : null,
3684
+ section.label && collapsed[section.key] ? null : section.rows.map(managerBlock)))),
3685
+ askBox,
3686
+ bulkBox,
3687
+ zoomBox)
3688
+ }
3689
+
2249
3690
  function MarketPanel(props) {
2250
- const [kind, setKind] = useState(() => (readMarketUi().kind === "plugin" ? "plugin" : "modpack"))
3691
+ const [kind, setKind] = useState(() => {
3692
+ const saved = readMarketUi().kind
3693
+ return saved === "plugin" ? saved : "modpack"
3694
+ })
2251
3695
  useEffect(() => { saveMarketKind(kind) }, [kind])
2252
3696
  const market = (props.status && props.status.market) || null
2253
3697
  const installed = Boolean(market && market.installed)
@@ -2263,9 +3707,9 @@ window.__ModuleLoader__.load({
2263
3707
  width: "100%",
2264
3708
  padding: "9px 10px",
2265
3709
  borderRadius: "8px",
2266
- border: kind === id ? "1px solid #4C7DF0" : "1px solid transparent",
3710
+ border: kind === id ? "1px solid var(--mp-primary, #4C7DF0)" : "1px solid transparent",
2267
3711
  background: kind === id ? "rgba(76, 125, 240, 0.12)" : "transparent",
2268
- color: "inherit",
3712
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
2269
3713
  cursor: "pointer",
2270
3714
  textAlign: "left",
2271
3715
  fontSize: "13px",
@@ -2281,7 +3725,7 @@ window.__ModuleLoader__.load({
2281
3725
  display: "flex",
2282
3726
  flexDirection: "column",
2283
3727
  gap: "4px",
2284
- borderRight: "0.5px solid var(--dsw-alias-border-l2)",
3728
+ borderRight: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
2285
3729
  paddingRight: "10px",
2286
3730
  position: "sticky",
2287
3731
  top: 0,
@@ -2312,6 +3756,10 @@ window.__ModuleLoader__.load({
2312
3756
  const [chips, setChips] = useState(Array.isArray(pluginSnap.chips) && pluginSnap.chips.length ? pluginSnap.chips : [{ id: "all", label: "全部", count: 0 }])
2313
3757
  const [loading, setLoading] = useState(false)
2314
3758
  const [error, setError] = useState("")
3759
+ const [view, setView] = useState(pluginSnap.view === "detail" && pluginSnap.detail ? "detail" : "list")
3760
+ const [detail, setDetail] = useState(pluginSnap.detail || null)
3761
+ const [installing, setInstalling] = useState("")
3762
+ const [installMsg, setInstallMsg] = useState("")
2315
3763
  // 第一屏如果有上次留下的列表,就别再打一次请求(会闪一下、还把页码冲回 1)
2316
3764
  const restoredPlugins = useRef(Array.isArray(pluginSnap.items) && pluginSnap.items.length > 0)
2317
3765
  const applyItems = (data, append) => {
@@ -2327,8 +3775,8 @@ window.__ModuleLoader__.load({
2327
3775
  // 分类直接沿用插件市场目录的口径:服务端按 label 过滤,前端只拿一页
2328
3776
  // 退出程序前一直留着:搜索框文字、分类、排序、页码与已读到的列表
2329
3777
  useEffect(() => {
2330
- saveMarketUi("plugin", { query, category, sort, items, total, page, hasMore, chips })
2331
- }, [query, category, sort, items, total, page, hasMore, chips])
3778
+ saveMarketUi("plugin", { query, category, sort, items, total, page, hasMore, chips, view, detail })
3779
+ }, [query, category, sort, items, total, page, hasMore, chips, view, detail])
2332
3780
  useEffect(() => {
2333
3781
  if (!installed) return undefined
2334
3782
  if (restoredPlugins.current) { restoredPlugins.current = false; return undefined }
@@ -2359,14 +3807,86 @@ window.__ModuleLoader__.load({
2359
3807
  setLoading(false)
2360
3808
  }
2361
3809
  }
3810
+ // 装 / 更新:同一来源(npm 上的 name@version),服务端优先走宿主插件管理器,失败退回命令行
3811
+ const installOne = async (item) => {
3812
+ if (!item || !item.name || installing) return
3813
+ setInstalling(item.name)
3814
+ setInstallMsg("")
3815
+ try {
3816
+ const data = await api("/plugin/install", { name: item.name, version: item.version || "" })
3817
+ if (data && data.ok) {
3818
+ const wasUpdate = item.installed && item.updateAvailable
3819
+ setInstallMsg((wasUpdate ? "已更新:" : "已装好:") + item.name + (data.restartRequired ? "(重启 DSH 后生效)" : "(已生效)"))
3820
+ const fresh = await api("/catalog/search", { query, category, sort, page: 1, pageSize: 20 })
3821
+ if (fresh) {
3822
+ applyItems(fresh, false)
3823
+ setPage(1)
3824
+ const after = (Array.isArray(fresh.items) ? fresh.items : []).find((row) => row.name === item.name)
3825
+ if (after) setDetail((prev) => (prev && prev.name === item.name ? after : prev))
3826
+ }
3827
+ } else {
3828
+ setInstallMsg("没装成:" + ((data && (data.error || data.application)) || "未知原因"))
3829
+ }
3830
+ } catch (e) {
3831
+ setInstallMsg("没装成:" + ((e && e.message) || String(e)))
3832
+ } finally {
3833
+ setInstalling("")
3834
+ }
3835
+ }
3836
+ const isLatest = (item) => Boolean(item.installed && item.version && item.localVersion && item.version === item.localVersion)
3837
+ const installLabel = (item) => {
3838
+ if (installing === item.name) return "安装中…"
3839
+ if (!item.installed) return "下载并安装"
3840
+ if (item.updateAvailable) return "更新到 " + item.version
3841
+ if (isLatest(item)) return "重新安装"
3842
+ return "重新安装"
3843
+ }
3844
+ const versionLine = (item) => {
3845
+ if (!item.installed) return "本机还没装;市场版 v" + (item.version || "未知")
3846
+ if (isLatest(item)) return "已是当前最新版(v" + item.version + ")"
3847
+ if (item.updateAvailable) return "本机 v" + (item.localVersion || "?") + ",市场有新版 v" + item.version
3848
+ return "本机已装 v" + (item.localVersion || item.version || "?")
3849
+ }
3850
+ const openDetail = (item) => { setDetail(item); setView("detail"); setInstallMsg("") }
3851
+ if (view === "detail" && detail) {
3852
+ const item = detail
3853
+ const latest = isLatest(item)
3854
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
3855
+ h("div", { style: row },
3856
+ h("button", { type: "button", style: chipBtn, onClick: () => setView("list") }, "← 返回列表"),
3857
+ h("span", { style: { ...strong, fontSize: "15px" } }, item.title || item.name),
3858
+ h(Tag, null, item.categoryLabel || item.category || "其它"),
3859
+ h("span", { style: { ...hint, marginLeft: "auto" } }, item.name)),
3860
+ h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "14px", display: "flex", flexDirection: "column", gap: "10px" } },
3861
+ h("div", { style: row },
3862
+ h("span", { style: { ...hint, color: latest ? "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" : (item.updateAvailable ? "var(--mp-primary, #4C7DF0)" : "inherit") } }, versionLine(item)),
3863
+ item.owner ? h("span", { style: hint }, "作者 " + item.owner) : null,
3864
+ item.publishedAt ? h("span", { style: hint }, "发布 " + item.publishedAt) : null,
3865
+ h("span", { style: { ...hint, marginLeft: "auto" } }, item.version ? "市场版 v" + item.version : "")),
3866
+ h("div", { style: { fontSize: "12.5px", lineHeight: "20px" } }, item.description || "插件市场里没写说明。"),
3867
+ item.homepage || item.repository ? h("span", { style: { ...hint, wordBreak: "break-all" } }, item.homepage || item.repository) : null,
3868
+ h("div", { style: row },
3869
+ h("button", {
3870
+ type: "button",
3871
+ style: { ...(latest ? btn : btnPrimary), padding: "7px 20px", fontSize: "13px", fontWeight: 600 },
3872
+ disabled: Boolean(installing),
3873
+ title: item.name + (item.version ? "@" + item.version : "") + "(来源与插件市场一致)",
3874
+ onClick: () => installOne(item),
3875
+ }, installLabel(item)),
3876
+ latest ? h("span", { style: hint }, "已是当前最新版;想再装一遍也可以。") : null,
3877
+ item.updateAvailable ? h("span", { style: { ...hint, color: "var(--mp-primary, #4C7DF0)" } }, "本机 v" + (item.localVersion || "?") + " → v" + item.version) : null),
3878
+ installMsg ? h("div", { style: { ...hint, color: /没装成/u.test(installMsg) ? "var(--mp-danger, #ff6b6b)" : "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, installMsg) : null,
3879
+ h("div", { style: hint }, "装完插件市场认成市场版(依赖写成 名字@版本);卸载仍去插件市场里做。")),
3880
+ h("div", { style: hint }, "点「返回列表」回到刚才那页,搜索与分类都还在。"))
3881
+ }
2362
3882
  if (!installed) {
2363
- return h("div", { style: { border: "1px dashed var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "8px" } },
3883
+ return h("div", { style: { border: "1px dashed var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "8px" } },
2364
3884
  h("span", { style: strong }, "请先安装插件市场"),
2365
3885
  h("span", { style: hint }, "「插件」这一类直接读插件市场(dshmarket)的目录与检索,功能基于插件市场;没装就没有这一层可看。"),
2366
3886
  h("span", { style: hint }, "装好插件市场后回到这里,左边这一项会变成「接入插件市场」,列表也就有了。"))
2367
3887
  }
2368
3888
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
2369
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "8px" } },
3889
+ h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "8px" } },
2370
3890
  h("div", { style: { ...row, justifyContent: "space-between" } },
2371
3891
  h("span", { style: { ...strong, fontSize: "13px" } }, "搜索插件"),
2372
3892
  h("span", { style: hint }, "跟打包页同一套:分类、搜索、已装优先;目录与检索都来自插件市场(dsh-plugin-catalog)")),
@@ -2376,43 +3896,518 @@ window.__ModuleLoader__.load({
2376
3896
  value: query,
2377
3897
  placeholder: "插件名 / 作者 / 描述(例如 记忆、壁纸、侧边栏)",
2378
3898
  onChange: (event) => setQuery(event.target.value),
2379
- style: { height: "30px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "inherit", fontSize: "12.5px", padding: "0 8px" },
3899
+ style: { height: "30px", borderRadius: "6px", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-card-soft, transparent)", color: "var(--mp-text, var(--dsw-alias-label-primary))", fontSize: "12.5px", padding: "0 8px" },
2380
3900
  }),
2381
3901
  h("select", {
2382
3902
  value: sort,
2383
3903
  onChange: (event) => setSort(event.target.value),
2384
- style: { height: "30px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "inherit", fontSize: "12.5px" },
3904
+ style: { height: "30px", borderRadius: "6px", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-card-soft, transparent)", color: "var(--mp-text, var(--dsw-alias-label-primary))", fontSize: "12.5px" },
2385
3905
  }, [["market", "按相关度"], ["new", "最新发布"], ["name", "按名字"]].map(([value, text]) => h("option", { key: value, value }, text))),
2386
3906
  h("span", { style: { ...hint, textAlign: "right" } }, loading ? "搜索中…" : "共 " + total + " 个")),
2387
3907
  h(CategoryChips, { chips, value: category, onChange: setCategory })),
2388
- error ? h("div", { style: { ...hint, color: "#ff6b6b", lineHeight: "19px" } }, String(error)) : null,
3908
+ error ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)", lineHeight: "19px" } }, String(error)) : null,
2389
3909
  loading && items.length === 0 ? h("div", { style: { ...hint, padding: "14px 2px" } }, "正在读取插件目录…") : null,
2390
3910
  !loading && items.length === 0 && !error
2391
- ? h("div", { style: { border: "1px dashed var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "6px" } },
3911
+ ? h("div", { style: { border: "1px dashed var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "6px" } },
2392
3912
  h("span", { style: strong }, query ? "没有匹配的插件" : "插件目录还是空的"),
2393
3913
  h("span", { style: hint }, query ? "换个说法试试:插件名、作者名、描述里的词都能搜。" : "插件市场还没建过目录索引:去插件市场里刷一次,或等它自己更新。"))
2394
3914
  : null,
2395
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", overflow: "hidden" } },
3915
+ h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", overflow: "hidden" } },
2396
3916
  items.map((item) => h("div", {
2397
3917
  key: "plug-" + item.name,
2398
- style: { display: "flex", flexDirection: "column", gap: "3px", padding: "9px 12px", borderBottom: "0.5px solid var(--dsw-alias-border-l2)" },
3918
+ onClick: () => openDetail(item),
3919
+ title: "点开看详情与下载",
3920
+ style: { display: "flex", flexDirection: "column", gap: "3px", padding: "9px 12px", borderBottom: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", cursor: "pointer" },
2399
3921
  },
2400
3922
  h("div", { style: row },
2401
3923
  h("span", { style: { fontSize: "13px", fontWeight: 600 } }, item.title || item.name),
2402
3924
  h(Tag, null, item.categoryLabel || item.category || "其它"),
2403
- item.installed ? h("span", { style: { ...hint, color: "#2bb673" } }, "本机已装" + (item.updateAvailable ? "(市场版 " + item.version + " 更新)" : "")) : null,
2404
- h("span", { style: { ...hint, marginLeft: "auto" } }, item.version ? "v" + item.version : "")),
3925
+ item.installed ? h("span", { style: { ...hint, color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, "本机已装" + (item.updateAvailable ? "(市场版 " + item.version + " 更新)" : "")) : null,
3926
+ h("span", { style: { ...hint, marginLeft: "auto" } }, item.version ? "v" + item.version : ""),
3927
+ h("span", { style: { ...hint, flexShrink: 0, color: item.updateAvailable ? "var(--mp-primary, #4C7DF0)" : undefined } }, isLatest(item) ? "已是最新版本" : (item.installed ? "可更新" : "")),
3928
+ h("span", { style: { ...chipBtn, flexShrink: 0 } }, "查看 ›")),
2405
3929
  h("span", { style: hint }, item.description || "作者没写说明。"),
2406
3930
  h("span", { style: { ...hint, fontSize: "11.5px" } }, item.name)))),
2407
3931
  hasMore ? h("div", { style: row },
2408
3932
  h("button", { type: "button", style: btn, disabled: loading, onClick: loadMore }, loading ? "读取中…" : "加载更多")) : null,
2409
- h("div", { style: hint }, "装 / 更新 / 卸载插件仍在插件市场里做:这一层只按它的目录浏览与检索,不重复实现一套安装。"))
3933
+ installMsg ? h("div", { style: { ...hint, color: /没装成/u.test(installMsg) ? "var(--mp-danger, #ff6b6b)" : "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, installMsg) : null,
3934
+ h("div", { style: hint }, "装与更新就在这里做:来源跟插件市场一致(npm 上的 名字@版本),装完市场认成市场版;卸载仍去插件市场里做。"))
3935
+ }
3936
+
3937
+ // ===== [区块] 社区资源:一键上传(别人也能用,不需要 LLM token) =====
3938
+ const UPLOAD_CATEGORIES = ["工作办公", "性能优化", "界面美化", "实用功能", "开发调试", "娱乐休闲", "学习资料", "其它", "水槽"]
3939
+
3940
+ function bytesToBase64(buffer) {
3941
+ const bytes = new Uint8Array(buffer)
3942
+ let binary = ""
3943
+ const chunk = 0x8000
3944
+ for (let i = 0; i < bytes.length; i += chunk) {
3945
+ binary += String.fromCharCode.apply(null, bytes.subarray(i, i + chunk))
3946
+ }
3947
+ return window.btoa(binary)
2410
3948
  }
2411
3949
 
2412
- // ===== [区块] 页签三:社区资源:整合包浏览(列表 / 详情 / 上传规则) =====
3950
+ function UploadPanel(props) {
3951
+ // 凭据不跟着页面走:离开这一页就请服务端把它从内存里丢掉,下次进来必须重新填
3952
+ useEffect(() => () => {
3953
+ api("/upload/token", { token: "" }).catch(() => {})
3954
+ }, [])
3955
+ const [status, setStatus] = useState(null)
3956
+ const [token, setToken] = useState("")
3957
+ const [busy, setBusy] = useState("")
3958
+ const [error, setError] = useState("")
3959
+ const [msg, setMsg] = useState("")
3960
+ const [fileBase64, setFileBase64] = useState("")
3961
+ const [filePath, setFilePath] = useState("")
3962
+ const [fileName, setFileName] = useState("")
3963
+ const [preview, setPreview] = useState(null)
3964
+ const [fields, setFields] = useState({ name: "", author: "", description: "", homepage: "" })
3965
+ const [category, setCategory] = useState("实用功能")
3966
+ const [host, setHost] = useState("repo")
3967
+ const [repoInput, setRepoInput] = useState("")
3968
+ const [tagInput, setTagInput] = useState("")
3969
+ const [cover, setCover] = useState("")
3970
+ const [coverSrc, setCoverSrc] = useState("") // 原图(还没裁)
3971
+ const [coverZoom, setCoverZoom] = useState(1)
3972
+ const [coverOffset, setCoverOffset] = useState({ x: 0, y: 0 })
3973
+ const [coverSize, setCoverSize] = useState(512)
3974
+ const coverDrag = useRef(null)
3975
+ const coverFrameRef = useRef(null)
3976
+ const [coverErr, setCoverErr] = useState("")
3977
+ const [localPack, setLocalPack] = useState(null)
3978
+ const [previewBusy, setPreviewBusy] = useState("")
3979
+ const coverRef = useRef(null)
3980
+ const [dir, setDir] = useState("")
3981
+ const [dirItems, setDirItems] = useState([])
3982
+ const [dirErr, setDirErr] = useState("")
3983
+ const fileRef = useRef(null)
3984
+
3985
+ const load = async () => {
3986
+ try {
3987
+ const data = await api("/upload/status")
3988
+ setStatus(data)
3989
+ } catch (e) {
3990
+ setError((e && e.message) || String(e))
3991
+ }
3992
+ }
3993
+ useEffect(() => { load() }, [])
3994
+
3995
+ const saveToken = async () => {
3996
+ setBusy("token"); setError(""); setMsg("")
3997
+ try {
3998
+ const data = await api("/upload/token", { token: token.trim() })
3999
+ if (!data || data.ok !== true) throw new Error((data && data.error) || "没存上")
4000
+ setToken("")
4001
+ setMsg(data.configured ? "已放进内存:登录为 " + data.login + "(不写盘,上传结束立刻清除;下次上传要重填)" : "已清掉内存里的凭据")
4002
+ await load()
4003
+ } catch (e) {
4004
+ setError((e && e.message) || String(e))
4005
+ } finally { setBusy("") }
4006
+ }
4007
+
4008
+ const readPreview = async (body) => {
4009
+ const data = await api("/upload/preview", body, 60000)
4010
+ if (!data || data.ok !== true) throw new Error((data && data.error) || "读不了这个包")
4011
+ setPreview(data)
4012
+ setFields({
4013
+ name: String((data.fields && data.fields.name) || ""),
4014
+ author: String((data.fields && data.fields.author) || ""),
4015
+ description: String((data.fields && data.fields.description) || ""),
4016
+ homepage: String((data.fields && data.fields.homepage) || ""),
4017
+ })
4018
+ if (data.fileName) setFileName(data.fileName)
4019
+ }
4020
+
4021
+ const readFile = async (picked) => {
4022
+ if (!picked) return
4023
+ if (!/\.dshpack$/iu.test(picked.name || "")) { setError("只认 .dshpack 整合包"); return }
4024
+ setBusy("read"); setError(""); setMsg(""); setPreview(null)
4025
+ setFilePath("")
4026
+ try {
4027
+ const buffer = await picked.arrayBuffer()
4028
+ const base64 = bytesToBase64(buffer)
4029
+ setFileBase64(base64)
4030
+ setFileName(picked.name)
4031
+ await readPreview({ fileName: picked.name, base64 })
4032
+ } catch (e) {
4033
+ setError((e && e.message) || String(e))
4034
+ setPreview(null)
4035
+ } finally { setBusy("") }
4036
+ }
4037
+
4038
+ const readPath = async (target) => {
4039
+ if (!target) return
4040
+ setBusy("read"); setError(""); setMsg(""); setPreview(null)
4041
+ setFileBase64("")
4042
+ try {
4043
+ await readPreview({ file: target })
4044
+ setFilePath(target)
4045
+ setFileName(String(target).split(/[\\/]/u).pop() || target)
4046
+ } catch (e) {
4047
+ setError((e && e.message) || String(e))
4048
+ setPreview(null)
4049
+ } finally { setBusy("") }
4050
+ }
4051
+
4052
+ const browseFolder = async () => {
4053
+ if (typeof pickDirectoryHost !== "function") {
4054
+ setDirErr("这个环境没有系统目录选择器:用「选择文件…」或者把包放进插件自己的 packs 目录")
4055
+ return
4056
+ }
4057
+ setBusy("dir"); setDirErr("")
4058
+ try {
4059
+ const picked = await pickDirectoryHost()
4060
+ if (!picked) return
4061
+ setDir(picked)
4062
+ const data = await api("/packs", { dir: picked })
4063
+ setDirItems(Array.isArray(data.items) ? data.items : [])
4064
+ setDirErr(String(data.error || ""))
4065
+ } catch (e) {
4066
+ setDirErr((e && e.message) || String(e))
4067
+ } finally { setBusy("") }
4068
+ }
4069
+
4070
+ const clearFile = () => {
4071
+ setFileBase64(""); setFilePath(""); setFileName(""); setPreview(null)
4072
+ setFields({ name: "", author: "", description: "", homepage: "" })
4073
+ setDirItems([]); setError(""); setMsg("")
4074
+ }
4075
+
4076
+ // 封面:只收 PNG/JPG,读成 data URL,前端先拦一遍大小(服务端还会再拦一次)
4077
+ const pickCover = async (picked) => {
4078
+ if (!picked) return
4079
+ setCoverErr("")
4080
+ if (!/image\/(png|jpeg)/iu.test(picked.type || "")) { setCoverErr("只收 PNG 或 JPG"); return }
4081
+ if (picked.size > 300 * 1024) { setCoverErr("图片 " + Math.round(picked.size / 1024) + " KB,超过 300 KB;建议 512×512 以内"); return }
4082
+ try {
4083
+ const url = await new Promise((resolve, reject) => {
4084
+ const reader = new FileReader()
4085
+ reader.onload = () => resolve(String(reader.result || ""))
4086
+ reader.onerror = () => reject(new Error("读不了这张图"))
4087
+ reader.readAsDataURL(picked)
4088
+ })
4089
+ setCoverSrc(url)
4090
+ setCoverZoom(1)
4091
+ setCoverOffset({ x: 0, y: 0 })
4092
+ setCover("")
4093
+ } catch (e) {
4094
+ setCoverErr((e && e.message) || String(e))
4095
+ }
4096
+ }
4097
+
4098
+ // 预览:把这份本地包临时当成社区里的一条,走同一条下载 → 安装路径(不联网、不开 PR)
4099
+ // —— 封面裁切:框里拖动挑位置、滑块缩放,应用时只把框里那块导出成正方形 ——
4100
+ const COVER_FRAME = 240
4101
+ const coverImgStyle = () => ({
4102
+ position: "absolute",
4103
+ left: "50%",
4104
+ top: "50%",
4105
+ transform: "translate(-50%, -50%) translate(" + coverOffset.x + "px, " + coverOffset.y + "px) scale(" + coverZoom + ")",
4106
+ transformOrigin: "center center",
4107
+ maxWidth: "none",
4108
+ width: "100%",
4109
+ height: "100%",
4110
+ objectFit: "cover",
4111
+ pointerEvents: "none",
4112
+ userSelect: "none",
4113
+ })
4114
+ const resetCover = () => { setCoverZoom(1); setCoverOffset({ x: 0, y: 0 }) }
4115
+ const coverDown = (event) => {
4116
+ coverDrag.current = { x: event.clientX, y: event.clientY, ox: coverOffset.x, oy: coverOffset.y }
4117
+ if (event.currentTarget && event.currentTarget.setPointerCapture) { try { event.currentTarget.setPointerCapture(event.pointerId) } catch (e) { } }
4118
+ }
4119
+ const coverMove = (event) => {
4120
+ const drag = coverDrag.current
4121
+ if (!drag) return
4122
+ setCoverOffset({ x: drag.ox + (event.clientX - drag.x), y: drag.oy + (event.clientY - drag.y) })
4123
+ }
4124
+ const coverUp = () => { coverDrag.current = null }
4125
+ const applyCover = () => {
4126
+ setCoverErr("")
4127
+ if (!coverSrc) { setCoverErr("先选一张图"); return }
4128
+ const image = new window.Image()
4129
+ image.onload = () => {
4130
+ try {
4131
+ const size = coverSize
4132
+ const canvas = window.document.createElement("canvas")
4133
+ canvas.width = size
4134
+ canvas.height = size
4135
+ const ctx = canvas.getContext("2d")
4136
+ if (!ctx) throw new Error("浏览器不支持 canvas")
4137
+ const frame = COVER_FRAME
4138
+ const scale = Math.max(size / image.naturalWidth, size / image.naturalHeight) * coverZoom
4139
+ const width = image.naturalWidth * scale
4140
+ const height = image.naturalHeight * scale
4141
+ const left = size / 2 - width / 2 + (coverOffset.x / frame) * size
4142
+ const top = size / 2 - height / 2 + (coverOffset.y / frame) * size
4143
+ ctx.fillStyle = "#000" // lint-allow-color:canvas 只认具体色值,不解析 var()
4144
+ ctx.fillRect(0, 0, size, size)
4145
+ ctx.drawImage(image, left, top, width, height)
4146
+ const url = canvas.toDataURL("image/png")
4147
+ const bytes = Math.round((url.length - "data:image/png;base64,".length) * 3 / 4)
4148
+ if (bytes > 300 * 1024) { setCoverErr("裁出来的图 " + Math.round(bytes / 1024) + " KB,超过 300 KB;换小一点的规格或缩小一点再试"); return }
4149
+ setCover(url)
4150
+ } catch (e) {
4151
+ setCoverErr((e && e.message) || String(e))
4152
+ }
4153
+ }
4154
+ image.onerror = () => setCoverErr("这张图读不出来")
4155
+ image.src = coverSrc
4156
+ }
4157
+
4158
+ const previewLocal = async () => {
4159
+ if (!fileBase64 && !filePath) { setError("先选一个 .dshpack"); return }
4160
+ setPreviewBusy("preview"); setError(""); setMsg(""); setLocalPack(null)
4161
+ try {
4162
+ const data = await api("/market/preview", {
4163
+ ...(fileBase64 ? { base64: fileBase64 } : { file: filePath }),
4164
+ fileName,
4165
+ name: fields.name,
4166
+ description: fields.description,
4167
+ category,
4168
+ cover: cover || undefined,
4169
+ }, 120000)
4170
+ if (!data || data.ok !== true) throw new Error((data && data.error) || "预览失败")
4171
+ setLocalPack(data.pack)
4172
+ if (typeof props.onPreview === "function") props.onPreview(data.pack)
4173
+ setMsg("下面就是它在社区里的样子(本地模拟,还没上传);两个按钮都走真实的下载与安装流程")
4174
+ } catch (e) {
4175
+ setError((e && e.message) || String(e))
4176
+ } finally { setPreviewBusy("") }
4177
+ }
4178
+
4179
+ const submit = async (dryRun) => {
4180
+ if (!preview) { setError("先选一个包"); return }
4181
+ if (!category) { setError("选一个类型"); return }
4182
+ setBusy("submit"); setError(""); setMsg("")
4183
+ try {
4184
+ const data = await api("/upload/submit", {
4185
+ fileName,
4186
+ ...(fileBase64 ? { base64: fileBase64 } : { file: filePath }),
4187
+ category,
4188
+ edits: fields,
4189
+ homepage: fields.homepage,
4190
+ host,
4191
+ ...(dryRun ? { dryRun: true } : {}),
4192
+ ...(cover ? { cover } : {}),
4193
+ ...(host === "release" ? { repo: repoInput.trim(), tag: tagInput.trim() } : {}),
4194
+ }, 60000)
4195
+ if (!data || data.ok !== true) throw new Error((data && data.error) || "没提交成功")
4196
+ const job = (data && data.job) || null
4197
+ setMsg("已开始" + (job && job.id ? "(任务 " + job.id + ")" : "") + ":进度显示在左下角悬浮窗;完成后那一行会变成「打开 PR」,卡住会出现「我已知晓」。")
4198
+ setToken("")
4199
+ await load()
4200
+ } catch (e) {
4201
+ setError((e && e.message) || String(e))
4202
+ } finally { setBusy("") }
4203
+ }
4204
+
4205
+ const configured = Boolean(status && status.configured)
4206
+ const repo = (status && status.repo) || "Vesna-Strivozha-cn/dsh-modpack-catalog"
4207
+ const changed = preview ? ["name", "author", "description", "homepage"].filter((key) => String(fields[key] || "").trim() !== String((preview.fields && preview.fields[key]) || "").trim()) : []
4208
+ const fmt = preview ? (preview.format === "hybrid" ? "混合包" : "轻量包") : ""
4209
+ const sum = (preview && preview.summary) || {}
4210
+ const pluginItems = (preview && Array.isArray(preview.pluginList)) ? preview.pluginList : []
4211
+ const addLabel = preview ? (preview.format === "hybrid" ? "有自定义" : "无修改") : ""
4212
+
4213
+ // 步骤外壳:编号圆点 + 标题 + 右侧状态
4214
+ const stepCard = (no, title, statusNode, body) => h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px", background: "var(--mp-hover, var(--dsw-alias-bg-layer-2, transparent))" } },
4215
+ h("div", { style: { ...row, gap: "8px" } },
4216
+ h("div", { style: { width: "20px", height: "20px", borderRadius: "10px", background: "var(--mp-primary, #4C7DF0)", color: "var(--mp-on-primary, #fff)", fontSize: "11px", display: "flex", alignItems: "center", justifyContent: "center", fontWeight: 700, flexShrink: 0 } }, String(no)),
4217
+ h("div", { style: { ...strong, fontSize: "13px" } }, title),
4218
+ h("span", { style: { marginLeft: "auto" } }, statusNode)),
4219
+ body)
4220
+
4221
+ const pluginRow = (item) => h("div", { style: { ...row, gap: "6px", padding: "5px 0", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" } },
4222
+ h("span", { style: { ...strong, fontSize: "12.5px" } }, item.name),
4223
+ h("span", { style: hint }, item.latest ? "市场最新(装的时候按名字取)" : "@" + item.version),
4224
+ item.group ? h(Tag, { color: "var(--mp-primary, #4C7DF0)" }, "组:" + item.group) : null,
4225
+ h(Tag, { color: item.configMode === "custom" ? "var(--mp-warn, #ffb020)" : undefined }, item.configMode === "custom" ? "自定义配置" + (item.configKeys ? " · " + item.configKeys + " 项" : "") : "默认配置"),
4226
+ item.dataIncluded ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "带数据" + (item.dataRedacted ? " · 擦除 " + item.dataRedacted + " 处" : "")) : null,
4227
+ item.embedded ? h(Tag, null, "本体在包里") : null)
4228
+
4229
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: "12px" } },
4230
+ h("div", { style: row },
4231
+ h("button", { type: "button", style: chipBtn, onClick: props.onBack }, "← 返回"),
4232
+ h("span", { style: { ...strong, fontSize: "15px" } }, "上传我的整合包"),
4233
+ h(Tag, null, "一键提 PR"),
4234
+ h("span", { style: { ...hint, marginLeft: "auto" } }, "目录:" + repo)),
4235
+ h("div", { style: hint }, "打包好一份轻量包或混合包,在这里选它:插件自己算 sha256、写条目,再用你的 GitHub 账号 fork 目录仓库、开一个 PR。全程本机发请求,不消耗模型 token。凭据只在内存里,上传结束(成功或失败)立刻丢掉,所以每次都要重填。"),
4236
+
4237
+ stepCard(1, "GitHub 凭据",
4238
+ configured ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "已就绪") : h(Tag, null, "待填"),
4239
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
4240
+ h("div", { style: hint }, configured ? ("本次已放进内存" + (status && status.login ? ":登录为 " + status.login : "") + "(上传结束就会清掉)") : "classic token 勾 repo 就够;fine-grained 要 contents 与 pull requests 读写。只放内存,不写盘"),
4241
+ h("div", { style: row },
4242
+ h("input", {
4243
+ type: "password",
4244
+ style: { ...input, flex: "1 1 320px" },
4245
+ placeholder: configured ? "要换一个就粘贴新的 token" : "ghp_… 或 github_pat_…",
4246
+ value: token,
4247
+ onChange: (e) => setToken(e.target.value),
4248
+ }),
4249
+ h("button", { type: "button", style: btnPrimary, disabled: busy !== "" || !token.trim(), onClick: saveToken }, busy === "token" ? "保存中…" : "保存"),
4250
+ configured ? h("button", { type: "button", style: btn, disabled: busy !== "", onClick: () => { setToken(""); saveToken() } }, "清除") : null))),
4251
+
4252
+ stepCard(2, "选包",
4253
+ preview ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "已读取") : h(Tag, null, busy === "read" ? "读取中" : "待选"),
4254
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
4255
+ h("div", { style: row },
4256
+ h("input", {
4257
+ type: "file",
4258
+ accept: ".dshpack",
4259
+ ref: fileRef,
4260
+ style: { display: "none" },
4261
+ onChange: (e) => {
4262
+ const picked = e && e.target && e.target.files ? e.target.files[0] : null
4263
+ readFile(picked)
4264
+ if (e && e.target) e.target.value = ""
4265
+ },
4266
+ }),
4267
+ h("button", { type: "button", style: btn, disabled: busy !== "", onClick: () => { if (fileRef.current) fileRef.current.click() } }, busy === "read" ? "读取中…" : (preview ? "换一个文件…" : "选择文件…")),
4268
+ h("button", { type: "button", style: btn, disabled: busy !== "", onClick: browseFolder }, "浏览文件夹…"),
4269
+ preview ? h("button", { type: "button", style: btn, disabled: busy !== "", onClick: clearFile }, "清除") : null),
4270
+ preview
4271
+ ? h("div", { style: { ...box, padding: "10px 12px", background: "var(--mp-card-soft, var(--dsw-alias-bg-layer-1, transparent))", display: "flex", flexDirection: "column", gap: "6px" } },
4272
+ h("div", { style: row },
4273
+ h("span", { style: { ...strong, fontSize: "13px" } }, fileName),
4274
+ h(Tag, { color: preview.format === "hybrid" ? "var(--mp-accent, #a855f7)" : "var(--mp-primary, #4C7DF0)" }, fmt),
4275
+ h(Tag, null, addLabel),
4276
+ h(Tag, null, (preview.plugins || 0) + " 个插件")),
4277
+ h("div", { style: hint }, Math.round((preview.size || 0) / 1024) + " KB · sha256 " + String(preview.sha256 || "").slice(0, 16) + "… · " + (pluginItems.filter((item) => item.embedded).length > 0 ? "带本体 " + pluginItems.filter((item) => item.embedded).length + " 个" : "不带本体,装的时候按版本取")))
4278
+ : h("div", { style: hint }, busy === "read" ? "正在读清单…" : "还没选包:可以直接选文件,也可以用「浏览文件夹…」从某个目录里挑(跟安装页一样)"),
4279
+ dirItems.length > 0
4280
+ ? h("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } },
4281
+ h("div", { style: hint }, "这个目录里的整合包(点一个就读):" + (dir ? " " + dir : "")),
4282
+ dirItems.slice(0, 8).map((item) => h("button", {
4283
+ key: "dir-" + item.name,
4284
+ type: "button",
4285
+ style: { ...chipBtn, textAlign: "left" },
4286
+ onClick: () => readPath(item.path),
4287
+ }, item.name + " · " + Math.round(Number(item.size || 0) / 1024) + " KB")))
4288
+ : null,
4289
+ dirErr ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, dirErr) : null)),
4290
+
4291
+ preview
4292
+ ? h(FoldBox, {
4293
+ title: "这个包里大致有什么",
4294
+ defaultOpen: true,
4295
+ summary: [h(Tag, { color: preview.format === "hybrid" ? "var(--mp-accent, #a855f7)" : "var(--mp-primary, #4C7DF0)" }, fmt), h(Tag, null, (preview.plugins || 0) + " 个插件")],
4296
+ hint: "展开",
4297
+ collapsedNote: (preview.plugins || 0) + " 个插件" + (sum.configMode === "custom" ? " · " + sum.configCount + " 个带自定义配置" : " · 全部默认配置") + (sum.dataCount ? " · " + sum.dataCount + " 个带数据" : "") + (sum.redacted ? " · 擦除 " + sum.redacted + " 处凭据" : "") + "(点标题展开)",
4298
+ },
4299
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } },
4300
+ h("div", { style: row },
4301
+ h(Tag, { color: sum.configMode === "custom" ? "var(--mp-warn, #ffb020)" : "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, sum.configMode === "custom" ? "有自定义配置:" + sum.configCount + " 个" : "全部默认配置"),
4302
+ sum.dataCount ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "带数据:" + sum.dataCount + " 个") : h(Tag, null, "不带数据"),
4303
+ sum.redacted ? h(Tag, { color: "var(--mp-warn, #ffb020)" }, "擦除凭据:" + sum.redacted + " 处") : null,
4304
+ (sum.groups && sum.groups.length) ? h(Tag, { color: "var(--mp-primary, #4C7DF0)" }, "分组:" + sum.groups.join("、")) : null),
4305
+ h("div", { style: { ...hint, marginTop: "4px" } }, "每个插件默认都是「默认配置」;打包时单独选成「自定义配置」或带上了数据/凭据的,会在下面单独标出来。这里只数清单里的顶层插件,插件自己带的组件不算。"),
4306
+ pluginItems.length > 0
4307
+ ? pluginItems.map((item) => h("div", { key: "pv-" + item.name }, pluginRow(item)))
4308
+ : h("div", { style: hint }, "清单里没有插件?这个包可能不是用本插件打的。")))
4309
+ : null,
4310
+
4311
+ preview
4312
+ ? stepCard(3, "改一下词条", changed.length > 0 ? h(Tag, { color: "var(--mp-primary, #4C7DF0)" }, "将改 " + changed.length + " 项") : h(Tag, null, "不改"),
4313
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
4314
+ h("div", { style: hint }, "名称、作者、简介、主页如果改过,会写回包里的 dsh-modpack.json,再重算 sha256 与条目——目录里显示的、别人装到的都是改后的内容。"),
4315
+ h("div", { style: row },
4316
+ h("input", { style: { ...input, flex: "1 1 220px" }, placeholder: "名称", value: fields.name, onChange: (e) => setFields({ ...fields, name: e.target.value }) }),
4317
+ h("input", { style: { ...input, flex: "1 1 160px" }, placeholder: "作者", value: fields.author, onChange: (e) => setFields({ ...fields, author: e.target.value }) })),
4318
+ h("textarea", {
4319
+ style: { ...input, minHeight: "76px", resize: "vertical", padding: "6px 8px", lineHeight: "18px" },
4320
+ placeholder: "简介:这包是做什么的、适合谁",
4321
+ value: fields.description,
4322
+ onChange: (e) => setFields({ ...fields, description: e.target.value }),
4323
+ }),
4324
+ h("div", { style: row },
4325
+ h("input", { style: { ...input, flex: "1 1 240px" }, placeholder: "项目主页(可不填)", value: fields.homepage, onChange: (e) => setFields({ ...fields, homepage: e.target.value }) }),
4326
+ h("select", { style: { ...input, maxWidth: "200px" }, value: category, onChange: (e) => setCategory(e.target.value) },
4327
+ UPLOAD_CATEGORIES.map((name) => h("option", { key: "cat-" + name, value: name }, name)))),
4328
+ changed.length > 0
4329
+ ? h("div", { style: { ...hint, color: "var(--mp-primary, #4C7DF0)" } }, "会改:" + changed.map((key) => (({ name: "名称", author: "作者", description: "简介", homepage: "主页" })[key])).join("、"))
4330
+ : h("div", { style: hint }, "没改任何一项:按包里的清单原样提交。")))
4331
+ : null,
4332
+
4333
+ stepCard(5, "封面图(可选)", h(Tag, null, cover ? "已裁好 " + coverSize + "×" + coverSize : (coverSrc ? "待裁切" : "没有封面")),
4334
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
4335
+ h("div", { style: hint }, "PNG / JPG。先选图,再在框里拖动、缩放挑出要上传的部分;上传时只传框里这一块(输出 " + coverSize + "×" + coverSize + ",PNG,300 KB 以内)。它会出现在社区列表与详情里。"),
4336
+ h("div", { style: row },
4337
+ h("input", { ref: coverRef, type: "file", accept: "image/png,image/jpeg", style: { display: "none" }, onChange: (e) => { const f = e.target.files && e.target.files[0]; if (coverRef.current) coverRef.current.value = ""; pickCover(f) } }),
4338
+ h("button", { type: "button", style: btn, onClick: () => { if (coverRef.current) coverRef.current.click() } }, coverSrc ? "换一张" : "选择图片…"),
4339
+ h("span", { style: hint }, "规格"),
4340
+ h("select", { style: { ...input, maxWidth: "120px" }, value: String(coverSize), onChange: (e) => setCoverSize(Number(e.target.value)) },
4341
+ [256, 512].map((size) => h("option", { key: "cs-" + size, value: String(size) }, size + "×" + size))),
4342
+ cover ? h("button", { type: "button", style: btn, onClick: () => { setCover(""); setCoverSrc("") } }, "去掉") : null),
4343
+ coverSrc
4344
+ ? h("div", { style: { display: "flex", gap: "12px", alignItems: "flex-start", flexWrap: "wrap" } },
4345
+ h("div", {
4346
+ ref: coverFrameRef,
4347
+ onPointerDown: coverDown,
4348
+ onPointerMove: coverMove,
4349
+ onPointerUp: coverUp,
4350
+ onPointerCancel: coverUp,
4351
+ style: { position: "relative", width: COVER_FRAME + "px", height: COVER_FRAME + "px", overflow: "hidden", borderRadius: "10px", border: "1px solid var(--mp-primary, #4C7DF0)", background: "var(--mp-text, #000)", cursor: "grab", touchAction: "none", flex: "0 0 auto" },
4352
+ },
4353
+ h("img", {
4354
+ src: coverSrc,
4355
+ alt: "",
4356
+ draggable: false,
4357
+ style: coverImgStyle(),
4358
+ }),
4359
+ h("div", { style: { position: "absolute", inset: 0, border: "2px dashed rgba(255,255,255,0.55)", borderRadius: "10px", pointerEvents: "none" } })),
4360
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "6px", minWidth: "180px" } },
4361
+ h("div", { style: hint }, "拖动图片挑位置;下面的滑块放大 / 缩小。"),
4362
+ h("input", { type: "range", min: "1", max: "3", step: "0.01", value: String(coverZoom), onChange: (e) => setCoverZoom(Number(e.target.value)) }),
4363
+ h("div", { style: row },
4364
+ h("button", { type: "button", style: btnPrimary, onClick: applyCover }, "应用这块"),
4365
+ h("button", { type: "button", style: btn, onClick: resetCover }, "复位")),
4366
+ h("div", { style: hint }, "预览:" + (cover ? "已按上面框里那块生成 " + coverSize + "×" + coverSize + " 的图" : "还没应用"))))
4367
+ : null,
4368
+ cover ? h("div", { style: row },
4369
+ h("img", { src: cover, alt: "", style: { height: "52px", width: "52px", objectFit: "cover", borderRadius: "6px", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))" } }),
4370
+ h("span", { style: hint }, "上传的就是这一张(列表 42×42、详情 88×88 都按它缩)")) : null,
4371
+ coverErr ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, coverErr) : null,
4372
+ h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, "严禁上传与整合包无关、侵权或违规的图片:目录是公开的,图片会随条目一起公开显示。"))),
4373
+
4374
+ stepCard(6, "预览",
4375
+ h(Tag, null, localPack ? "已放进社区列表" : "还没预览"),
4376
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
4377
+ h("div", { style: hint }, "预览不是在这里看:会把这份包当成社区里的一条放进「整合包」列表顶部,带橙色「测试预览」标记。点进去能走真实的下载到本地 / 下载并安装,但不会上传、不开 PR、不联网。"),
4378
+ h("div", { style: row },
4379
+ h("button", { type: "button", style: btn, disabled: previewBusy !== "" || busy !== "", onClick: previewLocal }, previewBusy === "preview" ? "准备中…" : "在列表里预览")))),
4380
+
4381
+ stepCard(4, "放在哪",
4382
+ h(Tag, null, host === "release" ? "Release 资产" : "目录仓库"),
4383
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
4384
+ h("div", { style: row },
4385
+ h("button", { type: "button", style: host === "repo" ? btnPrimary : btn, onClick: () => setHost("repo") }, "放进目录仓库"),
4386
+ h("button", { type: "button", style: host === "release" ? btnPrimary : btn, onClick: () => setHost("release") }, "放进我的 Release(真实下载量)")),
4387
+ host === "release"
4388
+ ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "6px" } },
4389
+ h("div", { style: hint }, "会传到你自己仓库的 Release 资产里(你必须有这个仓库的写权限)。目录构建时读它的 download_count,列表里就能显示真实下载次数。"),
4390
+ h("div", { style: row },
4391
+ h("input", { style: { ...input, flex: "1 1 240px" }, placeholder: "你的仓库:owner/name", value: repoInput, onChange: (e) => setRepoInput(e.target.value) }),
4392
+ h("input", { style: { ...input, maxWidth: "200px" }, placeholder: "tag(默认 packs-<id>)", value: tagInput, onChange: (e) => setTagInput(e.target.value) })))
4393
+ : h("div", { style: hint }, "放进目录仓库最简单:只有这一次 PR,不占你自己的仓库;缺点是没有逐文件下载计数,列表里显示「下载量未统计」。"),
4394
+ h("div", { style: hint }, "只收轻量包(无修改)和混合包(有自定义);完整包请放到发布页。"))),
4395
+
4396
+ h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px", borderColor: "var(--mp-primary, #4C7DF0)" } },
4397
+ h("div", { style: row },
4398
+ h("button", { type: "button", style: { ...btnPrimary, height: "32px", padding: "0 16px", fontSize: "13px" }, disabled: busy !== "" || !preview || !configured, onClick: () => submit(false) }, busy === "submit" ? "提交中…" : "确认上传(开 PR)"),
4399
+ h("button", { type: "button", style: { ...chipBtn, height: "32px", padding: "0 14px", fontSize: "13px" }, disabled: busy !== "" || !preview, title: "把整套检查跑一遍(类型、读包、封面、条目),但不碰 GitHub、不开 PR、不需要凭据", onClick: () => submit(true) }, busy === "dry" ? "演练中…" : "演练一次(不真上传)"),
4400
+ h("span", { style: hint }, configured ? (preview ? ("将提交:" + (fields.name || fileName) + " · " + category + " · " + (host === "release" ? "Release" : "目录仓库") + (changed.length ? " · 改 " + changed.length + " 项词条" : " · 词条不改")) : "先选一个包") : "先保存凭据")),
4401
+ h("div", { style: hint }, "提交后进入任务队列:进度显示在左下角悬浮窗,完成给「打开 PR」,卡住给「我已知晓」。")),
4402
+
4403
+ msg ? h("div", { style: { ...box, padding: "10px 12px", borderColor: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))", color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))", fontSize: "12.5px", lineHeight: "19px" } }, msg) : null,
4404
+ error ? h("div", { style: { ...box, padding: "10px 12px", borderColor: "var(--mp-danger, #ff6b6b)", color: "var(--mp-danger, #ff6b6b)", fontSize: "12.5px", lineHeight: "19px" } }, error) : null)
4405
+ }
4406
+
4407
+ // ===== [区块] 社区资源小插件:整合包浏览(列表 / 详情 / 上传规则) ====
2413
4408
  function ModpackBrowser(props) {
2414
4409
  const packSnap = readMarketUi().pack || {}
2415
- const [view, setView] = useState(packSnap.view === "detail" || packSnap.view === "rules" ? packSnap.view : "list")
4410
+ const [view, setView] = useState(packSnap.view === "detail" || packSnap.view === "rules" || packSnap.view === "upload" ? packSnap.view : "list")
2416
4411
  const [summary, setSummary] = useState(packSnap.summary || null)
2417
4412
  const [items, setItems] = useState(Array.isArray(packSnap.items) ? packSnap.items : [])
2418
4413
  const [total, setTotal] = useState(Number(packSnap.total) || 0)
@@ -2427,6 +4422,20 @@ window.__ModuleLoader__.load({
2427
4422
  const [error, setError] = useState("")
2428
4423
  const [msg, setMsg] = useState("")
2429
4424
  const [detail, setDetail] = useState(packSnap.detail || null)
4425
+ // 本机情况一律按「目录里的插件清单 × 本机已装」算:不下载包、不额外请求
4426
+ const packPlugins = (detail && Array.isArray(detail.plugins)) ? detail.plugins : []
4427
+ const installedNames = new Set((((props.status || {}).installed) || []).map((item) => item.name))
4428
+ const packMissing = packPlugins.filter((item) => !installedNames.has(item.name))
4429
+ const packInstalledCount = packPlugins.length - packMissing.length
4430
+
4431
+ // 本地预览:把还没上传的包当成社区里的一条,放在列表最上面(只在这台机器上模拟)
4432
+ const [previewPack, setPreviewPack] = useState(null)
4433
+ const openPreview = (pack) => {
4434
+ setPreviewPack(pack ? { ...pack, preview: true } : null)
4435
+ setDetail(null)
4436
+ setView("list")
4437
+ setMsg(pack ? "预览:这份包现在放在列表最上面(橙色「测试预览」标记),点进去能试下载与安装;它不会真的上传。" : "")
4438
+ }
2430
4439
  const [descOpen, setDescOpen] = useState(packSnap.descOpen !== false)
2431
4440
  const [descTick, setDescTick] = useState(0)
2432
4441
  const [downloading, setDownloading] = useState(false)
@@ -2439,6 +4448,7 @@ window.__ModuleLoader__.load({
2439
4448
  saveMarketUi("pack", { view, summary, items, total, page, hasMore, query, category, sort, detail, dataReady: true })
2440
4449
  }, [view, summary, items, total, page, hasMore, query, category, sort, detail])
2441
4450
 
4451
+
2442
4452
  // 打开详情时补齐插件介绍:包里写了就用包里的,没写就问插件市场的目录
2443
4453
  useEffect(() => {
2444
4454
  if (view !== "detail" || !detail) return undefined
@@ -2541,13 +4551,18 @@ window.__ModuleLoader__.load({
2541
4551
  }
2542
4552
  }
2543
4553
 
2544
- const download = async (pack) => {
4554
+ const download = async (pack, saveOnly) => {
2545
4555
  setDownloading(true); setError(""); setMsg("")
2546
4556
  try {
2547
- const data = await api("/market/download", { id: pack.id })
4557
+ const data = await api("/market/download", saveOnly ? { id: pack.id, saveOnly: true } : { id: pack.id })
4558
+ if (saveOnly) {
4559
+ if (!data || data.ok !== true) { setError((data && data.error) || "下载失败"); return }
4560
+ setMsg("已下到本机:" + (data.savedName || pack.name) + "(在插件自己的 packs 目录,安装页「已下载的整合包」里能选到)")
4561
+ return
4562
+ }
2548
4563
  if (!data || data.ok !== true) { setError((data && data.error) || "下载失败"); return }
2549
4564
  requestInstall({ token: data.token, fileName: data.fileName, packName: pack.name })
2550
- setMsg("已下载并读取:" + pack.name + ",正在转到安装页")
4565
+ setMsg("已下载并读取:" + pack.name + (data && data.savedName ? "(也存了一份:" + data.savedName + ")" : "") + ",正在转到安装页")
2551
4566
  if (typeof props.onGoInstall === "function") props.onGoInstall()
2552
4567
  } catch (e) {
2553
4568
  setError((e && e.message) || String(e))
@@ -2556,17 +4571,35 @@ window.__ModuleLoader__.load({
2556
4571
  }
2557
4572
  }
2558
4573
 
4574
+ // 封面:目录条目里存 covers/<id>.png 这种相对路径,这里拼 CDN(取不到就看 raw)
4575
+ const coverUrl = (pack) => {
4576
+ const rel = pack && typeof pack.cover === "string" ? pack.cover.trim() : ""
4577
+ if (!rel) return ""
4578
+ if (rel.startsWith("data:image/")) return rel
4579
+ const repo = (pack && pack.repo) || ((props.status || {}).modpackMarket || {}).repo || "Vesna-Strivozha-cn/dsh-modpack-catalog"
4580
+ return "https://cdn.jsdelivr.net/gh/" + repo + "@main/" + rel.split("/").map(encodeURIComponent).join("/")
4581
+ }
4582
+ const coverImg = (pack, size) => {
4583
+ const url = coverUrl(pack)
4584
+ if (!url) return null
4585
+ return h("img", {
4586
+ src: url,
4587
+ alt: "",
4588
+ style: { width: size + "px", height: size + "px", borderRadius: "6px", objectFit: "cover", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", flex: "0 0 auto" },
4589
+ })
4590
+ }
4591
+
2559
4592
  // 分类英文名(目录里只存中文 label,英文界面在这里映射)
2560
4593
  const catLabel = (name) => name
2561
- const CATEGORY_TINT = { 工作办公: "#4C7DF0", 性能优化: "#2bb673", 界面美化: "#a855f7", 实用功能: "#0ea5e9", 开发调试: "#f59e0b", 娱乐休闲: "#ec4899", 学习资料: "#14b8a6", 水槽: "#7c3aed", 其它: "#64748b" }
4594
+ const CATEGORY_TINT = { 工作办公: "var(--mp-primary, #4C7DF0)", 性能优化: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))", 界面美化: "var(--mp-accent, #a855f7)", 实用功能: "var(--mp-accent, #0ea5e9)", 开发调试: "var(--mp-warn, #f59e0b)", 娱乐休闲: "var(--mp-accent, #ec4899)", 学习资料: "var(--mp-accent, #14b8a6)", 水槽: "var(--mp-accent, #7c3aed)", 其它: "var(--mp-muted, var(--dsw-alias-label-tertiary, #64748b))" }
2562
4595
  const initialsOf = (name) => String(name || "?").replace(/\s+/gu, "").slice(0, 2) || "?"
2563
4596
  // 体量词条:不靠作者写,按插件总数自动算(0-3 轻量 / 4-8 中型 / 9-12 大型 / 13+ 大宗)
2564
4597
  const TIER_LABELS = { small: "轻量", medium: "中型", large: "大型", huge: "大宗" }
2565
- const TIER_COLORS = { small: "#2bb673", medium: "#0ea5e9", large: "#f59e0b", huge: "#ec4899" }
4598
+ const TIER_COLORS = { small: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))", medium: "var(--mp-accent, #0ea5e9)", large: "var(--mp-warn, #f59e0b)", huge: "var(--mp-accent, #ec4899)" }
2566
4599
  const tierInfo = (pack) => {
2567
4600
  const count = Array.isArray(pack.plugins) ? pack.plugins.length : 0
2568
4601
  const id = pack.tier || (count >= 13 ? "huge" : count >= 9 ? "large" : count >= 4 ? "medium" : "small")
2569
- return { id, color: TIER_COLORS[id] || "#64748b", text: TIER_LABELS[id] || "轻量" }
4602
+ return { id, color: TIER_COLORS[id] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #64748b))", text: TIER_LABELS[id] || "轻量" }
2570
4603
  }
2571
4604
  const tierTag = (pack) => {
2572
4605
  const info = tierInfo(pack)
@@ -2589,7 +4622,7 @@ window.__ModuleLoader__.load({
2589
4622
  return text || "作者没写说明。"
2590
4623
  }
2591
4624
  const renderRow = (pack) => {
2592
- const tint = CATEGORY_TINT[pack.category] || "#64748b"
4625
+ const tint = CATEGORY_TINT[pack.category] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #64748b))"
2593
4626
  const plugins = pack.plugins || []
2594
4627
  const meta = []
2595
4628
  meta.push(plugins.length + " 个插件")
@@ -2601,12 +4634,12 @@ window.__ModuleLoader__.load({
2601
4634
  return h("div", {
2602
4635
  key: "pack-" + pack.id,
2603
4636
  onClick: () => { setDetail(pack); setView("detail"); setError(""); setMsg("") },
2604
- style: { display: "flex", gap: "10px", padding: "10px 12px", borderTop: "0.5px solid var(--dsw-alias-border-l2)", cursor: "pointer", alignItems: "flex-start" },
4637
+ style: { display: "flex", gap: "10px", padding: "10px 12px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", cursor: "pointer", alignItems: "flex-start" },
2605
4638
  },
2606
- h("div", {
4639
+ coverImg(pack, 42) || h("div", {
2607
4640
  style: {
2608
4641
  width: "42px", height: "42px", flexShrink: 0, borderRadius: "8px",
2609
- background: tint, color: "#fff", fontSize: "13px", fontWeight: 600,
4642
+ background: tint, color: "var(--mp-on-primary, #fff)", fontSize: "13px", fontWeight: 600,
2610
4643
  display: "flex", alignItems: "center", justifyContent: "center", letterSpacing: "0.5px",
2611
4644
  },
2612
4645
  }, initialsOf(pack.name)),
@@ -2615,12 +4648,15 @@ window.__ModuleLoader__.load({
2615
4648
  h("span", { style: { fontWeight: 600, fontSize: "13.5px" } }, pack.name),
2616
4649
  h(Tag, null, catLabel(pack.category || "其它")),
2617
4650
  tierTag(pack),
2618
- h(Tag, null, "v" + pack.version),
2619
- pack.installed && pack.installed.all ? h("span", { style: { ...hint, color: "#2bb673" } }, "已装") : null,
2620
- pack.installed && pack.installed.some && !pack.installed.all ? h("span", { style: hint }, "部分已装") : null),
4651
+ h(Tag, { title: pack.customization === "custom" ? "这份包带着作者本地的配置或改动" : "只记版本,没有任何本地改动" }, pack.customization === "custom" ? "有自定义" : "无修改"),
4652
+ pack.version ? h(Tag, null, "v" + pack.version) : null,
4653
+ pack.preview ? h(Tag, { color: "var(--mp-warn, #f59e0b)", title: "只在这台机器上模拟,没有上传" }, "测试预览") : null,
4654
+ ),
2621
4655
  h("span", { style: { ...hint, display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical", overflow: "hidden", lineHeight: "18px" } }, descOf(pack)),
4656
+ pack.preview ? h("span", { style: { ...hint, color: "var(--mp-warn, #ffb020)" } }, "测试预览 · 没上传,也没开 PR") : null,
2622
4657
  h("div", { style: { ...row, gap: "14px" } }, meta.map((line, index) => h("span", { key: "meta-" + pack.id + "-" + index, style: hint }, line)))))
2623
4658
  }
4659
+ const rows = previewPack ? [previewPack].concat(items.filter((item) => item.id !== previewPack.id)) : items
2624
4660
  const resetFilters = () => { setQuery(""); setCategory("all"); setSort("new"); setPage(1); setSearchTick((n) => n + 1) }
2625
4661
 
2626
4662
  const head = h("div", { style: { ...row, justifyContent: "space-between" } },
@@ -2629,18 +4665,23 @@ window.__ModuleLoader__.load({
2629
4665
  present ? h(Tag, null, total + " 个") : null,
2630
4666
  present ? h("span", { style: hint }, "目录来自 " + (summary.repo || "dsh-modpack-catalog") + (summary.builtAt ? " · 构建于 " + String(summary.builtAt).slice(0, 10) : "")) : null),
2631
4667
  h("div", { style: row },
4668
+ h("button", { type: "button", style: chipBtn, onClick: () => { setView("upload"); setDetail(null) } }, "上传我的整合包"),
2632
4669
  h("button", { type: "button", style: chipBtn, onClick: () => { setView("rules"); setDetail(null) } }, "上传方式与规则"),
2633
4670
  h("button", { type: "button", style: chipBtn, disabled: syncing, onClick: syncNow }, syncing ? "更新中…" : "更新目录")))
2634
4671
 
4672
+ if (view === "upload") {
4673
+ return h(UploadPanel, { onBack: () => setView("list"), onPreview: openPreview })
4674
+ }
4675
+
2635
4676
  if (view === "rules") {
2636
4677
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
2637
4678
  h("div", { style: row },
2638
4679
  h("button", { type: "button", style: chipBtn, onClick: () => setView("list") }, "← 返回市场"),
2639
4680
  h("span", { style: { ...strong, fontSize: "14px" } }, "上传方式与规则")),
2640
- h("div", { style: { ...hint, lineHeight: "20px" } }, "第一阶段只收轻量包;审核与出问题下架都靠 PR 与 issue,和插件市场一样。"),
4681
+ h("div", { style: { ...hint, lineHeight: "20px" } }, "收轻量包(无修改)与混合包(有自定义);审核与出问题下架都靠 PR 与 issue,和插件市场一样。"),
2641
4682
  h("ol", { style: { margin: 0, paddingLeft: "18px", display: "flex", flexDirection: "column", gap: "8px" } },
2642
4683
  MARKET_RULES.map((line, index) => h("li", { key: "rule-" + index, style: { fontSize: "12.5px", lineHeight: "19px" } }, line))),
2643
- h("div", { style: { border: "1px dashed var(--dsw-alias-border-l2)", borderRadius: "8px", padding: "10px", display: "flex", flexDirection: "column", gap: "4px" } },
4684
+ h("div", { style: { border: "1px dashed var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "8px", padding: "10px", display: "flex", flexDirection: "column", gap: "4px" } },
2644
4685
  h("span", { style: strong }, "清单长这样"),
2645
4686
  h("code", { style: { fontSize: "11.5px", whiteSpace: "pre-wrap", lineHeight: "17px" } },
2646
4687
  '{\n "id": "bili-trio",\n "category": "实用功能",\n "file": "bili-trio-lite.dshpack",\n "sha256": "…64 位…",\n "createdAt": "2026-11-27",\n "updatedAt": "2026-11-27",\n "homepage": ""\n}\n\n// 名称、作者、介绍、插件清单不写在这里:\n// 全部取包里的 dsh-modpack.json(打包时填的)')),
@@ -2657,22 +4698,37 @@ window.__ModuleLoader__.load({
2657
4698
  h("span", { style: { ...strong, fontSize: "15px" } }, pack.name),
2658
4699
  h(Tag, null, catLabel(pack.category || "其它")),
2659
4700
  tierTag(pack),
2660
- h("span", { style: hint }, "v" + pack.version + " · 作者 " + (pack.author || "?") + " · " + sizeText(pack.size) + " · " + plugins.length + " 个插件")),
4701
+ h(Tag, { title: pack.customization === "custom" ? "这份包带着作者本地的配置或改动" : "只记版本,没有任何本地改动" }, pack.customization === "custom" ? "有自定义" : "无修改"),
4702
+ pack.preview ? h(Tag, { color: "var(--mp-warn, #f59e0b)", title: "只在这台机器上模拟,没有上传" }, "测试预览") : null,
4703
+ h("span", { style: hint }, (pack.version ? "v" + pack.version + " · " : "") + "作者 " + (pack.author || "?") + " · " + sizeText(pack.size) + " · " + plugins.length + " 个插件")),
4704
+ coverImg(pack, 88) || null,
2661
4705
  h("div", { style: { ...hint, lineHeight: "20px" } },
2662
4706
  pack.downloads === null || pack.downloads === undefined
2663
4707
  ? "下载量:暂无统计(安装文件放在 Git 仓库里,没有逐文件计数;放进 GitHub Release 资源才拿得到真实下载数)"
2664
4708
  : "下载 " + Number(pack.downloads) + " 次(这个安装文件本身的下载量,不是里面插件的)"
2665
4709
  + " · 创建 " + (pack.createdAt ? String(pack.createdAt).slice(0, 10) : "未记录")
2666
4710
  + " · 上次更新 " + (pack.updatedAt ? String(pack.updatedAt).slice(0, 10) : (pack.createdAt ? String(pack.createdAt).slice(0, 10) : "未记录"))),
2667
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "8px" } },
4711
+ h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "8px" } },
2668
4712
  h("span", { style: strong }, "这个整合包是做什么的"),
2669
4713
  h("div", { style: { fontSize: "12.5px", lineHeight: "20px" } }, descOf(pack)),
2670
- pack.installed && pack.installed.all
2671
- ? h("div", { style: { ...hint, color: "#2bb673" } }, "这台机器上已经装齐了它包含的插件,可以只下载留存或再装一遍。")
2672
- : pack.installed && pack.installed.some
2673
- ? h("div", { style: hint }, "本机已装 " + pack.installed.count + " / " + plugins.length + " 个,安装时会先跳过已装的那些。")
2674
- : null),
2675
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
4714
+ ),
4715
+ h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
4716
+ h("div", { style: row },
4717
+ h("span", { style: strong }, "本机情况"),
4718
+ h(Tag, { title: "只数包里清单列的顶层插件;壁纸引擎那类组件不算" }, "已装 " + packInstalledCount + " / " + packPlugins.length),
4719
+ packMissing.length
4720
+ ? h(Tag, { title: "这些插件在你本机还没装" }, "缺 " + packMissing.length + " 个")
4721
+ : h("span", { style: { ...hint, color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, "都装了")),
4722
+ packMissing.length
4723
+ ? h("div", { style: { fontSize: "12.5px", lineHeight: "19px" } }, "本机还没装:" + packMissing.map((item) => item.name + (item.latest !== false ? "(装的时候取市场最新)" : (item.version ? "@" + item.version : ""))).join("、"))
4724
+ : h("div", { style: { ...hint, color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, "包里的插件本机都有,无需安装"),
4725
+ detail.hasSpecialConfig
4726
+ ? h("div", { style: { fontSize: "12.5px", lineHeight: "19px" } }, "包里带了特殊配置:" + (detail.configPlugins || []).map((item) => item.name + "(" + item.keys + " 个键)").join("、") + ";安装时可以选择「包内配置」或「保持本机」。")
4727
+ : h("div", { style: hint }, "包里没有单独的配置改动:插件都用各自的默认配置。"),
4728
+ detail.hasData ? h("div", { style: hint }, "还带着数据快照(安装时默认不覆盖你已有的文件,会问你要不要写回)。") : null,
4729
+ detail.redactedTotal ? h("div", { style: hint }, "其中 " + detail.redactedTotal + " 处疑似凭据已被替换成 ${REDACTED},装完要自己重填。") : null,
4730
+ detail.groups && detail.groups.length ? h("div", { style: hint }, "带了分组:" + detail.groups.join("、") + "(本机装了插件市场就并进同名组)") : null),
4731
+ h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
2676
4732
  h("div", { style: { ...row, justifyContent: "space-between" } },
2677
4733
  h("span", { style: strong }, "包含的插件(这些插件会干什么)"),
2678
4734
  plugins.length === 0 ? null : h("button", {
@@ -2683,26 +4739,27 @@ window.__ModuleLoader__.load({
2683
4739
  }, descOpen ? "收起介绍" : "显示介绍")),
2684
4740
  plugins.length === 0
2685
4741
  ? h("span", { style: hint }, "清单里没有插件记录。")
2686
- : plugins.map((plugin) => h("div", { key: "p-" + plugin.name, style: { display: "flex", flexDirection: "column", gap: "2px", borderTop: "0.5px solid var(--dsw-alias-border-l2)", paddingTop: "6px" } },
4742
+ : plugins.map((plugin) => h("div", { key: "p-" + plugin.name, style: { display: "flex", flexDirection: "column", gap: "2px", borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", paddingTop: "6px" } },
2687
4743
  h("div", { style: row },
2688
4744
  h("span", { style: { fontSize: "12.5px", fontWeight: 600 } }, plugin.name),
2689
4745
  h(Tag, null, plugin.version ? "@" + plugin.version : "@市场最新")),
2690
4746
  descOpen ? h("span", { style: hint }, pluginDescOf(plugin)) : null)),
2691
4747
  h("span", { style: hint }, "安装时按上面的版本从插件市场取包;取不到就明确报错,不会拿别的东西顶替。"),
2692
4748
  h("span", { style: hint }, "这里只数清单里的顶层插件;像壁纸引擎那样由插件自己带的一组组件不算在里面,装好后由那个插件自己管理。")),
2693
- h("div", { style: { border: "1px dashed var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
4749
+ h("div", { style: { border: "1px dashed var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
2694
4750
  h("span", { style: strong }, "下载码"),
2695
4751
  h("code", { style: { fontSize: "11.5px", whiteSpace: "pre-wrap", lineHeight: "17px", wordBreak: "break-all" } }, downloadCode),
2696
4752
  h("span", { style: hint }, "下载码就是包的直链 + sha256:谁拿到都能自己下载核对,不依赖这个界面。")),
2697
- error ? h("div", { style: { ...hint, color: "#ff6b6b" } }, error) : null,
4753
+ error ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, error) : null,
2698
4754
  msg ? h("div", { style: hint }, msg) : null,
2699
4755
  h("div", { style: row },
2700
- h("button", { type: "button", style: btnPrimary, disabled: downloading, onClick: () => download(pack) }, downloading ? "下载中…" : "下载并安装"),
4756
+ h("button", { type: "button", style: btn, disabled: downloading, onClick: () => download(pack, true) }, downloading ? "下载中…" : "下载到本地"),
4757
+ h("button", { type: "button", style: btnPrimary, disabled: downloading, onClick: () => download(pack, false) }, downloading ? "下载中…" : "下载并安装"),
2701
4758
  h("span", { style: hint }, "下载后在内存里校验 sha256、跑一遍安全检测,再转到安装页读取;半成品不会留在磁盘上。")))
2702
4759
  }
2703
4760
 
2704
4761
  const searchCard = h("div", {
2705
- style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "10px" },
4762
+ style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "10px" },
2706
4763
  },
2707
4764
  h("div", { style: { ...row, justifyContent: "space-between" } },
2708
4765
  h("span", { style: { ...strong, fontSize: "13px" } }, "搜索整合包"),
@@ -2714,19 +4771,19 @@ window.__ModuleLoader__.load({
2714
4771
  value: query,
2715
4772
  placeholder: "整合包名 / 作者 / 插件名(例如 B站、壁纸、记忆)",
2716
4773
  onChange: (event) => { setQuery(event.target.value); setPage(1) },
2717
- style: { height: "30px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "inherit", padding: "0 8px", fontSize: "12.5px" },
4774
+ style: { height: "30px", borderRadius: "6px", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-card-soft, transparent)", color: "var(--mp-text, var(--dsw-alias-label-primary))", padding: "0 8px", fontSize: "12.5px" },
2718
4775
  }),
2719
4776
  h("span", { style: hint }, "类型"),
2720
4777
  h("select", {
2721
4778
  value: category,
2722
4779
  onChange: (event) => { setCategory(event.target.value); setPage(1) },
2723
- style: { height: "30px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "inherit", fontSize: "12.5px" },
4780
+ style: { height: "30px", borderRadius: "6px", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-card-soft, transparent)", color: "var(--mp-text, var(--dsw-alias-label-primary))", fontSize: "12.5px" },
2724
4781
  }, chips.map((chip) => h("option", { key: "sel-" + chip.id, value: chip.id }, chip.label + "(" + (chip.count || 0) + ")"))),
2725
4782
  h("span", { style: hint }, "排序"),
2726
4783
  h("select", {
2727
4784
  value: sort,
2728
4785
  onChange: (event) => { setSort(event.target.value); setPage(1) },
2729
- style: { height: "30px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "inherit", fontSize: "12.5px" },
4786
+ style: { height: "30px", borderRadius: "6px", border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", background: "var(--mp-card-soft, transparent)", color: "var(--mp-text, var(--dsw-alias-label-primary))", fontSize: "12.5px" },
2730
4787
  }, MARKET_SORTS.map(([value, text]) => h("option", { key: value, value }, text)))),
2731
4788
  h("div", { style: row },
2732
4789
  h("button", { type: "button", style: { ...btn, minWidth: "96px" }, disabled: searching, onClick: () => setSearchTick((n) => n + 1) }, searching ? "搜索中…" : "搜索"),
@@ -2734,7 +4791,7 @@ window.__ModuleLoader__.load({
2734
4791
  h("button", { type: "button", style: { ...btn, minWidth: "128px" }, onClick: () => { if (typeof props.onGoInstall === "function") props.onGoInstall() } }, "安装已有整合包"),
2735
4792
  h("span", { style: { ...hint, marginLeft: "auto" } }, "共 " + total + " 个")))
2736
4793
 
2737
- const emptyCard = h("div", { style: { border: "1px dashed var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "8px" } },
4794
+ const emptyCard = h("div", { style: { border: "1px dashed var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", padding: "16px", display: "flex", flexDirection: "column", gap: "8px" } },
2738
4795
  h("span", { style: strong }, query ? "没有匹配的整合包" : present ? "这个类型下还没有整合包" : "还没有整合包目录"),
2739
4796
  h("span", { style: hint }, query
2740
4797
  ? "换个说法试试:整合包名、作者名、插件名都能搜。"
@@ -2750,32 +4807,47 @@ window.__ModuleLoader__.load({
2750
4807
  ? h("span", { style: { ...hint, lineHeight: "19px" } }, "网络正常但接口报 404/405 的话,是宿主还跑着旧代码:把 DSH 完全退出再打开,这一栏就会生效。")
2751
4808
  : null)
2752
4809
 
2753
- const listBox = items.length > 0
2754
- ? h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", overflow: "hidden" } }, items.map(renderRow))
4810
+ const listBox = rows.length > 0
4811
+ ? h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", overflow: "hidden" } },
4812
+ previewPack
4813
+ ? h("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "7px 12px", background: "var(--mp-warn-soft, rgba(255, 154, 60, 0.12))", borderBottom: "0.5px solid var(--mp-warn-line, rgba(255, 154, 60, 0.45))", color: "var(--mp-warn, #ffb020)", fontSize: "11.5px" } },
4814
+ h(Tag, { color: "var(--mp-warn, #f59e0b)" }, "测试预览"),
4815
+ h("span", null, "这一条只在本机模拟:没上传、没开 PR,也不会出现在别人的社区列表里"),
4816
+ h("button", { type: "button", style: chipBtn, onClick: () => { setPreviewPack(null); setMsg("") } }, "移除预览"))
4817
+ : null,
4818
+ rows.map(renderRow))
2755
4819
  : null
2756
4820
 
2757
4821
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
2758
4822
  head,
2759
4823
  searchCard,
2760
4824
  loading && items.length === 0 ? h("div", { style: { ...hint, padding: "14px 2px" } }, "正在读取整合包目录…") : null,
2761
- error ? h("div", { style: { ...hint, color: "#ff6b6b", lineHeight: "19px" } }, String(error)) : null,
4825
+ error ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)", lineHeight: "19px" } }, String(error)) : null,
2762
4826
  msg ? h("div", { style: hint }, msg) : null,
2763
4827
  listBox,
2764
- !loading && items.length === 0 ? emptyCard : null,
4828
+ !loading && rows.length === 0 ? emptyCard : null,
2765
4829
  hasMore ? h("button", { type: "button", style: btn, disabled: searching, onClick: loadMore }, searching ? "加载中…" : "加载更多") : null)
2766
4830
  }
2767
4831
 
2768
4832
  // ===== [区块] 外壳:页签、刷新、彩蛋、进度窗挂载:Home =====
2769
4833
  function Home(props) {
2770
- const [tab, setTab] = useState("pack")
4834
+ const [tab, setTab] = useState(() => {
4835
+ const saved = readPageUi().tab
4836
+ return PAGE_TABS.includes(saved) ? saved : "pack"
4837
+ })
4838
+ useEffect(() => { setPageUi("tab", tab) }, [tab])
2771
4839
  const jobs = useJobs()
2772
4840
  const status = props.status
2773
4841
  const surface = (props && props.surface) || "sidebar"
2774
4842
  // 插件页里的那一栏外面已经有一层页头与标签:嵌进去不能再摆一遍大标题,
2775
4843
  // 否则同一屏里会出现两个名字、两套边距,看着像画坏了。
2776
4844
  const embedded = surface === "plugins"
4845
+ // 上了主题就整片上色:标题带、页底渐变、卡片、按钮都跟着主色走(经典界面 / 跟宿主原生时是 false)
4846
+ const themed = props.themeOn === true
2777
4847
  const [packResult, setPackResult] = useState(() => readPackValue())
2778
4848
  const [focus, setFocus] = useState(0)
4849
+ // 插件树是全屏浮层:开着的时候页签照旧停在那儿,关掉回到原来那一屏
4850
+ const [treeOpen, setTreeOpen] = useState(false)
2779
4851
  const [unlag, setUnlag] = useState(null)
2780
4852
  const [unlagMsg, setUnlagMsg] = useState("")
2781
4853
  // 解除卡顿是别人家的插件:有就出按钮,没有就什么都不显示。
@@ -2853,10 +4925,17 @@ window.__ModuleLoader__.load({
2853
4925
  // 拖到角上挡住界面时用这个:位置清掉、回到右下角默认位,并且强制显示
2854
4926
  const recallBtn = h("button", {
2855
4927
  type: "button",
2856
- style: { ...chipBtn, background: "#4C7DF0", borderColor: "#4C7DF0", color: "#fff", fontWeight: 600 },
4928
+ style: { ...chipBtn, background: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-primary, #4C7DF0)", color: "var(--mp-on-primary, #fff)", fontWeight: 600 },
2857
4929
  title: "把进度窗叫回右下角的默认位置(拖到角落挡住了界面就用这个)",
2858
4930
  onClick: () => { requestDockReset() },
2859
4931
  }, "召回进度窗")
4932
+ // 插件树(附属小插件):界面照我的世界 AE2 的配方树,滚轮缩放、按住空白拖动
4933
+ const treeBtn = h("button", {
4934
+ type: "button",
4935
+ style: chipBtn,
4936
+ title: "插件树与兼容树:按插件自己的声明构筑,滚轮缩放、拖动查看;关掉这个附属小插件后这里会提示没启用",
4937
+ onClick: () => setTreeOpen(true),
4938
+ }, "插件树")
2860
4939
  const [eggMsg, setEggMsg] = useState("")
2861
4940
  const eggClicks = useRef([])
2862
4941
  const eggTimer = useRef(0)
@@ -2878,7 +4957,7 @@ window.__ModuleLoader__.load({
2878
4957
  bottom: "88px",
2879
4958
  transform: "translateX(-50%)",
2880
4959
  background: "rgba(18, 20, 26, 0.92)",
2881
- color: "#fff",
4960
+ color: "var(--mp-on-primary, #fff)",
2882
4961
  padding: "9px 16px",
2883
4962
  borderRadius: "10px",
2884
4963
  fontSize: "13px",
@@ -2893,27 +4972,54 @@ window.__ModuleLoader__.load({
2893
4972
  ["pack", "打包"],
2894
4973
  ["install", "安装 / 导入"],
2895
4974
  ...(marketOn ? [["market", "社区资源"]] : []),
4975
+ ["manager", "插件管理"],
2896
4976
  ["settings", "设置与记录"],
2897
4977
  ]
4978
+ const plain = props.plain === true
2898
4979
  const tabBtn = (key, text) => h("button", {
2899
4980
  key,
2900
4981
  onClick: () => { setTab(key); if (key === "market") spotEgg() },
2901
- style: {
2902
- ...btn,
2903
- fontSize: embedded ? "12px" : btn.fontSize,
2904
- padding: embedded ? "3px 9px" : btn.padding,
2905
- borderColor: tab === key ? "transparent" : "var(--dsw-alias-border-l2)",
2906
- background: tab === key ? "var(--dsw-alias-fill-primary, #3b6cf6)" : "transparent",
2907
- color: tab === key ? "#fff" : "var(--dsw-alias-label-primary)",
2908
- },
4982
+ style: plain
4983
+ ? {
4984
+ fontFamily: "inherit", fontSize: embedded ? "12px" : "13px", padding: "4px 2px", cursor: "pointer",
4985
+ border: "none", borderRadius: "0px", background: "transparent",
4986
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
4987
+ fontWeight: tab === key ? 600 : 400,
4988
+ borderBottom: tab === key ? "2px solid var(--mp-text, var(--dsw-alias-label-primary))" : "2px solid transparent",
4989
+ }
4990
+ : {
4991
+ ...btn,
4992
+ fontSize: embedded ? "12px" : btn.fontSize,
4993
+ padding: embedded ? "3px 9px" : btn.padding,
4994
+ borderColor: tab === key ? "transparent" : "var(--mp-line, var(--dsw-alias-border-l2))",
4995
+ background: tab === key ? "var(--mp-primary, var(--dsw-alias-brand-primary, #3b6cf6))" : "var(--mp-card, transparent)",
4996
+ color: tab === key ? "var(--mp-on-primary, #fff)" : "var(--mp-text, var(--dsw-alias-label-primary))",
4997
+ borderRadius: "999px",
4998
+ boxShadow: tab === key ? "var(--mp-shadow, none)" : "none",
4999
+ },
2909
5000
  }, text)
2910
5001
 
5002
+ // 上了主题就把整块内容装进一张主题卡片里:五个页签(打包 / 安装 / 社区 / 插件管理 / 设置)看到的是同一套面板底,而不是只有设置页有卡片
5003
+ const panelSurface = themed
5004
+ ? { background: "var(--mp-card, var(--dsw-alias-card-fill, var(--dsw-alias-bg-layer-1, transparent)))", borderRadius: "var(--mp-radius, 10px)", border: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", boxShadow: "var(--mp-shadow, none)", padding: "14px" }
5005
+ : null
5006
+ const rt = status && status.runtime
5007
+ const staleNode = rt && rt.stale
5008
+ ? h("div", {
5009
+ style: { ...box, borderColor: "var(--mp-warn, var(--dsw-alias-state-warn-primary, #E0A33E))", background: "var(--mp-card-soft, transparent)", display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" },
5010
+ title: "运行中的这份在 " + new Date(rt.loadedAt).toLocaleString() + " 读入;磁盘上 " + (rt.newestFile || "文件") + " 在 " + new Date(rt.newestMtime).toLocaleString() + " 被改过",
5011
+ },
5012
+ h("span", { style: { ...strong, color: "var(--mp-warn, var(--dsw-alias-state-warn-primary, #E0A33E))" } }, "插件文件已更新"),
5013
+ h("span", { style: hint }, "运行中的这份是在 " + new Date(rt.loadedAt).toLocaleString() + " 读入的。完全退出 DSH 再打开(不是关窗口),新代码才会生效;浏览器里看的话再 Ctrl+Shift+R 强刷一次。"))
5014
+ : null
2911
5015
  const panels = [
2912
5016
  tab === "pack" ? h(PackPanel, { key: "pack-" + gen, status, jobs, result: packResult, setResult: savePackResult, focus }) : null,
2913
5017
  tab === "install" ? h(InstallPanel, { key: "install-" + gen, status }) : null,
2914
5018
  tab === "market" ? h(MarketPanel, { key: "market-" + gen, status, onGoInstall: () => setTab("install") }) : null,
2915
- tab === "settings" ? h(SettingsPanel, { key: "settings-" + gen, status }) : null,
5019
+ tab === "manager" ? h(PluginManagerPanel, { key: "manager-" + gen, status }) : null,
5020
+ tab === "settings" ? h(SettingsPanel, { key: "settings-" + gen, status, onOpenTree: () => setTreeOpen(true) }) : null,
2916
5021
  ]
5022
+ const treeNode = treeOpen ? h(PluginTreeOverlay, { key: "tree", status, onClose: () => setTreeOpen(false) }) : null
2917
5023
  // 这段是打包/安装的安全说明,社区资源里不该出现(那里是逛目录,不是打包)
2918
5024
  const footNote = tab === "market" ? null : h("div", { style: hint }, "说明:整合包只打包你选择的插件与必要配置。打包与安装安全检测在内存中进行,命中原文不落盘;请遵守插件作者许可证与你所在地区的法律法规。")
2919
5025
  const unlagNode = unlag
@@ -2941,16 +5047,29 @@ window.__ModuleLoader__.load({
2941
5047
  style: {
2942
5048
  display: "flex",
2943
5049
  flexDirection: "column",
2944
- color: "var(--dsw-alias-label-primary)",
5050
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
2945
5051
  padding: "10px 2px 24px",
2946
5052
  position: "relative",
5053
+ minHeight: "100%",
5054
+ boxSizing: "border-box",
5055
+ // 整片铺色:宽处一直铺到容器边缘,别只给中间那一列上色
5056
+ background: themed ? "var(--mp-page-grad, linear-gradient(180deg, rgba(120, 160, 240, 0.10) 0%, rgba(255, 255, 255, 0) 78%))" : "transparent",
5057
+ backgroundAttachment: "local",
2947
5058
  },
2948
5059
  },
2949
- h("div", { style: { maxWidth: "1020px", margin: "0 auto", width: "100%", display: "flex", flexDirection: "column", gap: "10px" } },
2950
- h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)), envLine, refreshNote ? h("span", { style: hint }, refreshNote) : null, refreshMsg ? h("span", { style: { ...hint, color: "#ff6b6b" } }, refreshMsg) : null, recallBtn, refreshBtn),
5060
+ h("div", {
5061
+ style: {
5062
+ maxWidth: "1020px", margin: "0 auto", width: "100%", display: "flex", flexDirection: "column", gap: "10px",
5063
+ ...(themed ? { padding: "12px 14px 18px" } : {}),
5064
+ },
5065
+ },
5066
+ h("div", { style: row },
5067
+ status && status.testMode ? h("span", { style: { ...chip, color: "var(--mp-warn, #ff9a3c)", border: "1px solid var(--mp-warn, #ff9a3c)", fontWeight: 600 }, title: "设置里开着「测试模式」:打包/下载/安装/更新/重装/启停都只走流程,不会真的动本机" }, "测试模式") : null,
5068
+ tabs.map(([key, text]) => tabBtn(key, text)), envLine, refreshNote ? h("span", { style: hint }, refreshNote) : null, refreshMsg ? h("span", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, refreshMsg) : null, treeBtn, recallBtn, refreshBtn),
2951
5069
  eggNode,
2952
5070
  unlagNode,
2953
- panels,
5071
+ treeNode,
5072
+ staleNode, h("div", { style: panelSurface }, panels),
2954
5073
  footNote,
2955
5074
  h(RepoFooter, null)),
2956
5075
  h(JobDock, { jobs, onOpenResult: openResult })
@@ -2958,15 +5077,36 @@ window.__ModuleLoader__.load({
2958
5077
  }
2959
5078
 
2960
5079
  return h("div", {
2961
- style: { height: "100%", overflow: "auto", boxSizing: "border-box", padding: "22px 26px 44px", color: "var(--dsw-alias-label-primary)", position: "relative" },
5080
+ style: {
5081
+ height: "100%", minHeight: "100vh", overflow: "auto", boxSizing: "border-box", padding: "22px 26px 44px",
5082
+ color: "var(--mp-text, var(--dsw-alias-label-primary))", position: "relative",
5083
+ background: themed ? "var(--mp-page-grad, linear-gradient(180deg, rgba(120, 160, 240, 0.10) 0%, rgba(255, 255, 255, 0) 78%))" : "transparent",
5084
+ backgroundAttachment: "local",
5085
+ },
2962
5086
  },
2963
5087
  h("div", { style: { maxWidth: "1020px", margin: "0 auto", display: "flex", flexDirection: "column", gap: "14px" } },
2964
- h("div", { style: { display: "flex", alignItems: "baseline", gap: "10px", flexWrap: "wrap" } },
2965
- h("h2", { style: { margin: 0, fontSize: "20px", fontWeight: 600 } }, "整合包"),
2966
- h("span", { style: hint }, ((status && status.config && status.config.tagline) || "谁说 dsh 不能整整合包呢?(你说这几个插件整一块不牛逼坏了)"))),
2967
- h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)), envLine, refreshNote ? h("span", { style: hint }, refreshNote) : null, refreshMsg ? h("span", { style: { ...hint, color: "#ff6b6b" } }, refreshMsg) : null, recallBtn, refreshBtn),
5088
+ themed ? h("div", {
5089
+ style: {
5090
+ display: "flex", alignItems: "center", gap: "14px", flexWrap: "wrap",
5091
+ padding: "15px 20px", borderRadius: "var(--mp-radius, 10px)",
5092
+ background: "var(--mp-header, var(--mp-primary))",
5093
+ color: "var(--mp-on-primary, #fff)",
5094
+ boxShadow: "var(--mp-shadow-strong, none)",
5095
+ },
5096
+ },
5097
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", minWidth: 0 } },
5098
+ h("div", { style: { fontSize: "19px", fontWeight: 600, letterSpacing: "0.2px" } }, "整合包工坊"),
5099
+ h("div", { style: { fontSize: "11.5px", opacity: 0.88, lineHeight: "16px" } },
5100
+ ((status && status.config && status.config.tagline) || "谁说 dsh 不能整整合包呢?(你说这几个插件整一块不牛逼坏了)"))),
5101
+ h("div", { style: { marginLeft: "auto", display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap", fontSize: "11.5px", opacity: 0.9 } },
5102
+ h("span", null, "打包 · 安装 · 社区 · 插件管理")))
5103
+ : h("div", { style: { display: "flex", alignItems: "baseline", gap: "10px", flexWrap: "wrap" } },
5104
+ h("h2", { style: { margin: 0, fontSize: "20px", fontWeight: 600 } }, "整合包工坊"),
5105
+ h("span", { style: hint }, ((status && status.config && status.config.tagline) || "谁说 dsh 不能整整合包呢?(你说这几个插件整一块不牛逼坏了)"))),
5106
+ h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)), envLine, refreshNote ? h("span", { style: hint }, refreshNote) : null, refreshMsg ? h("span", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, refreshMsg) : null, treeBtn, recallBtn, refreshBtn),
2968
5107
  eggNode,
2969
- panels,
5108
+ treeNode,
5109
+ staleNode, h("div", { style: panelSurface }, panels),
2970
5110
  footNote,
2971
5111
  h(RepoFooter, null)),
2972
5112
  h(JobDock, { jobs, onOpenResult: openResult })
@@ -2988,6 +5128,33 @@ window.__ModuleLoader__.load({
2988
5128
  const [tries, setTries] = useState(0)
2989
5129
  const [gen, setGen] = useState(0)
2990
5130
  const alive = useRef(true)
5131
+ // 配色:把服务端算好的 --mp-* 变量挂到 document 上,只影响本插件自己的样式。
5132
+ // 选「跟 DSH 原生」时不注入任何东西——整块 style 直接删掉,等于没发生。
5133
+ const [live, setLive] = useState(liveTheme.value)
5134
+ useEffect(() => {
5135
+ const fn = (next) => setLive(next)
5136
+ liveTheme.listeners.add(fn)
5137
+ return () => { liveTheme.listeners.delete(fn) }
5138
+ }, [])
5139
+ // 主题从三处取,优先级从高到低:
5140
+ // 1) live(刚在设置里点完,服务端 /settings 回包里算好的);
5141
+ // 2) status.theme(宿主新版本自己算的);
5142
+ // 3) 老宿主没有 status.theme 时,客户端自己按 config 算一份(localTheme)——
5143
+ // 少了这一条,界面就只会在「点过一次设置」之后才变色,看起来像功能没做。
5144
+ const configTheme = (status && status.config) ? localTheme(status.config) : null
5145
+ const themeNow = (live && live.theme) || (status && status.theme) || configTheme
5146
+ const themeId = (themeNow && themeNow.id) || ''
5147
+ const themeVars = (themeNow && themeNow.vars) || null
5148
+ // 界面风格 classic(改版前)时整块配色不生效:不注入任何 --mp-*,颜色回到宿主自己的。
5149
+ const classicUi = ((live && live.uiStyle) || (status && status.uiStyle)) === "classic"
5150
+ // 「整片都跟着主题走」:给 Home 一个开关,由它决定标题带与页底渐变要不要上色
5151
+ const themeOn = !classicUi && !!(themeNow && themeNow.id && themeNow.id !== "native" && themeNow.primary)
5152
+ useEffect(() => {
5153
+ const doc = typeof document === "undefined" ? null : document
5154
+ if (!doc) return undefined
5155
+ applyThemeVars(classicUi ? CLASSIC_VARS : (Object.keys(themeVars || {}).length ? themeVars : hostVarsFor(themeNow)))
5156
+ return undefined
5157
+ }, [themeVars, classicUi])
2991
5158
  useEffect(() => () => { alive.current = false }, [])
2992
5159
  // 宿主刚起来、会话还在建的时候,第一次可能拿不到状态(401/网络没就绪)。
2993
5160
  // 自己退避重试几次,别让用户看到一块红字或者一块空白。
@@ -3016,12 +5183,12 @@ window.__ModuleLoader__.load({
3016
5183
  }, [])
3017
5184
  useEffect(() => { load(3) }, [load])
3018
5185
  if (error) {
3019
- return h("div", { style: { padding: "20px 24px", color: "#ff6b6b", fontSize: "13px", display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" } },
5186
+ return h("div", { style: { padding: "20px 24px", color: "var(--mp-danger, #ff6b6b)", fontSize: "13px", display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" } },
3020
5187
  h("span", null, "整合包没起来:" + error),
3021
5188
  h("button", { type: "button", style: btn, onClick: () => { setError(""); setTries(0); load(3) } }, "重试"))
3022
5189
  }
3023
5190
  if (!status) {
3024
- return h("div", { style: { padding: "20px 24px", color: "var(--dsw-alias-label-tertiary, #8b909b)", fontSize: "13px" } },
5191
+ return h("div", { style: { padding: "20px 24px", color: "var(--dsw-alias-label-tertiary, var(--mp-muted, #8b909b))", fontSize: "13px" } },
3025
5192
  tries > 0 ? "整合包:还在连 DSH 本体…(自动重试 " + tries + " 次)" : "整合包:读取环境…")
3026
5193
  }
3027
5194
  // 手动刷新:先重读 status,再把下面几个面板整体重挂一次(gen+1)。
@@ -3030,6 +5197,8 @@ window.__ModuleLoader__.load({
3030
5197
  return h(Home, {
3031
5198
  status,
3032
5199
  surface: (props && props.surface) || "sidebar",
5200
+ themeOn,
5201
+ plain: classicUi,
3033
5202
  gen,
3034
5203
  onRefresh: async () => {
3035
5204
  await load(3)
@@ -3043,14 +5212,14 @@ window.__ModuleLoader__.load({
3043
5212
  // 三处显示位各自注册什么。开关一翻就整组挂上 / 整组撤掉,不动别的插件。
3044
5213
  const PLACEMENT_MOUNTS = {
3045
5214
  settings: () => [
3046
- { slot: "settings.section", spec: { name: "settings.section", id: "dsh-modpack-kit", order: 45, label: () => "整合包" }, Comp: () => h(Page, { surface: "settings" }) },
3047
- { slot: "settings.plugins.tab", spec: { name: "settings.plugins.tab", id: "dsh-modpack-kit", order: 70, label: () => "整合包" }, Comp: () => h(Page, { surface: "plugins" }) },
5215
+ { slot: "settings.section", spec: { name: "settings.section", id: "dsh-modpack-kit", order: 45, label: () => "整合包工坊" }, Comp: () => h(Page, { surface: "settings" }) },
5216
+ { slot: "settings.plugins.tab", spec: { name: "settings.plugins.tab", id: "dsh-modpack-kit", order: 70, label: () => "整合包工坊" }, Comp: () => h(Page, { surface: "plugins" }) },
3048
5217
  ],
3049
5218
  pluginsTab: () => [
3050
- { slot: "plugins.tab", spec: { name: "plugins.tab", id: "dsh-modpack-kit", order: 1, label: () => "整合包" }, Comp: () => h(Page, { surface: "plugins" }) },
5219
+ { slot: "plugins.tab", spec: { name: "plugins.tab", id: "dsh-modpack-kit", order: 1, label: () => "整合包工坊" }, Comp: () => h(Page, { surface: "plugins" }) },
3051
5220
  ],
3052
5221
  sidebar: () => [
3053
- { slot: "sidebar.panellist", spec: { name: "sidebar.panellist", id: "dsh-modpack-kit", order: 60, label: () => "整合包" }, Comp: Icon },
5222
+ { slot: "sidebar.panellist", spec: { name: "sidebar.panellist", id: "dsh-modpack-kit", order: 60, label: () => "整合包工坊" }, Comp: Icon },
3054
5223
  { slot: "main", spec: { name: "main", key: "dsh-modpack-kit" }, Comp: () => h(Page, { surface: "sidebar" }) },
3055
5224
  ],
3056
5225
  }
@@ -3118,12 +5287,24 @@ window.__ModuleLoader__.load({
3118
5287
  exports.MarketPanel = MarketPanel
3119
5288
  // 自测用:社区资源那层「切页签也保留」的状态存在模块里,测试要能塞一份进去看恢复得对不对
3120
5289
  exports.__marketUi = marketUi
5290
+ // 自测用:页签状态也是模块级的,dev/tools/ui-preview.mjs 与测试要能直接把初始页签摆好再渲染
5291
+ exports.__setPageTab = (tab) => { pageUi.tab = tab }
3121
5292
  exports.PluginBrowser = PluginBrowser
5293
+ exports.PluginManagerPanel = PluginManagerPanel
5294
+ exports.SubpluginList = SubpluginList
5295
+ exports.PluginTreeOverlay = PluginTreeOverlay
3122
5296
  exports.ModpackBrowser = ModpackBrowser
3123
5297
  exports.inject = inject
3124
5298
  exports.Page = Page
3125
5299
  exports.Home = Home
5300
+ exports.SettingsPanel = SettingsPanel
3126
5301
  exports.Icon = Icon
5302
+ exports.HOST_VARS = HOST_VARS // 预览器复用同一张「原生模式」映射表,避免两处各写一份
5303
+ exports.CLASSIC_VARS = CLASSIC_VARS
5304
+ exports.__treeLayout = treeLayout
5305
+ exports.__treeColOfKind = TREE_COL_OF_KIND
5306
+ exports.__treeFolds = treeFolds
5307
+ exports.__treeRelated = treeRelated // 只给预览与自检用:按同一份数据摆一遍,截图核对布局 // 同理:预览器要能按经典模式出图,否则看到的还是「主题色」
3127
5308
 
3128
5309
  return module.exports
3129
5310
  },