dsh-modpack-kit 0.2.4 → 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 会退回旧值
@@ -152,7 +334,7 @@ window.__ModuleLoader__.load({
152
334
  function setPageUi(slice, value) {
153
335
  pageUi[slice] = value
154
336
  }
155
- const PAGE_TABS = ["pack", "install", "settings", "market"]
337
+ const PAGE_TABS = ["pack", "install", "settings", "market", "manager"]
156
338
 
157
339
  // 插件市场的 AI 搜索:市场新版本用 POST /dsh-market/ai-search,让「你在 DSH 里配的模型」从目录里挑插件。
158
340
  // 我们不重复实现模型调用:旧版市场(或没装)没有这条路由,界面自动退回纯关键词搜索。
@@ -391,7 +573,7 @@ window.__ModuleLoader__.load({
391
573
 
392
574
  function Switch(props) {
393
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 } },
394
- 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) }),
395
577
  props.label)
396
578
  }
397
579
 
@@ -410,7 +592,7 @@ window.__ModuleLoader__.load({
410
592
 
411
593
  function NagText(props) {
412
594
  if (!props.text) return null
413
- 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)
414
596
  }
415
597
 
416
598
  // 强制项:开关照常显示(让人知道这项存在),但点不动——点一次弹红字。
@@ -425,11 +607,15 @@ window.__ModuleLoader__.load({
425
607
  }
426
608
 
427
609
  function Tag(props) {
428
- 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)
429
611
  }
430
612
 
431
613
  function Notice(props) {
432
- 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)
433
619
  }
434
620
 
435
621
  const ORIGIN_LABEL = { local: "本机", market: "市场", config: "配置", data: "数据", pack: "整合包" }
@@ -442,7 +628,7 @@ window.__ModuleLoader__.load({
442
628
  const summary = Array.isArray(props.summary) ? props.summary : [props.summary]
443
629
  // 标题行上的操作(比如「清空」):点它不该顺带把整块展开/收起
444
630
  const actions = Array.isArray(props.actions) ? props.actions.filter(Boolean) : []
445
- 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" } },
446
632
  h("div", { style: { ...row, cursor: "pointer" }, onClick: () => setOpen((prev) => !prev) },
447
633
  h("div", { style: strong }, props.title),
448
634
  ...summary.filter(Boolean),
@@ -468,7 +654,7 @@ window.__ModuleLoader__.load({
468
654
  title: "安全检测",
469
655
  defaultOpen: counts.high > 0,
470
656
  summary: [
471
- 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),
472
658
  h("span", { style: hint }, "扫了 " + (scan.scannedFiles || 0) + " 个文件"),
473
659
  ],
474
660
  hint: findings.length ? "展开(" + findings.length + " 条)" : "没有命中",
@@ -479,9 +665,9 @@ window.__ModuleLoader__.load({
479
665
  : h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
480
666
  groups.map((group) => {
481
667
  const expanded = openGroup[group.key] === true
482
- 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" } },
483
669
  h("div", {
484
- 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))" },
485
671
  onClick: () => toggleGroup(group.key),
486
672
  },
487
673
  h("span", { style: { ...label, fontSize: "12.5px" } }, group.label),
@@ -516,7 +702,7 @@ window.__ModuleLoader__.load({
516
702
  f.suggestion ? h("div", { style: hint }, "建议:" + f.suggestion) : null)))
517
703
  }
518
704
 
519
- const JOB_KIND_LABEL = { pack: "打包", install: "安装", upload: "上传" }
705
+ const JOB_KIND_LABEL = { pack: "打包", install: "安装", upload: "上传", reinstall: "重装", update: "更新" }
520
706
  const JOB_STATUS_TEXT = { running: "进行中", paused: "等决定", acked: "已确认", done: "完成", failed: "失败", cancelled: "已取消" }
521
707
 
522
708
  function useJobs(intervalMs) {
@@ -541,7 +727,7 @@ window.__ModuleLoader__.load({
541
727
  function ProgressBar(props) {
542
728
  const pct = Math.max(0, Math.min(100, Math.round(props.pct || 0)))
543
729
  return h("div", { style: { height: "6px", borderRadius: "99px", background: "rgba(127,163,245,.18)", overflow: "hidden" } },
544
- 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%)" } }))
545
731
  }
546
732
 
547
733
  // 进度窗:可以拖,拖过的位置记在浏览器本地;没有任务时自动收起,只留一枚唤出按钮。
@@ -741,10 +927,10 @@ window.__ModuleLoader__.load({
741
927
  gap: "6px",
742
928
  padding: "7px 11px",
743
929
  borderRadius: "999px",
744
- border: "0.5px solid var(--dsw-alias-border-l2)",
745
- background: "var(--dsw-alias-surface-1, rgba(24,26,31,.97))",
746
- color: "var(--dsw-alias-label-primary)",
747
- 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))",
748
934
  cursor: pos ? "grab" : "pointer",
749
935
  fontSize: "12px",
750
936
  touchAction: "none",
@@ -761,7 +947,7 @@ window.__ModuleLoader__.load({
761
947
  onPointerUp: endPillDrag,
762
948
  onPointerCancel: endPillDrag,
763
949
  },
764
- 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)" } }),
765
951
  "进度",
766
952
  badge ? h("span", { style: { ...hint, marginLeft: "0", fontVariantNumeric: "tabular-nums" } }, String(badge)) : null)
767
953
  }
@@ -826,10 +1012,10 @@ window.__ModuleLoader__.load({
826
1012
  overflow: "auto",
827
1013
  boxSizing: "border-box",
828
1014
  padding: "10px 12px",
829
- borderRadius: "10px",
830
- border: "0.5px solid var(--dsw-alias-border-l2)",
831
- background: "var(--dsw-alias-surface-1, rgba(24,26,31,.97))",
832
- 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))",
833
1019
  display: "flex",
834
1020
  flexDirection: "column",
835
1021
  gap: "7px",
@@ -844,7 +1030,7 @@ window.__ModuleLoader__.load({
844
1030
  onPointerUp: endDrag,
845
1031
  onPointerCancel: endDrag,
846
1032
  },
847
- 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),
848
1034
  h("span", { style: { marginLeft: "auto", fontSize: "12px", fontVariantNumeric: "tabular-nums" } }, headPct + "%"),
849
1035
  running.length > 1 ? h("span", { style: { ...hint, marginLeft: "0" } }, "+" + (running.length - 1)) : null,
850
1036
  jobs.length > 0
@@ -863,18 +1049,27 @@ window.__ModuleLoader__.load({
863
1049
  onPointerDown: (event) => { if (event && event.stopPropagation) event.stopPropagation() },
864
1050
  onClick: (event) => { if (event && event.stopPropagation) event.stopPropagation(); setHidden(true); setPinned(false) },
865
1051
  }, "收起")),
866
- 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,
867
1053
  open
868
1054
  ? (jobs.length === 0
869
1055
  ? h("div", { style: hint }, "还没有打包或安装任务。开始一个就会出现在这里。")
870
1056
  : h("div", { style: { display: "flex", flexDirection: "column", gap: "8px", marginTop: "2px" } },
871
- 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))" } },
872
1058
  h("div", { style: row },
873
1059
  h("span", { style: { ...label, fontSize: "12.5px" } }, job.label || JOB_KIND_LABEL[job.kind] || "任务"),
874
1060
  h("span", { style: { ...hint, marginLeft: "auto" } }, (JOB_STATUS_TEXT[job.status] || job.status) + " · " + Math.round(job.pct || 0) + "%")),
875
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,
876
1071
  job.risk && job.status === "paused"
877
- ? 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" } },
878
1073
  h("div", null, "检测到风险:高 " + (job.risk.high || 0) + " · 中 " + (job.risk.medium || 0) + " · 低 " + (job.risk.low || 0)),
879
1074
  h("div", { style: { fontSize: "10.5px" } }, job.risk.message || ""),
880
1075
  job.risk.groups && job.risk.groups.length
@@ -882,19 +1077,19 @@ window.__ModuleLoader__.load({
882
1077
  job.risk.groups.map((g) => (g.label || "") + "(高 " + ((g.counts && g.counts.high) || 0) + " / 中 " + ((g.counts && g.counts.medium) || 0) + ")").join(" "))
883
1078
  : null)
884
1079
  : null,
885
- 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 }),
886
1081
  h("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px" } },
887
1082
  job.status === "running" ? h("button", { style: { ...chipBtn }, onClick: () => stop(job.id) }, "终止") : null,
888
1083
  job.status === "done" && job.kind === "pack" && job.data && job.data.token
889
1084
  ? h("button", {
890
- style: { ...chipBtn, color: "#4C7DF0", borderColor: "#4C7DF0" },
1085
+ style: { ...chipBtn, color: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-primary, #4C7DF0)" },
891
1086
  title: "跳到打包页的下载部分",
892
1087
  onClick: () => { if (typeof props.onOpenResult === "function") props.onOpenResult(job) },
893
1088
  }, "下载安装包")
894
1089
  : null,
895
1090
  job.kind === "upload" && job.status === "done" && job.data && job.data.pr && job.data.pr.url
896
1091
  ? h("a", {
897
- style: { ...chipBtn, color: "#4C7DF0", borderColor: "#4C7DF0", textDecoration: "none" },
1092
+ style: { ...chipBtn, color: "var(--mp-primary, #4C7DF0)", borderColor: "var(--mp-primary, #4C7DF0)", textDecoration: "none" },
898
1093
  href: job.data.pr.url,
899
1094
  target: "_blank",
900
1095
  rel: "noreferrer",
@@ -902,16 +1097,16 @@ window.__ModuleLoader__.load({
902
1097
  }, "打开 PR #" + (job.data.pr.number || ""))
903
1098
  : null,
904
1099
  job.canAck
905
- ? 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) }, "我知道在干什么")
906
1101
  : null,
907
1102
  job.status !== "running" && job.status !== "paused"
908
- ? h("button", { style: { ...chipBtn, color: "var(--dsw-alias-label-tertiary, #8b8f99)" }, title: "从列表里删掉这条记录", onClick: () => dismiss(job.id) }, job.status === "failed" ? "我已知晓" : "删除该进程")
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" ? "我已知晓" : "删除该进程")
909
1104
  : null,
910
- 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)))))
911
1106
  : h("div", { style: { ...hint, fontSize: "10.5px" } },
912
1107
  (running.length ? running.length + " 个任务进行中 · " : "") + "按住标题能拖动,点标题展开看详情、也能中途终止"),
913
1108
  dockMsg
914
- ? 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" } },
915
1110
  dockMsg,
916
1111
  h("button", { style: { ...chipBtn, marginLeft: "auto" }, onClick: () => setDockMsg("") }, "知道了"))
917
1112
  : null)
@@ -1170,7 +1365,6 @@ window.__ModuleLoader__.load({
1170
1365
  return next
1171
1366
  })
1172
1367
  }
1173
- const setSpec = (name, spec) => setSelected((prev) => ({ ...prev, [name]: { ...prev[name], spec } }))
1174
1368
  const setChoice = (name, choice) => setSelected((prev) => ({ ...prev, [name]: { ...prev[name], choice } }))
1175
1369
  // 同名市场版:装出来是上游原版代码 + 插件默认配置
1176
1370
  const switchMarket = (entry, toMarket) => setSelected((prev) => {
@@ -1226,9 +1420,9 @@ window.__ModuleLoader__.load({
1226
1420
  const chosenSource = on ? selected[entry.name].source : (entry.installed === false ? "npm" : "profile")
1227
1421
  const sourceText = on ? (chosenSource === "npm" ? "市场版" : "本机版") : (entry.installed === false ? "市场未装" : "已装")
1228
1422
  const sourceStyle = on
1229
- ? { ...chip, minWidth: "58px", textAlign: "center", fontWeight: 600, color: "var(--dsw-alias-label-primary)", borderColor: "var(--dsw-alias-border-l2)" }
1230
- : { ...chip, minWidth: "58px", textAlign: "center", color: "var(--dsw-alias-label-tertiary)" }
1231
- 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" } },
1232
1426
  h("span", {
1233
1427
  style: sourceStyle,
1234
1428
  title: on
@@ -1239,9 +1433,9 @@ window.__ModuleLoader__.load({
1239
1433
  h("div", { style: { flex: "1 1 220px", minWidth: "180px" } },
1240
1434
  h("div", { style: label }, entry.title || entry.name, " ", h("span", { style: hint }, "@" + (entry.version || "?"))),
1241
1435
  h("div", { style: hint }, (entry.description || "").slice(0, 110))),
1242
- h("span", { style: { ...chip, color: "var(--dsw-alias-label-tertiary)" } }, labelOf(categoryOf(entry))),
1243
- entry.updateAvailable ? h(Tag, { color: "#2bb673" }, "市场版 " + (entry.marketVersion || entry.version) + " 更新") : null,
1244
- 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 } },
1245
1439
  "版本 " + (selected[entry.name].source === "npm"
1246
1440
  ? (entry.marketVersion || (selected[entry.name].spec || "").replace(/^[^@]+@/u, "") || entry.version || "最新")
1247
1441
  : (entry.version || "本机"))) : null,
@@ -1249,7 +1443,7 @@ window.__ModuleLoader__.load({
1249
1443
  h("button", { style: selected[entry.name].choice !== "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "preset"), title: "只打插件默认配置:不带本机的配置与数据快照(代码按所选来源)" }, "插件预设"),
1250
1444
  h("button", { style: selected[entry.name].choice === "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "custom"), title: "带上本机这份插件的配置与数据快照;本机来源的连代码改动一起打" }, "自定义配置")) : null,
1251
1445
  entry.hasMarket && entry.source === "profile" && on ? h("button", {
1252
- 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))" },
1253
1447
  onClick: () => switchMarket(entry, selected[entry.name].source !== "npm"),
1254
1448
  title: "改用插件市场发的同名版本(上游原版代码 + 默认配置),装出来和从市场装一样",
1255
1449
  }, selected[entry.name].source === "npm" ? "改为本机版" : "改为市场版") : null)}
@@ -1262,10 +1456,10 @@ window.__ModuleLoader__.load({
1262
1456
  const isFolded = folded[section.name] === true
1263
1457
  out.push(h("div", {
1264
1458
  key: section.key,
1265
- 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))" },
1266
1460
  },
1267
1461
  h("button", {
1268
- 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))" },
1269
1463
  onClick: () => setFolded((prev) => ({ ...prev, [section.name]: !isFolded })),
1270
1464
  title: isFolded ? "展开「" + section.name + "」" : "收起「" + section.name + "」",
1271
1465
  }, isFolded ? "▸" : "▾"),
@@ -1292,7 +1486,7 @@ window.__ModuleLoader__.load({
1292
1486
  // 停在风险点的任务:按插件分栏列出命中项,确认/删除都在这里做
1293
1487
  const pausedRiskNodes = []
1294
1488
  if (pausedJobs.length > 0) {
1295
- 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} 个任务)`))
1296
1490
  pausedRiskNodes.push(h("div", { key: "hint", style: hint }, "下面是每个插件自己的命中项。确认后原任务从这个检测点接着跑完,不再重复检测。"))
1297
1491
  for (const job of pausedJobs) {
1298
1492
  const groupNodes = (job.risk.groups || []).map((group, index) => {
@@ -1316,7 +1510,7 @@ window.__ModuleLoader__.load({
1316
1510
  h("div", { style: { ...row, justifyContent: "space-between" } },
1317
1511
  h("div", { style: strong }, job.label || "打包任务"),
1318
1512
  h("div", { style: row },
1319
- 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) }, "我知道在干什么"),
1320
1514
  h("button", { style: btn, onClick: () => dismissJob(job.id) }, "删除该进程"))),
1321
1515
  groupNodes))
1322
1516
  }
@@ -1468,26 +1662,26 @@ window.__ModuleLoader__.load({
1468
1662
  catalog.present && syncing ? h("div", { style: hint }, syncing) : null,
1469
1663
  catalog.present ? h(CategoryChips, { chips, value: category, onChange: setCategory }) : null,
1470
1664
  aiReady === false ? h("div", { style: hint }, "当前装的插件市场没有 AI 搜索(旧版本或未安装):这里只做关键词搜索。装新版 dshmarket 后开关会自动出现。") : null,
1471
- 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))" } },
1472
1666
  h("div", { style: row },
1473
1667
  h("div", { style: strong }, aiRun.error ? "AI 搜索没成功" : "AI 挑的插件"),
1474
1668
  h("span", { style: hint }, aiRun.model ? "模型:" + aiRun.model : ""),
1475
1669
  h("button", { style: btn, onClick: () => setAiRun(null) }, "收起")),
1476
- 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,
1477
1671
  aiRun.intro ? h("div", { style: hint }, aiRun.intro) : null,
1478
1672
  aiRun.picks.length === 0 && !aiRun.error ? h("div", { style: hint }, "这次没挑出合适的插件,换个说法再试。") : null,
1479
1673
  aiRun.picks.map((item) => {
1480
1674
  const meta = marketInfo[item.name] || {}
1481
1675
  const on = Boolean(selected[item.name])
1482
1676
  const entry = { name: item.name, installed: false, hasMarket: true, marketVersion: meta.version || "", version: meta.version || "" }
1483
- 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))" } },
1484
1678
  h("input", { type: "checkbox", checked: on, onChange: () => toggle(entry), style: { marginTop: "3px" } }),
1485
1679
  h("div", { style: { flex: "1 1 auto", minWidth: 0 } },
1486
1680
  h("div", { style: { ...strong, fontSize: "12.5px" } }, item.name + (meta.version ? " · v" + meta.version : "")),
1487
1681
  h("div", { style: hint }, item.description || ""),
1488
- 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))
1489
1683
  })) : null,
1490
- 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,
1491
1685
  h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", maxHeight: "320px", overflow: "auto" } },
1492
1686
  rows.length === 0
1493
1687
  ? h("div", { style: hint }, loading ? "读取中…" : active ? (searching ? "搜索中…" : "无匹配条目") : "本机尚未安装插件")
@@ -1505,7 +1699,7 @@ window.__ModuleLoader__.load({
1505
1699
  (planEntries.length ? planEntries : STRATEGY_INFO.map((item) => ({ ...item, ok: true }))).map((item) => {
1506
1700
  const disabled = item.ok === false
1507
1701
  const chosen = options.strategy === item.id
1508
- 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))"
1509
1703
  return h("div", {
1510
1704
  key: item.id,
1511
1705
  role: "button",
@@ -1514,7 +1708,7 @@ window.__ModuleLoader__.load({
1514
1708
  style: {
1515
1709
  flex: "1 1 210px", minWidth: "190px", padding: "9px 10px", borderRadius: "8px",
1516
1710
  cursor: disabled ? "not-allowed" : "pointer",
1517
- 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))"),
1518
1712
  borderStyle: disabled ? "dashed" : "solid",
1519
1713
  background: chosen && !disabled ? "rgba(76,125,240,0.08)" : "transparent",
1520
1714
  opacity: disabled ? 0.7 : 1,
@@ -1531,7 +1725,7 @@ window.__ModuleLoader__.load({
1531
1725
  },
1532
1726
  title: disabled ? (item.reason || "") : (item.online ? "安装时需要联网" : "不联网也能装"),
1533
1727
  },
1534
- 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))" } },
1535
1729
  h("span", { style: { fontWeight: 600 } }, item.title),
1536
1730
  h("span", { style: { fontSize: "11px", color: muted } }, item.online ? "需联网" : "不联网"),
1537
1731
  disabled ? h("span", { style: { ...chip, marginLeft: "auto", color: muted, cursor: "pointer" } }, "不可选") : null),
@@ -1551,7 +1745,7 @@ window.__ModuleLoader__.load({
1551
1745
  h("button", { style: btnPrimary, disabled: picked.length === 0 || busy === "start" || Boolean(currentBlocked), onClick: doPack }, busy === "start" ? "提交中…" : (currentBlocked ? "先换个可用的策略" : `打包 ${picked.length} 个插件`)),
1552
1746
  started ? h("span", { style: hint }, "已开始:" + started + "(进度在悬浮窗,可以接着选别的再打一个)") : null,
1553
1747
  status ? h("span", { style: hint }, "DSH " + (status.dshVersion || "?") + " · profile " + status.profile) : null)),
1554
- 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,
1555
1749
  error ? h(Notice, { tone: "bad" }, error) : null,
1556
1750
  result ? h("div", { ref: resultRef, style: { ...box, display: "flex", flexDirection: "column", gap: "10px" } },
1557
1751
  result.refused || result.error
@@ -1559,13 +1753,13 @@ window.__ModuleLoader__.load({
1559
1753
  h("b", null, "已停止:"), result.error || "未通过检查",
1560
1754
  result.needsAck ? h("div", { style: { ...row, marginTop: "8px" } },
1561
1755
  h("button", {
1562
- style: { ...btn, borderColor: "#ff6b6b", color: "#ff6b6b" },
1756
+ style: { ...btn, borderColor: "var(--mp-danger, #ff6b6b)", color: "var(--mp-danger, #ff6b6b)" },
1563
1757
  disabled: busy === "start",
1564
1758
  onClick: () => doPack(true),
1565
1759
  }, busy === "start" ? "提交中…" : "我已知晓其中风险,继续打包")) : null)
1566
1760
  : h("div", { style: row },
1567
1761
  h("div", { style: strong }, result.fileName),
1568
- h(Tag, { color: "#2bb673" }, bytes(result.size)),
1762
+ h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, bytes(result.size)),
1569
1763
  h(Tag, null, FORMAT_TEXT[result.manifest && result.manifest.format] || ""),
1570
1764
  h("span", { style: hint }, "包内插件 " + ((result.manifest && result.manifest.plugins) || []).length + " 个")),
1571
1765
  result.scan ? h(ScanReport, { scan: result.scan, groups: result.scanGroups, footNote: "报告已写进包内 security/report.txt(只含类型与掩码)。" }) : null,
@@ -1856,7 +2050,7 @@ window.__ModuleLoader__.load({
1856
2050
  gap: "3px",
1857
2051
  padding: "8px 10px",
1858
2052
  borderRadius: "8px",
1859
- 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))"),
1860
2054
  },
1861
2055
  },
1862
2056
  h("div", { style: row },
@@ -1869,7 +2063,7 @@ window.__ModuleLoader__.load({
1869
2063
  onClick: () => pickImport(item),
1870
2064
  }, source.kind === "token" && source.token === item.token ? "当前选中" : "选择"),
1871
2065
  h("button", {
1872
- 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)))" },
1873
2067
  onClick: () => {
1874
2068
  removeImport(item.token)
1875
2069
  if (source.kind === "token" && source.token === item.token) {
@@ -1880,7 +2074,7 @@ window.__ModuleLoader__.load({
1880
2074
  }, "移除")),
1881
2075
  h("div", { style: { ...hint, fontSize: "10.5px" } },
1882
2076
  "作者:" + (item.author || "未填写") + " · 生成于 " + (item.createdAt ? when(item.createdAt) : "未知")),
1883
- 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,
1884
2078
  item.fileName ? h("div", { style: { ...hint, fontSize: "10px" } }, item.fileName) : null))))
1885
2079
  : null,
1886
2080
  h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px" } },
@@ -1896,7 +2090,7 @@ window.__ModuleLoader__.load({
1896
2090
  h("span", { style: { ...label, flex: "1 1 auto" } }, p.name),
1897
2091
  h("span", { style: hint }, bytes(p.size) + " · " + when(p.mtime)),
1898
2092
  h("button", { style: btn, disabled: busy !== "", onClick: () => pickDownloaded(p) }, source.kind === "file" && source.file === p.path ? "当前选中" : "选择"),
1899
- h("button", { style: { ...btn, color: "#ff6b6b" }, disabled: busy !== "", onClick: () => removeDownloaded(p) }, "删除"))))),
2093
+ h("button", { style: { ...btn, color: "var(--mp-danger, #ff6b6b)" }, disabled: busy !== "", onClick: () => removeDownloaded(p) }, "删除"))))),
1900
2094
  h("div", { style: row },
1901
2095
  h("button", { style: source.kind === "url" ? btnPrimary : btn, onClick: () => setSource({ ...source, kind: "url" }) }, "从链接读取"),
1902
2096
  h("button", { style: source.kind === "file" ? btnPrimary : btn, onClick: () => setSource({ ...source, kind: "file" }) }, "从本机文件读取"),
@@ -1929,7 +2123,7 @@ window.__ModuleLoader__.load({
1929
2123
  h("button", { style: btn, disabled: busy !== "", onClick: browseFolder }, busy === "dir" ? "选择中…" : "浏览文件夹…"),
1930
2124
  h("button", { style: btn, onClick: () => reloadPacks(dirInput) }, "读这个目录"),
1931
2125
  h("button", { style: btn, onClick: () => reloadPacks() }, "回到默认")),
1932
- 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,
1933
2127
  h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", maxHeight: "170px", overflow: "auto" } },
1934
2128
  packs.length === 0 ? h("div", { style: hint }, "这个目录里没有 .dshpack。先去打包页生成一个,或者把文件拖到界面上。") : null,
1935
2129
  packs.map((p) => h("label", { key: p.path || p.name, style: { ...row, gap: "6px", cursor: "pointer" } },
@@ -1961,23 +2155,23 @@ window.__ModuleLoader__.load({
1961
2155
  h("div", { style: row },
1962
2156
  h("div", { style: strong }, preview.manifest.name),
1963
2157
  h(Tag, null, FORMAT_TEXT[preview.manifest.format] || preview.manifest.format),
1964
- 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 ? "完整性通过" : "完整性有出入") : "无完整性清单"),
1965
2159
  h("span", { style: hint }, "生成于 " + when(preview.manifest.createdAt) + (preview.manifest.author ? " · " + preview.manifest.author : ""))),
1966
2160
  preview.manifest.description ? h("div", { style: label }, preview.manifest.description) : null,
1967
2161
  preview.blockingReasons && preview.blockingReasons.length
1968
2162
  ? h(Notice, { tone: "bad" }, h("b", null, "阻断:" ), preview.blockingReasons.join(";"), " (真要装,勾上面的「忽略阻断」)")
1969
2163
  : null,
1970
2164
  h("div", { style: { display: "flex", flexDirection: "column", gap: "4px", maxHeight: "280px", overflow: "auto" } },
1971
- 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,
1972
2166
  previewRows.map((row) => {
1973
2167
  const p = row.plugin
1974
2168
  const checked = pickedNames[p.name] !== false
1975
- 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))" } },
1976
2170
  h("input", { type: "checkbox", checked, onChange: () => setPickedNames((prev) => ({ ...prev, [p.name]: !checked })) }),
1977
2171
  h("div", { style: { flex: "1 1 220px", minWidth: "170px" } },
1978
2172
  h("div", { style: label }, p.name, " ", h("span", { style: hint }, p.latest ? "@市场最新(装的时候按名字取)" : "@" + (p.version || "?"))),
1979
2173
  h("div", { style: hint }, [p.localEdits ? "含本机修改" : "", p.configIncluded ? "有配置" : "", p.dataIncluded ? "有数据快照" : ""].filter(Boolean).join(" · ")),
1980
- 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)" } },
1981
2175
  row.problems.slice(0, 3).map((f) => "· " + f.message).join(";") + (row.problems.length > 3 ? "(还有 " + (row.problems.length - 3) + " 条)" : "")) : null),
1982
2176
  p.configIncluded ? h("div", { style: { display: "flex", gap: "4px" } },
1983
2177
  h("button", { style: (configChoice[p.name] || "pack") === "pack" ? chipOn : chipBtn, onClick: () => setConfigChoice((prev) => ({ ...prev, [p.name]: "pack" })), title: "用包里的配置条目覆盖/补上" }, "包内配置"),
@@ -1992,7 +2186,7 @@ window.__ModuleLoader__.load({
1992
2186
  : null,
1993
2187
  askReplace && deferred.length > 0
1994
2188
  ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
1995
- h("div", { style: { ...label, color: "#ffb020" } }, "以下 " + deferred.length + " 个插件本机已经装了,这次先跳过没动它们:"),
2189
+ h("div", { style: { ...label, color: "var(--mp-warn, #ffb020)" } }, "以下 " + deferred.length + " 个插件本机已经装了,这次先跳过没动它们:"),
1996
2190
  deferred.map((d) => h("div", { key: d.name, style: mono },
1997
2191
  "· " + d.name + " 本机 " + (d.localVersion || "未知") + " → 包内 " + (d.packVersion || "未知") + (d.sameVersion ? "(版本相同)" : ""))),
1998
2192
  h("div", { style: hint }, "要保留本机版本就直接完成;要换成包内版本点下面这个(会覆盖本机那份)。"),
@@ -2003,14 +2197,20 @@ window.__ModuleLoader__.load({
2003
2197
  done ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2004
2198
  h("div", { style: row },
2005
2199
  h("div", { style: strong }, done.ok ? "安装完成" : "没有装成"),
2006
- done.needsRestart ? h(Tag, { color: "#ffb020" }, "需要重启 DSH 生效") : null),
2007
- done.error ? h("div", { style: { ...label, color: "#ff6b6b" } }, done.error) : null,
2008
- (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)" } },
2009
2203
  (a.ok ? "✓ " : "✗ ") + a.plugin + " · " + a.action + " · " + a.message)),
2010
2204
  (done.lines || []).length ? h("details", null, h("summary", { style: hint }, "命令输出(" + done.lines.length + " 行)"),
2011
2205
  h("pre", { style: { ...mono, maxHeight: "200px", overflow: "auto", whiteSpace: "pre-wrap" } }, done.lines.join("\n"))) : null,
2012
2206
  done.scan ? h(ScanReport, { scan: done.scan, groups: done.scanGroups }) : null)
2013
- : 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 })))
2014
2214
  }
2015
2215
 
2016
2216
  // —— 设置与记录 ——
@@ -2022,13 +2222,13 @@ window.__ModuleLoader__.load({
2022
2222
  style: {
2023
2223
  marginTop: "6px",
2024
2224
  paddingTop: "12px",
2025
- borderTop: "1px solid var(--dsw-alias-border-l2)",
2225
+ borderTop: "1px solid var(--mp-line, var(--dsw-alias-border-l2))",
2026
2226
  display: "flex",
2027
2227
  alignItems: "baseline",
2028
2228
  gap: "8px",
2029
2229
  flexWrap: "wrap",
2030
2230
  fontSize: "12px",
2031
- color: "var(--dsw-alias-label-tertiary)",
2231
+ color: "var(--mp-muted, var(--dsw-alias-label-tertiary))",
2032
2232
  },
2033
2233
  },
2034
2234
  h("span", null, "项目地址:"),
@@ -2036,7 +2236,7 @@ window.__ModuleLoader__.load({
2036
2236
  href: REPO_URL,
2037
2237
  target: "_blank",
2038
2238
  rel: "noreferrer",
2039
- 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" },
2040
2240
  }, "github.com/Vesna-Strivozha-cn/dsh-modpack-kit"),
2041
2241
  h("span", null, "如果这个插件省了时间,顺手点个 Star,能让更多人找到它。"))
2042
2242
  }
@@ -2086,6 +2286,9 @@ window.__ModuleLoader__.load({
2086
2286
  if (data && data.ok) {
2087
2287
  setCfg(data.config)
2088
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 })
2089
2292
  // 「社区资源」这一栏的开关键在这里:一关,标签立刻消失,不用等重新拉状态
2090
2293
  if (Object.prototype.hasOwnProperty.call(p, "showModpackMarket")) setMarketVisible(data.config.showModpackMarket !== false)
2091
2294
  setSaved("已保存")
@@ -2148,8 +2351,155 @@ window.__ModuleLoader__.load({
2148
2351
 
2149
2352
  const textList = (key) => (Array.isArray(cfg[key]) ? cfg[key].join("\n") : "")
2150
2353
 
2151
- return h("div", { style: { display: "flex", flexDirection: "column", gap: "14px" } },
2152
- 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 },
2153
2503
  h("div", { style: strong }, "扫描与安装策略"),
2154
2504
  h("div", { style: row },
2155
2505
  h(ForcedSwitch, { label: "打包前扫描(强制)", onNag: () => fireScanNag("你想干什么") }),
@@ -2184,8 +2534,7 @@ window.__ModuleLoader__.load({
2184
2534
  }, "保存数值"),
2185
2535
  h("span", { style: hint }, "默认 256 MB,可填 16~4096"),
2186
2536
  saved ? h("span", { style: hint }, saved) : null)),
2187
- ),
2188
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2537
+ h("div", { id: "mp-set-net", style: settingsCard },
2189
2538
  h("div", { style: strong }, "网络与请求上限"),
2190
2539
  h("div", { style: row },
2191
2540
  h("span", { style: label }, "网络超时(秒)"),
@@ -2199,8 +2548,8 @@ window.__ModuleLoader__.load({
2199
2548
  label: "fetch 失败时用系统 curl 兜底",
2200
2549
  onChange: (v) => { setField("curlFallback", v); patch({ curlFallback: v }) },
2201
2550
  })),
2202
- h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl 兜底(走系统证书库)。提示「下载超过上限」时是版本清单太大(billion-context 这类包的清单十几 MB):把「版本清单上限」调大,或改用确定的版本号(插件会直接取单版本清单,体积最小)。保存后立即生效。"),
2203
- 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 },
2204
2553
  h("div", { style: strong }, "信任清单"),
2205
2554
  h("div", { style: hint }, "允许的许可证(一行一个,例如 MIT):"),
2206
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")) }),
@@ -2210,7 +2559,7 @@ window.__ModuleLoader__.load({
2210
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")) }),
2211
2560
  h("div", { style: row },
2212
2561
  h("button", { style: btn, disabled: busy, onClick: () => patch({ licenseAllow: cfg.licenseAllow.filter(Boolean), allowHosts: cfg.allowHosts.filter(Boolean), registries: cfg.registries.filter(Boolean) }) }, "保存清单"))),
2213
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2562
+ h("div", { id: "mp-set-paths", style: settingsCard },
2214
2563
  h("div", { style: strong }, "位置"),
2215
2564
  h("div", { style: mono }, "profile:" + ((props.status && props.status.paths && props.status.paths.profile) || "?")),
2216
2565
  h("div", { style: mono }, "整合包:" + ((props.status && props.status.paths && props.status.paths.packs) || "?")),
@@ -2234,7 +2583,7 @@ window.__ModuleLoader__.load({
2234
2583
  history.length === 0
2235
2584
  ? h("div", { style: hint }, "还没有记录。")
2236
2585
  : h("div", { style: { display: "flex", flexDirection: "column", gap: "2px" } },
2237
- 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" } },
2238
2587
  h("span", { style: { flex: "1 1 auto" } },
2239
2588
  "[" + (item.kind || "?") + "] " + (item.name || item.pack || "") + " · " + when(item.at) + (item.size ? " · " + bytes(item.size) : "") + (item.ok === false ? " · 失败" : "")),
2240
2589
  h("button", {
@@ -2246,14 +2595,14 @@ window.__ModuleLoader__.load({
2246
2595
  h("div", { style: row },
2247
2596
  h("button", { type: "button", style: btn, onClick: () => dropHistory(null, true) }, "清空记录"),
2248
2597
  historyMsg ? h("span", { style: hint }, historyMsg) : null))),
2249
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2598
+ h("div", { id: "mp-set-place", style: settingsCard },
2250
2599
  h("div", { style: strong }, "显示位置"),
2251
2600
  h("div", { style: hint }, "三处互相独立,一点就生效,不用重启。关掉只是不挂载入口,功能与接口都还在。至少留一处:只剩一个时,那个开关会变灰、点不动。"),
2252
2601
  h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
2253
2602
  h(Switch, { checked: cfg.showInSettings !== false, disabled: placementLocked("showInSettings"), label: "在设置里显示(插件设置页内一栏「整合包」)" + (placementLocked("showInSettings") ? "(最后剩这一个,不能关)" : ""), onChange: (v) => savePlacement("showInSettings", v) }),
2254
2603
  h(Switch, { checked: cfg.showInSidebar !== false, disabled: placementLocked("showInSidebar"), label: "在侧边栏显示(左侧栏「整合包」入口)" + (placementLocked("showInSidebar") ? "(最后剩这一个,不能关)" : ""), onChange: (v) => savePlacement("showInSidebar", v) }),
2255
2604
  h(Switch, { checked: cfg.showInPluginsTab === true, disabled: placementLocked("showInPluginsTab"), label: "在插件页内显示(与插件市场同一位置,单开一栏「整合包」)" + (placementLocked("showInPluginsTab") ? "(最后剩这一个,不能关)" : ""), onChange: (v) => savePlacement("showInPluginsTab", v) })),
2256
- 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" } }, "插件市场自己那一行(与上面整合包的入口无关):"),
2257
2606
  h(Switch, {
2258
2607
  checked: cfg.forceHideMarketSidebar === true,
2259
2608
  label: "强制关闭侧栏里的插件市场显示",
@@ -2263,7 +2612,7 @@ window.__ModuleLoader__.load({
2263
2612
  h("div", { style: hint }, "只关市场自己的,不动整合包:改的是它存在 .dsh-market/state.json 里的 sidebarEntry,不动它的安装,也不动整合包的入口。"),
2264
2613
  marketSidebarMsg ? h("div", { style: hint }, marketSidebarMsg) : null,
2265
2614
  saved ? h("span", { style: hint }, saved) : null),
2266
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
2615
+ h("div", { id: "mp-set-market", style: settingsCard },
2267
2616
  h("div", { style: strong }, "社区资源(附属功能)"),
2268
2617
  h("div", { style: hint }, "这是「整合包」的附属小插件:自己一层代码(community/)、自己一套接口;关掉只是把它的接口和这一栏一起下线,打包/安装/进度窗都不受影响。"),
2269
2618
  h(Switch, {
@@ -2277,7 +2626,7 @@ window.__ModuleLoader__.load({
2277
2626
  h("span", { style: label }, "自动更新(小时)"),
2278
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)) }),
2279
2628
  h("button", { style: btn, disabled: busy, onClick: () => patch({ modpackRefreshHours: cfg.modpackRefreshHours }) }, "保存")),
2280
- h("div", { style: { ...hint, borderTop: "0.5px solid var(--dsw-alias-border-l2)", paddingTop: "8px", marginTop: "2px" } }, "下载与安装包:"),
2629
+ h("div", { style: { ...hint, borderTop: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))", paddingTop: "8px", marginTop: "2px" } }, "下载与安装包:"),
2281
2630
  h(Switch, {
2282
2631
  checked: cfg.autoClearPack === true,
2283
2632
  label: "装完自动清除安装包(默认关闭)",
@@ -2288,7 +2637,27 @@ window.__ModuleLoader__.load({
2288
2637
  h("button", { type: "button", style: btn, disabled: busy, onClick: openPackFolder }, "打开整合包下载文件夹"),
2289
2638
  h("span", { style: hint }, packsDirLine || "")),
2290
2639
  h("div", { style: hint }, "搜索、分类、详情与下载码都在「社区资源」那一栏里;上传方式与规则点那一栏右上角。")),
2291
- 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 },
2292
2661
  h("div", { style: strong }, "插件目录(分类 · 搜索 · 分页)"),
2293
2662
  h("div", { style: hint }, (() => {
2294
2663
  const c = props.status && props.status.catalog
@@ -2306,6 +2675,561 @@ window.__ModuleLoader__.load({
2306
2675
  )
2307
2676
  }
2308
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
+
2309
3233
  // —— 社区资源 ——
2310
3234
  // 「从市场下载」到「安装页」之间只有一次交接:市场负责下载、校验、把 token 递过去,
2311
3235
  // 识别 / 扫描 / 兼容 / 许可证 / 安装这些仍然由安装页那条老路做,不另起一套。
@@ -2349,8 +3273,425 @@ window.__ModuleLoader__.load({
2349
3273
  // 两层:外层管左侧「插件 / 整合包」两个大类,里层各自是独立的浏览面板。
2350
3274
  // 整合包这层就是原来的整包浏览(列表 / 详情 / 上传规则)。
2351
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
+
2352
3690
  function MarketPanel(props) {
2353
- 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
+ })
2354
3695
  useEffect(() => { saveMarketKind(kind) }, [kind])
2355
3696
  const market = (props.status && props.status.market) || null
2356
3697
  const installed = Boolean(market && market.installed)
@@ -2366,9 +3707,9 @@ window.__ModuleLoader__.load({
2366
3707
  width: "100%",
2367
3708
  padding: "9px 10px",
2368
3709
  borderRadius: "8px",
2369
- border: kind === id ? "1px solid #4C7DF0" : "1px solid transparent",
3710
+ border: kind === id ? "1px solid var(--mp-primary, #4C7DF0)" : "1px solid transparent",
2370
3711
  background: kind === id ? "rgba(76, 125, 240, 0.12)" : "transparent",
2371
- color: "inherit",
3712
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
2372
3713
  cursor: "pointer",
2373
3714
  textAlign: "left",
2374
3715
  fontSize: "13px",
@@ -2384,7 +3725,7 @@ window.__ModuleLoader__.load({
2384
3725
  display: "flex",
2385
3726
  flexDirection: "column",
2386
3727
  gap: "4px",
2387
- borderRight: "0.5px solid var(--dsw-alias-border-l2)",
3728
+ borderRight: "0.5px solid var(--mp-line, var(--dsw-alias-border-l2))",
2388
3729
  paddingRight: "10px",
2389
3730
  position: "sticky",
2390
3731
  top: 0,
@@ -2516,9 +3857,9 @@ window.__ModuleLoader__.load({
2516
3857
  h("span", { style: { ...strong, fontSize: "15px" } }, item.title || item.name),
2517
3858
  h(Tag, null, item.categoryLabel || item.category || "其它"),
2518
3859
  h("span", { style: { ...hint, marginLeft: "auto" } }, item.name)),
2519
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "14px", display: "flex", flexDirection: "column", gap: "10px" } },
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" } },
2520
3861
  h("div", { style: row },
2521
- h("span", { style: { ...hint, color: latest ? "#2bb673" : (item.updateAvailable ? "#4C7DF0" : "inherit") } }, versionLine(item)),
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)),
2522
3863
  item.owner ? h("span", { style: hint }, "作者 " + item.owner) : null,
2523
3864
  item.publishedAt ? h("span", { style: hint }, "发布 " + item.publishedAt) : null,
2524
3865
  h("span", { style: { ...hint, marginLeft: "auto" } }, item.version ? "市场版 v" + item.version : "")),
@@ -2533,19 +3874,19 @@ window.__ModuleLoader__.load({
2533
3874
  onClick: () => installOne(item),
2534
3875
  }, installLabel(item)),
2535
3876
  latest ? h("span", { style: hint }, "已是当前最新版;想再装一遍也可以。") : null,
2536
- item.updateAvailable ? h("span", { style: { ...hint, color: "#4C7DF0" } }, "本机 v" + (item.localVersion || "?") + " → v" + item.version) : null),
2537
- installMsg ? h("div", { style: { ...hint, color: /没装成/u.test(installMsg) ? "#ff6b6b" : "#2bb673" } }, installMsg) : 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,
2538
3879
  h("div", { style: hint }, "装完插件市场认成市场版(依赖写成 名字@版本);卸载仍去插件市场里做。")),
2539
3880
  h("div", { style: hint }, "点「返回列表」回到刚才那页,搜索与分类都还在。"))
2540
3881
  }
2541
3882
  if (!installed) {
2542
- 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" } },
2543
3884
  h("span", { style: strong }, "请先安装插件市场"),
2544
3885
  h("span", { style: hint }, "「插件」这一类直接读插件市场(dshmarket)的目录与检索,功能基于插件市场;没装就没有这一层可看。"),
2545
3886
  h("span", { style: hint }, "装好插件市场后回到这里,左边这一项会变成「接入插件市场」,列表也就有了。"))
2546
3887
  }
2547
3888
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
2548
- 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" } },
2549
3890
  h("div", { style: { ...row, justifyContent: "space-between" } },
2550
3891
  h("span", { style: { ...strong, fontSize: "13px" } }, "搜索插件"),
2551
3892
  h("span", { style: hint }, "跟打包页同一套:分类、搜索、已装优先;目录与检索都来自插件市场(dsh-plugin-catalog)")),
@@ -2555,41 +3896,41 @@ window.__ModuleLoader__.load({
2555
3896
  value: query,
2556
3897
  placeholder: "插件名 / 作者 / 描述(例如 记忆、壁纸、侧边栏)",
2557
3898
  onChange: (event) => setQuery(event.target.value),
2558
- 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" },
2559
3900
  }),
2560
3901
  h("select", {
2561
3902
  value: sort,
2562
3903
  onChange: (event) => setSort(event.target.value),
2563
- 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" },
2564
3905
  }, [["market", "按相关度"], ["new", "最新发布"], ["name", "按名字"]].map(([value, text]) => h("option", { key: value, value }, text))),
2565
3906
  h("span", { style: { ...hint, textAlign: "right" } }, loading ? "搜索中…" : "共 " + total + " 个")),
2566
3907
  h(CategoryChips, { chips, value: category, onChange: setCategory })),
2567
- 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,
2568
3909
  loading && items.length === 0 ? h("div", { style: { ...hint, padding: "14px 2px" } }, "正在读取插件目录…") : null,
2569
3910
  !loading && items.length === 0 && !error
2570
- ? 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" } },
2571
3912
  h("span", { style: strong }, query ? "没有匹配的插件" : "插件目录还是空的"),
2572
3913
  h("span", { style: hint }, query ? "换个说法试试:插件名、作者名、描述里的词都能搜。" : "插件市场还没建过目录索引:去插件市场里刷一次,或等它自己更新。"))
2573
3914
  : null,
2574
- 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" } },
2575
3916
  items.map((item) => h("div", {
2576
3917
  key: "plug-" + item.name,
2577
3918
  onClick: () => openDetail(item),
2578
3919
  title: "点开看详情与下载",
2579
- style: { display: "flex", flexDirection: "column", gap: "3px", padding: "9px 12px", borderBottom: "0.5px solid var(--dsw-alias-border-l2)", cursor: "pointer" },
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" },
2580
3921
  },
2581
3922
  h("div", { style: row },
2582
3923
  h("span", { style: { fontSize: "13px", fontWeight: 600 } }, item.title || item.name),
2583
3924
  h(Tag, null, item.categoryLabel || item.category || "其它"),
2584
- item.installed ? h("span", { style: { ...hint, color: "#2bb673" } }, "本机已装" + (item.updateAvailable ? "(市场版 " + item.version + " 更新)" : "")) : null,
3925
+ item.installed ? h("span", { style: { ...hint, color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, "本机已装" + (item.updateAvailable ? "(市场版 " + item.version + " 更新)" : "")) : null,
2585
3926
  h("span", { style: { ...hint, marginLeft: "auto" } }, item.version ? "v" + item.version : ""),
2586
- h("span", { style: { ...hint, flexShrink: 0, color: item.updateAvailable ? "#4C7DF0" : undefined } }, isLatest(item) ? "已是最新版本" : (item.installed ? "可更新" : "")),
3927
+ h("span", { style: { ...hint, flexShrink: 0, color: item.updateAvailable ? "var(--mp-primary, #4C7DF0)" : undefined } }, isLatest(item) ? "已是最新版本" : (item.installed ? "可更新" : "")),
2587
3928
  h("span", { style: { ...chipBtn, flexShrink: 0 } }, "查看 ›")),
2588
3929
  h("span", { style: hint }, item.description || "作者没写说明。"),
2589
3930
  h("span", { style: { ...hint, fontSize: "11.5px" } }, item.name)))),
2590
3931
  hasMore ? h("div", { style: row },
2591
3932
  h("button", { type: "button", style: btn, disabled: loading, onClick: loadMore }, loading ? "读取中…" : "加载更多")) : null,
2592
- installMsg ? h("div", { style: { ...hint, color: /没装成/u.test(installMsg) ? "#ff6b6b" : "#2bb673" } }, installMsg) : null,
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,
2593
3934
  h("div", { style: hint }, "装与更新就在这里做:来源跟插件市场一致(npm 上的 名字@版本),装完市场认成市场版;卸载仍去插件市场里做。"))
2594
3935
  }
2595
3936
 
@@ -2799,7 +4140,7 @@ window.__ModuleLoader__.load({
2799
4140
  const height = image.naturalHeight * scale
2800
4141
  const left = size / 2 - width / 2 + (coverOffset.x / frame) * size
2801
4142
  const top = size / 2 - height / 2 + (coverOffset.y / frame) * size
2802
- ctx.fillStyle = "#000"
4143
+ ctx.fillStyle = "#000" // lint-allow-color:canvas 只认具体色值,不解析 var()
2803
4144
  ctx.fillRect(0, 0, size, size)
2804
4145
  ctx.drawImage(image, left, top, width, height)
2805
4146
  const url = canvas.toDataURL("image/png")
@@ -2835,21 +4176,6 @@ window.__ModuleLoader__.load({
2835
4176
  } finally { setPreviewBusy("") }
2836
4177
  }
2837
4178
 
2838
- const previewDownload = async (saveOnly) => {
2839
- if (!localPack) return
2840
- setPreviewBusy(saveOnly ? "save" : "install"); setError(""); setMsg("")
2841
- try {
2842
- const data = await api("/market/download", saveOnly ? { id: localPack.id, saveOnly: true } : { id: localPack.id }, 180000)
2843
- if (!data || data.ok !== true) throw new Error((data && data.error) || "下载失败")
2844
- if (saveOnly) { setMsg("已下到本机:" + (data.savedName || localPack.name)); return }
2845
- requestInstall({ token: data.token, fileName: data.fileName, packName: localPack.name })
2846
- setMsg("已下载并读取:" + localPack.name + ",转到安装页")
2847
- if (typeof props.onGoInstall === "function") props.onGoInstall()
2848
- } catch (e) {
2849
- setError((e && e.message) || String(e))
2850
- } finally { setPreviewBusy("") }
2851
- }
2852
-
2853
4179
  const submit = async (dryRun) => {
2854
4180
  if (!preview) { setError("先选一个包"); return }
2855
4181
  if (!category) { setError("选一个类型"); return }
@@ -2885,19 +4211,19 @@ window.__ModuleLoader__.load({
2885
4211
  const addLabel = preview ? (preview.format === "hybrid" ? "有自定义" : "无修改") : ""
2886
4212
 
2887
4213
  // 步骤外壳:编号圆点 + 标题 + 右侧状态
2888
- const stepCard = (no, title, statusNode, body) => h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px", background: "var(--dsw-alias-bg-l2, transparent)" } },
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))" } },
2889
4215
  h("div", { style: { ...row, gap: "8px" } },
2890
- h("div", { style: { width: "20px", height: "20px", borderRadius: "10px", background: "#4C7DF0", color: "#fff", fontSize: "11px", display: "flex", alignItems: "center", justifyContent: "center", fontWeight: 700, flexShrink: 0 } }, String(no)),
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)),
2891
4217
  h("div", { style: { ...strong, fontSize: "13px" } }, title),
2892
4218
  h("span", { style: { marginLeft: "auto" } }, statusNode)),
2893
4219
  body)
2894
4220
 
2895
- const pluginRow = (item) => h("div", { style: { ...row, gap: "6px", padding: "5px 0", borderTop: "0.5px solid var(--dsw-alias-border-l2)" } },
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))" } },
2896
4222
  h("span", { style: { ...strong, fontSize: "12.5px" } }, item.name),
2897
4223
  h("span", { style: hint }, item.latest ? "市场最新(装的时候按名字取)" : "@" + item.version),
2898
- item.group ? h(Tag, { color: "#4C7DF0" }, "组:" + item.group) : null,
2899
- h(Tag, { color: item.configMode === "custom" ? "#ffb020" : undefined }, item.configMode === "custom" ? "自定义配置" + (item.configKeys ? " · " + item.configKeys + " 项" : "") : "默认配置"),
2900
- item.dataIncluded ? h(Tag, { color: "#2bb673" }, "带数据" + (item.dataRedacted ? " · 擦除 " + item.dataRedacted + " 处" : "")) : null,
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,
2901
4227
  item.embedded ? h(Tag, null, "本体在包里") : null)
2902
4228
 
2903
4229
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "12px" } },
@@ -2909,7 +4235,7 @@ window.__ModuleLoader__.load({
2909
4235
  h("div", { style: hint }, "打包好一份轻量包或混合包,在这里选它:插件自己算 sha256、写条目,再用你的 GitHub 账号 fork 目录仓库、开一个 PR。全程本机发请求,不消耗模型 token。凭据只在内存里,上传结束(成功或失败)立刻丢掉,所以每次都要重填。"),
2910
4236
 
2911
4237
  stepCard(1, "GitHub 凭据",
2912
- configured ? h(Tag, { color: "#2bb673" }, "已就绪") : h(Tag, null, "待填"),
4238
+ configured ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "已就绪") : h(Tag, null, "待填"),
2913
4239
  h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
2914
4240
  h("div", { style: hint }, configured ? ("本次已放进内存" + (status && status.login ? ":登录为 " + status.login : "") + "(上传结束就会清掉)") : "classic token 勾 repo 就够;fine-grained 要 contents 与 pull requests 读写。只放内存,不写盘"),
2915
4241
  h("div", { style: row },
@@ -2924,7 +4250,7 @@ window.__ModuleLoader__.load({
2924
4250
  configured ? h("button", { type: "button", style: btn, disabled: busy !== "", onClick: () => { setToken(""); saveToken() } }, "清除") : null))),
2925
4251
 
2926
4252
  stepCard(2, "选包",
2927
- preview ? h(Tag, { color: "#2bb673" }, "已读取") : h(Tag, null, busy === "read" ? "读取中" : "待选"),
4253
+ preview ? h(Tag, { color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" }, "已读取") : h(Tag, null, busy === "read" ? "读取中" : "待选"),
2928
4254
  h("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } },
2929
4255
  h("div", { style: row },
2930
4256
  h("input", {
@@ -2942,10 +4268,10 @@ window.__ModuleLoader__.load({
2942
4268
  h("button", { type: "button", style: btn, disabled: busy !== "", onClick: browseFolder }, "浏览文件夹…"),
2943
4269
  preview ? h("button", { type: "button", style: btn, disabled: busy !== "", onClick: clearFile }, "清除") : null),
2944
4270
  preview
2945
- ? h("div", { style: { ...box, padding: "10px 12px", background: "var(--dsw-alias-bg-l1, transparent)", display: "flex", flexDirection: "column", gap: "6px" } },
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" } },
2946
4272
  h("div", { style: row },
2947
4273
  h("span", { style: { ...strong, fontSize: "13px" } }, fileName),
2948
- h(Tag, { color: preview.format === "hybrid" ? "#a855f7" : "#4C7DF0" }, fmt),
4274
+ h(Tag, { color: preview.format === "hybrid" ? "var(--mp-accent, #a855f7)" : "var(--mp-primary, #4C7DF0)" }, fmt),
2949
4275
  h(Tag, null, addLabel),
2950
4276
  h(Tag, null, (preview.plugins || 0) + " 个插件")),
2951
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 + " 个" : "不带本体,装的时候按版本取")))
@@ -2960,22 +4286,22 @@ window.__ModuleLoader__.load({
2960
4286
  onClick: () => readPath(item.path),
2961
4287
  }, item.name + " · " + Math.round(Number(item.size || 0) / 1024) + " KB")))
2962
4288
  : null,
2963
- dirErr ? h("div", { style: { ...hint, color: "#ff6b6b" } }, dirErr) : null)),
4289
+ dirErr ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, dirErr) : null)),
2964
4290
 
2965
4291
  preview
2966
4292
  ? h(FoldBox, {
2967
4293
  title: "这个包里大致有什么",
2968
4294
  defaultOpen: true,
2969
- summary: [h(Tag, { color: preview.format === "hybrid" ? "#a855f7" : "#4C7DF0" }, fmt), h(Tag, null, (preview.plugins || 0) + " 个插件")],
4295
+ summary: [h(Tag, { color: preview.format === "hybrid" ? "var(--mp-accent, #a855f7)" : "var(--mp-primary, #4C7DF0)" }, fmt), h(Tag, null, (preview.plugins || 0) + " 个插件")],
2970
4296
  hint: "展开",
2971
4297
  collapsedNote: (preview.plugins || 0) + " 个插件" + (sum.configMode === "custom" ? " · " + sum.configCount + " 个带自定义配置" : " · 全部默认配置") + (sum.dataCount ? " · " + sum.dataCount + " 个带数据" : "") + (sum.redacted ? " · 擦除 " + sum.redacted + " 处凭据" : "") + "(点标题展开)",
2972
4298
  },
2973
4299
  h("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } },
2974
4300
  h("div", { style: row },
2975
- h(Tag, { color: sum.configMode === "custom" ? "#ffb020" : "#2bb673" }, sum.configMode === "custom" ? "有自定义配置:" + sum.configCount + " 个" : "全部默认配置"),
2976
- sum.dataCount ? h(Tag, { color: "#2bb673" }, "带数据:" + sum.dataCount + " 个") : h(Tag, null, "不带数据"),
2977
- sum.redacted ? h(Tag, { color: "#ffb020" }, "擦除凭据:" + sum.redacted + " 处") : null,
2978
- (sum.groups && sum.groups.length) ? h(Tag, { color: "#4C7DF0" }, "分组:" + sum.groups.join("、")) : null),
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),
2979
4305
  h("div", { style: { ...hint, marginTop: "4px" } }, "每个插件默认都是「默认配置」;打包时单独选成「自定义配置」或带上了数据/凭据的,会在下面单独标出来。这里只数清单里的顶层插件,插件自己带的组件不算。"),
2980
4306
  pluginItems.length > 0
2981
4307
  ? pluginItems.map((item) => h("div", { key: "pv-" + item.name }, pluginRow(item)))
@@ -2983,7 +4309,7 @@ window.__ModuleLoader__.load({
2983
4309
  : null,
2984
4310
 
2985
4311
  preview
2986
- ? stepCard(3, "改一下词条", changed.length > 0 ? h(Tag, { color: "#4C7DF0" }, "将改 " + changed.length + " 项") : h(Tag, null, "不改"),
4312
+ ? stepCard(3, "改一下词条", changed.length > 0 ? h(Tag, { color: "var(--mp-primary, #4C7DF0)" }, "将改 " + changed.length + " 项") : h(Tag, null, "不改"),
2987
4313
  h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
2988
4314
  h("div", { style: hint }, "名称、作者、简介、主页如果改过,会写回包里的 dsh-modpack.json,再重算 sha256 与条目——目录里显示的、别人装到的都是改后的内容。"),
2989
4315
  h("div", { style: row },
@@ -3000,7 +4326,7 @@ window.__ModuleLoader__.load({
3000
4326
  h("select", { style: { ...input, maxWidth: "200px" }, value: category, onChange: (e) => setCategory(e.target.value) },
3001
4327
  UPLOAD_CATEGORIES.map((name) => h("option", { key: "cat-" + name, value: name }, name)))),
3002
4328
  changed.length > 0
3003
- ? h("div", { style: { ...hint, color: "#4C7DF0" } }, "会改:" + changed.map((key) => (({ name: "名称", author: "作者", description: "简介", homepage: "主页" })[key])).join("、"))
4329
+ ? h("div", { style: { ...hint, color: "var(--mp-primary, #4C7DF0)" } }, "会改:" + changed.map((key) => (({ name: "名称", author: "作者", description: "简介", homepage: "主页" })[key])).join("、"))
3004
4330
  : h("div", { style: hint }, "没改任何一项:按包里的清单原样提交。")))
3005
4331
  : null,
3006
4332
 
@@ -3022,7 +4348,7 @@ window.__ModuleLoader__.load({
3022
4348
  onPointerMove: coverMove,
3023
4349
  onPointerUp: coverUp,
3024
4350
  onPointerCancel: coverUp,
3025
- style: { position: "relative", width: COVER_FRAME + "px", height: COVER_FRAME + "px", overflow: "hidden", borderRadius: "10px", border: "1px solid #4C7DF0", background: "#000", cursor: "grab", touchAction: "none", flex: "0 0 auto" },
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" },
3026
4352
  },
3027
4353
  h("img", {
3028
4354
  src: coverSrc,
@@ -3040,10 +4366,10 @@ window.__ModuleLoader__.load({
3040
4366
  h("div", { style: hint }, "预览:" + (cover ? "已按上面框里那块生成 " + coverSize + "×" + coverSize + " 的图" : "还没应用"))))
3041
4367
  : null,
3042
4368
  cover ? h("div", { style: row },
3043
- h("img", { src: cover, alt: "", style: { height: "52px", width: "52px", objectFit: "cover", borderRadius: "6px", border: "0.5px solid var(--dsw-alias-border-l2)" } }),
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))" } }),
3044
4370
  h("span", { style: hint }, "上传的就是这一张(列表 42×42、详情 88×88 都按它缩)")) : null,
3045
- coverErr ? h("div", { style: { ...hint, color: "#ff6b6b" } }, coverErr) : null,
3046
- h("div", { style: { ...hint, color: "#ff6b6b" } }, "严禁上传与整合包无关、侵权或违规的图片:目录是公开的,图片会随条目一起公开显示。"))),
4371
+ coverErr ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, coverErr) : null,
4372
+ h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, "严禁上传与整合包无关、侵权或违规的图片:目录是公开的,图片会随条目一起公开显示。"))),
3047
4373
 
3048
4374
  stepCard(6, "预览",
3049
4375
  h(Tag, null, localPack ? "已放进社区列表" : "还没预览"),
@@ -3067,15 +4393,15 @@ window.__ModuleLoader__.load({
3067
4393
  : h("div", { style: hint }, "放进目录仓库最简单:只有这一次 PR,不占你自己的仓库;缺点是没有逐文件下载计数,列表里显示「下载量未统计」。"),
3068
4394
  h("div", { style: hint }, "只收轻量包(无修改)和混合包(有自定义);完整包请放到发布页。"))),
3069
4395
 
3070
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px", borderColor: "#4C7DF0" } },
4396
+ h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px", borderColor: "var(--mp-primary, #4C7DF0)" } },
3071
4397
  h("div", { style: row },
3072
4398
  h("button", { type: "button", style: { ...btnPrimary, height: "32px", padding: "0 16px", fontSize: "13px" }, disabled: busy !== "" || !preview || !configured, onClick: () => submit(false) }, busy === "submit" ? "提交中…" : "确认上传(开 PR)"),
3073
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" ? "演练中…" : "演练一次(不真上传)"),
3074
4400
  h("span", { style: hint }, configured ? (preview ? ("将提交:" + (fields.name || fileName) + " · " + category + " · " + (host === "release" ? "Release" : "目录仓库") + (changed.length ? " · 改 " + changed.length + " 项词条" : " · 词条不改")) : "先选一个包") : "先保存凭据")),
3075
4401
  h("div", { style: hint }, "提交后进入任务队列:进度显示在左下角悬浮窗,完成给「打开 PR」,卡住给「我已知晓」。")),
3076
4402
 
3077
- msg ? h("div", { style: { ...box, padding: "10px 12px", borderColor: "#2bb673", color: "#2bb673", fontSize: "12.5px", lineHeight: "19px" } }, msg) : null,
3078
- error ? h("div", { style: { ...box, padding: "10px 12px", borderColor: "#ff6b6b", color: "#ff6b6b", fontSize: "12.5px", lineHeight: "19px" } }, error) : null)
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)
3079
4405
  }
3080
4406
 
3081
4407
  // ===== [区块] 社区资源小插件:整合包浏览(列表 / 详情 / 上传规则) ====
@@ -3259,21 +4585,21 @@ window.__ModuleLoader__.load({
3259
4585
  return h("img", {
3260
4586
  src: url,
3261
4587
  alt: "",
3262
- style: { width: size + "px", height: size + "px", borderRadius: "6px", objectFit: "cover", border: "0.5px solid var(--dsw-alias-border-l2)", flex: "0 0 auto" },
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" },
3263
4589
  })
3264
4590
  }
3265
4591
 
3266
4592
  // 分类英文名(目录里只存中文 label,英文界面在这里映射)
3267
4593
  const catLabel = (name) => name
3268
- 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))" }
3269
4595
  const initialsOf = (name) => String(name || "?").replace(/\s+/gu, "").slice(0, 2) || "?"
3270
4596
  // 体量词条:不靠作者写,按插件总数自动算(0-3 轻量 / 4-8 中型 / 9-12 大型 / 13+ 大宗)
3271
4597
  const TIER_LABELS = { small: "轻量", medium: "中型", large: "大型", huge: "大宗" }
3272
- 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)" }
3273
4599
  const tierInfo = (pack) => {
3274
4600
  const count = Array.isArray(pack.plugins) ? pack.plugins.length : 0
3275
4601
  const id = pack.tier || (count >= 13 ? "huge" : count >= 9 ? "large" : count >= 4 ? "medium" : "small")
3276
- 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] || "轻量" }
3277
4603
  }
3278
4604
  const tierTag = (pack) => {
3279
4605
  const info = tierInfo(pack)
@@ -3296,7 +4622,7 @@ window.__ModuleLoader__.load({
3296
4622
  return text || "作者没写说明。"
3297
4623
  }
3298
4624
  const renderRow = (pack) => {
3299
- const tint = CATEGORY_TINT[pack.category] || "#64748b"
4625
+ const tint = CATEGORY_TINT[pack.category] || "var(--mp-muted, var(--dsw-alias-label-tertiary, #64748b))"
3300
4626
  const plugins = pack.plugins || []
3301
4627
  const meta = []
3302
4628
  meta.push(plugins.length + " 个插件")
@@ -3308,12 +4634,12 @@ window.__ModuleLoader__.load({
3308
4634
  return h("div", {
3309
4635
  key: "pack-" + pack.id,
3310
4636
  onClick: () => { setDetail(pack); setView("detail"); setError(""); setMsg("") },
3311
- 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" },
3312
4638
  },
3313
4639
  coverImg(pack, 42) || h("div", {
3314
4640
  style: {
3315
4641
  width: "42px", height: "42px", flexShrink: 0, borderRadius: "8px",
3316
- background: tint, color: "#fff", fontSize: "13px", fontWeight: 600,
4642
+ background: tint, color: "var(--mp-on-primary, #fff)", fontSize: "13px", fontWeight: 600,
3317
4643
  display: "flex", alignItems: "center", justifyContent: "center", letterSpacing: "0.5px",
3318
4644
  },
3319
4645
  }, initialsOf(pack.name)),
@@ -3324,10 +4650,10 @@ window.__ModuleLoader__.load({
3324
4650
  tierTag(pack),
3325
4651
  h(Tag, { title: pack.customization === "custom" ? "这份包带着作者本地的配置或改动" : "只记版本,没有任何本地改动" }, pack.customization === "custom" ? "有自定义" : "无修改"),
3326
4652
  pack.version ? h(Tag, null, "v" + pack.version) : null,
3327
- pack.preview ? h(Tag, { color: "#f59e0b", title: "只在这台机器上模拟,没有上传" }, "测试预览") : null,
4653
+ pack.preview ? h(Tag, { color: "var(--mp-warn, #f59e0b)", title: "只在这台机器上模拟,没有上传" }, "测试预览") : null,
3328
4654
  ),
3329
4655
  h("span", { style: { ...hint, display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical", overflow: "hidden", lineHeight: "18px" } }, descOf(pack)),
3330
- pack.preview ? h("span", { style: { ...hint, color: "#b45309" } }, "测试预览 · 没上传,也没开 PR") : null,
4656
+ pack.preview ? h("span", { style: { ...hint, color: "var(--mp-warn, #ffb020)" } }, "测试预览 · 没上传,也没开 PR") : null,
3331
4657
  h("div", { style: { ...row, gap: "14px" } }, meta.map((line, index) => h("span", { key: "meta-" + pack.id + "-" + index, style: hint }, line)))))
3332
4658
  }
3333
4659
  const rows = previewPack ? [previewPack].concat(items.filter((item) => item.id !== previewPack.id)) : items
@@ -3355,7 +4681,7 @@ window.__ModuleLoader__.load({
3355
4681
  h("div", { style: { ...hint, lineHeight: "20px" } }, "收轻量包(无修改)与混合包(有自定义);审核与出问题下架都靠 PR 与 issue,和插件市场一样。"),
3356
4682
  h("ol", { style: { margin: 0, paddingLeft: "18px", display: "flex", flexDirection: "column", gap: "8px" } },
3357
4683
  MARKET_RULES.map((line, index) => h("li", { key: "rule-" + index, style: { fontSize: "12.5px", lineHeight: "19px" } }, line))),
3358
- 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" } },
3359
4685
  h("span", { style: strong }, "清单长这样"),
3360
4686
  h("code", { style: { fontSize: "11.5px", whiteSpace: "pre-wrap", lineHeight: "17px" } },
3361
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(打包时填的)')),
@@ -3373,7 +4699,7 @@ window.__ModuleLoader__.load({
3373
4699
  h(Tag, null, catLabel(pack.category || "其它")),
3374
4700
  tierTag(pack),
3375
4701
  h(Tag, { title: pack.customization === "custom" ? "这份包带着作者本地的配置或改动" : "只记版本,没有任何本地改动" }, pack.customization === "custom" ? "有自定义" : "无修改"),
3376
- pack.preview ? h(Tag, { color: "#f59e0b", title: "只在这台机器上模拟,没有上传" }, "测试预览") : null,
4702
+ pack.preview ? h(Tag, { color: "var(--mp-warn, #f59e0b)", title: "只在这台机器上模拟,没有上传" }, "测试预览") : null,
3377
4703
  h("span", { style: hint }, (pack.version ? "v" + pack.version + " · " : "") + "作者 " + (pack.author || "?") + " · " + sizeText(pack.size) + " · " + plugins.length + " 个插件")),
3378
4704
  coverImg(pack, 88) || null,
3379
4705
  h("div", { style: { ...hint, lineHeight: "20px" } },
@@ -3382,27 +4708,27 @@ window.__ModuleLoader__.load({
3382
4708
  : "下载 " + Number(pack.downloads) + " 次(这个安装文件本身的下载量,不是里面插件的)"
3383
4709
  + " · 创建 " + (pack.createdAt ? String(pack.createdAt).slice(0, 10) : "未记录")
3384
4710
  + " · 上次更新 " + (pack.updatedAt ? String(pack.updatedAt).slice(0, 10) : (pack.createdAt ? String(pack.createdAt).slice(0, 10) : "未记录"))),
3385
- 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" } },
3386
4712
  h("span", { style: strong }, "这个整合包是做什么的"),
3387
4713
  h("div", { style: { fontSize: "12.5px", lineHeight: "20px" } }, descOf(pack)),
3388
4714
  ),
3389
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
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" } },
3390
4716
  h("div", { style: row },
3391
4717
  h("span", { style: strong }, "本机情况"),
3392
4718
  h(Tag, { title: "只数包里清单列的顶层插件;壁纸引擎那类组件不算" }, "已装 " + packInstalledCount + " / " + packPlugins.length),
3393
4719
  packMissing.length
3394
4720
  ? h(Tag, { title: "这些插件在你本机还没装" }, "缺 " + packMissing.length + " 个")
3395
- : h("span", { style: { ...hint, color: "#2bb673" } }, "都装了")),
4721
+ : h("span", { style: { ...hint, color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, "都装了")),
3396
4722
  packMissing.length
3397
4723
  ? h("div", { style: { fontSize: "12.5px", lineHeight: "19px" } }, "本机还没装:" + packMissing.map((item) => item.name + (item.latest !== false ? "(装的时候取市场最新)" : (item.version ? "@" + item.version : ""))).join("、"))
3398
- : h("div", { style: { ...hint, color: "#2bb673" } }, "包里的插件本机都有,无需安装"),
4724
+ : h("div", { style: { ...hint, color: "var(--mp-ok, var(--dsw-alias-state-success-primary, #2bb673))" } }, "包里的插件本机都有,无需安装"),
3399
4725
  detail.hasSpecialConfig
3400
4726
  ? h("div", { style: { fontSize: "12.5px", lineHeight: "19px" } }, "包里带了特殊配置:" + (detail.configPlugins || []).map((item) => item.name + "(" + item.keys + " 个键)").join("、") + ";安装时可以选择「包内配置」或「保持本机」。")
3401
4727
  : h("div", { style: hint }, "包里没有单独的配置改动:插件都用各自的默认配置。"),
3402
4728
  detail.hasData ? h("div", { style: hint }, "还带着数据快照(安装时默认不覆盖你已有的文件,会问你要不要写回)。") : null,
3403
4729
  detail.redactedTotal ? h("div", { style: hint }, "其中 " + detail.redactedTotal + " 处疑似凭据已被替换成 ${REDACTED},装完要自己重填。") : null,
3404
4730
  detail.groups && detail.groups.length ? h("div", { style: hint }, "带了分组:" + detail.groups.join("、") + "(本机装了插件市场就并进同名组)") : null),
3405
- h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", padding: "12px", display: "flex", flexDirection: "column", gap: "6px" } },
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" } },
3406
4732
  h("div", { style: { ...row, justifyContent: "space-between" } },
3407
4733
  h("span", { style: strong }, "包含的插件(这些插件会干什么)"),
3408
4734
  plugins.length === 0 ? null : h("button", {
@@ -3413,18 +4739,18 @@ window.__ModuleLoader__.load({
3413
4739
  }, descOpen ? "收起介绍" : "显示介绍")),
3414
4740
  plugins.length === 0
3415
4741
  ? h("span", { style: hint }, "清单里没有插件记录。")
3416
- : 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" } },
3417
4743
  h("div", { style: row },
3418
4744
  h("span", { style: { fontSize: "12.5px", fontWeight: 600 } }, plugin.name),
3419
4745
  h(Tag, null, plugin.version ? "@" + plugin.version : "@市场最新")),
3420
4746
  descOpen ? h("span", { style: hint }, pluginDescOf(plugin)) : null)),
3421
4747
  h("span", { style: hint }, "安装时按上面的版本从插件市场取包;取不到就明确报错,不会拿别的东西顶替。"),
3422
4748
  h("span", { style: hint }, "这里只数清单里的顶层插件;像壁纸引擎那样由插件自己带的一组组件不算在里面,装好后由那个插件自己管理。")),
3423
- 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" } },
3424
4750
  h("span", { style: strong }, "下载码"),
3425
4751
  h("code", { style: { fontSize: "11.5px", whiteSpace: "pre-wrap", lineHeight: "17px", wordBreak: "break-all" } }, downloadCode),
3426
4752
  h("span", { style: hint }, "下载码就是包的直链 + sha256:谁拿到都能自己下载核对,不依赖这个界面。")),
3427
- error ? h("div", { style: { ...hint, color: "#ff6b6b" } }, error) : null,
4753
+ error ? h("div", { style: { ...hint, color: "var(--mp-danger, #ff6b6b)" } }, error) : null,
3428
4754
  msg ? h("div", { style: hint }, msg) : null,
3429
4755
  h("div", { style: row },
3430
4756
  h("button", { type: "button", style: btn, disabled: downloading, onClick: () => download(pack, true) }, downloading ? "下载中…" : "下载到本地"),
@@ -3433,7 +4759,7 @@ window.__ModuleLoader__.load({
3433
4759
  }
3434
4760
 
3435
4761
  const searchCard = h("div", {
3436
- 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" },
3437
4763
  },
3438
4764
  h("div", { style: { ...row, justifyContent: "space-between" } },
3439
4765
  h("span", { style: { ...strong, fontSize: "13px" } }, "搜索整合包"),
@@ -3445,19 +4771,19 @@ window.__ModuleLoader__.load({
3445
4771
  value: query,
3446
4772
  placeholder: "整合包名 / 作者 / 插件名(例如 B站、壁纸、记忆)",
3447
4773
  onChange: (event) => { setQuery(event.target.value); setPage(1) },
3448
- 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" },
3449
4775
  }),
3450
4776
  h("span", { style: hint }, "类型"),
3451
4777
  h("select", {
3452
4778
  value: category,
3453
4779
  onChange: (event) => { setCategory(event.target.value); setPage(1) },
3454
- 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" },
3455
4781
  }, chips.map((chip) => h("option", { key: "sel-" + chip.id, value: chip.id }, chip.label + "(" + (chip.count || 0) + ")"))),
3456
4782
  h("span", { style: hint }, "排序"),
3457
4783
  h("select", {
3458
4784
  value: sort,
3459
4785
  onChange: (event) => { setSort(event.target.value); setPage(1) },
3460
- 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" },
3461
4787
  }, MARKET_SORTS.map(([value, text]) => h("option", { key: value, value }, text)))),
3462
4788
  h("div", { style: row },
3463
4789
  h("button", { type: "button", style: { ...btn, minWidth: "96px" }, disabled: searching, onClick: () => setSearchTick((n) => n + 1) }, searching ? "搜索中…" : "搜索"),
@@ -3465,7 +4791,7 @@ window.__ModuleLoader__.load({
3465
4791
  h("button", { type: "button", style: { ...btn, minWidth: "128px" }, onClick: () => { if (typeof props.onGoInstall === "function") props.onGoInstall() } }, "安装已有整合包"),
3466
4792
  h("span", { style: { ...hint, marginLeft: "auto" } }, "共 " + total + " 个")))
3467
4793
 
3468
- 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" } },
3469
4795
  h("span", { style: strong }, query ? "没有匹配的整合包" : present ? "这个类型下还没有整合包" : "还没有整合包目录"),
3470
4796
  h("span", { style: hint }, query
3471
4797
  ? "换个说法试试:整合包名、作者名、插件名都能搜。"
@@ -3482,10 +4808,10 @@ window.__ModuleLoader__.load({
3482
4808
  : null)
3483
4809
 
3484
4810
  const listBox = rows.length > 0
3485
- ? h("div", { style: { border: "1px solid var(--dsw-alias-border-l2)", borderRadius: "10px", overflow: "hidden" } },
4811
+ ? h("div", { style: { border: "1px solid var(--mp-line, var(--dsw-alias-border-l2))", borderRadius: "10px", overflow: "hidden" } },
3486
4812
  previewPack
3487
- ? h("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "7px 12px", background: "#fff7ed", borderBottom: "0.5px solid #fed7aa", color: "#b45309", fontSize: "11.5px" } },
3488
- h(Tag, { color: "#f59e0b" }, "测试预览"),
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)" }, "测试预览"),
3489
4815
  h("span", null, "这一条只在本机模拟:没上传、没开 PR,也不会出现在别人的社区列表里"),
3490
4816
  h("button", { type: "button", style: chipBtn, onClick: () => { setPreviewPack(null); setMsg("") } }, "移除预览"))
3491
4817
  : null,
@@ -3496,7 +4822,7 @@ window.__ModuleLoader__.load({
3496
4822
  head,
3497
4823
  searchCard,
3498
4824
  loading && items.length === 0 ? h("div", { style: { ...hint, padding: "14px 2px" } }, "正在读取整合包目录…") : null,
3499
- 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,
3500
4826
  msg ? h("div", { style: hint }, msg) : null,
3501
4827
  listBox,
3502
4828
  !loading && rows.length === 0 ? emptyCard : null,
@@ -3516,8 +4842,12 @@ window.__ModuleLoader__.load({
3516
4842
  // 插件页里的那一栏外面已经有一层页头与标签:嵌进去不能再摆一遍大标题,
3517
4843
  // 否则同一屏里会出现两个名字、两套边距,看着像画坏了。
3518
4844
  const embedded = surface === "plugins"
4845
+ // 上了主题就整片上色:标题带、页底渐变、卡片、按钮都跟着主色走(经典界面 / 跟宿主原生时是 false)
4846
+ const themed = props.themeOn === true
3519
4847
  const [packResult, setPackResult] = useState(() => readPackValue())
3520
4848
  const [focus, setFocus] = useState(0)
4849
+ // 插件树是全屏浮层:开着的时候页签照旧停在那儿,关掉回到原来那一屏
4850
+ const [treeOpen, setTreeOpen] = useState(false)
3521
4851
  const [unlag, setUnlag] = useState(null)
3522
4852
  const [unlagMsg, setUnlagMsg] = useState("")
3523
4853
  // 解除卡顿是别人家的插件:有就出按钮,没有就什么都不显示。
@@ -3595,10 +4925,17 @@ window.__ModuleLoader__.load({
3595
4925
  // 拖到角上挡住界面时用这个:位置清掉、回到右下角默认位,并且强制显示
3596
4926
  const recallBtn = h("button", {
3597
4927
  type: "button",
3598
- 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 },
3599
4929
  title: "把进度窗叫回右下角的默认位置(拖到角落挡住了界面就用这个)",
3600
4930
  onClick: () => { requestDockReset() },
3601
4931
  }, "召回进度窗")
4932
+ // 插件树(附属小插件):界面照我的世界 AE2 的配方树,滚轮缩放、按住空白拖动
4933
+ const treeBtn = h("button", {
4934
+ type: "button",
4935
+ style: chipBtn,
4936
+ title: "插件树与兼容树:按插件自己的声明构筑,滚轮缩放、拖动查看;关掉这个附属小插件后这里会提示没启用",
4937
+ onClick: () => setTreeOpen(true),
4938
+ }, "插件树")
3602
4939
  const [eggMsg, setEggMsg] = useState("")
3603
4940
  const eggClicks = useRef([])
3604
4941
  const eggTimer = useRef(0)
@@ -3620,7 +4957,7 @@ window.__ModuleLoader__.load({
3620
4957
  bottom: "88px",
3621
4958
  transform: "translateX(-50%)",
3622
4959
  background: "rgba(18, 20, 26, 0.92)",
3623
- color: "#fff",
4960
+ color: "var(--mp-on-primary, #fff)",
3624
4961
  padding: "9px 16px",
3625
4962
  borderRadius: "10px",
3626
4963
  fontSize: "13px",
@@ -3635,27 +4972,54 @@ window.__ModuleLoader__.load({
3635
4972
  ["pack", "打包"],
3636
4973
  ["install", "安装 / 导入"],
3637
4974
  ...(marketOn ? [["market", "社区资源"]] : []),
4975
+ ["manager", "插件管理"],
3638
4976
  ["settings", "设置与记录"],
3639
4977
  ]
4978
+ const plain = props.plain === true
3640
4979
  const tabBtn = (key, text) => h("button", {
3641
4980
  key,
3642
4981
  onClick: () => { setTab(key); if (key === "market") spotEgg() },
3643
- style: {
3644
- ...btn,
3645
- fontSize: embedded ? "12px" : btn.fontSize,
3646
- padding: embedded ? "3px 9px" : btn.padding,
3647
- borderColor: tab === key ? "transparent" : "var(--dsw-alias-border-l2)",
3648
- background: tab === key ? "var(--dsw-alias-fill-primary, #3b6cf6)" : "transparent",
3649
- color: tab === key ? "#fff" : "var(--dsw-alias-label-primary)",
3650
- },
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
+ },
3651
5000
  }, text)
3652
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
3653
5015
  const panels = [
3654
5016
  tab === "pack" ? h(PackPanel, { key: "pack-" + gen, status, jobs, result: packResult, setResult: savePackResult, focus }) : null,
3655
5017
  tab === "install" ? h(InstallPanel, { key: "install-" + gen, status }) : null,
3656
5018
  tab === "market" ? h(MarketPanel, { key: "market-" + gen, status, onGoInstall: () => setTab("install") }) : null,
3657
- 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,
3658
5021
  ]
5022
+ const treeNode = treeOpen ? h(PluginTreeOverlay, { key: "tree", status, onClose: () => setTreeOpen(false) }) : null
3659
5023
  // 这段是打包/安装的安全说明,社区资源里不该出现(那里是逛目录,不是打包)
3660
5024
  const footNote = tab === "market" ? null : h("div", { style: hint }, "说明:整合包只打包你选择的插件与必要配置。打包与安装安全检测在内存中进行,命中原文不落盘;请遵守插件作者许可证与你所在地区的法律法规。")
3661
5025
  const unlagNode = unlag
@@ -3683,16 +5047,29 @@ window.__ModuleLoader__.load({
3683
5047
  style: {
3684
5048
  display: "flex",
3685
5049
  flexDirection: "column",
3686
- color: "var(--dsw-alias-label-primary)",
5050
+ color: "var(--mp-text, var(--dsw-alias-label-primary))",
3687
5051
  padding: "10px 2px 24px",
3688
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",
3689
5058
  },
3690
5059
  },
3691
- h("div", { style: { maxWidth: "1020px", margin: "0 auto", width: "100%", display: "flex", flexDirection: "column", gap: "10px" } },
3692
- 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),
3693
5069
  eggNode,
3694
5070
  unlagNode,
3695
- panels,
5071
+ treeNode,
5072
+ staleNode, h("div", { style: panelSurface }, panels),
3696
5073
  footNote,
3697
5074
  h(RepoFooter, null)),
3698
5075
  h(JobDock, { jobs, onOpenResult: openResult })
@@ -3700,15 +5077,36 @@ window.__ModuleLoader__.load({
3700
5077
  }
3701
5078
 
3702
5079
  return h("div", {
3703
- 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
+ },
3704
5086
  },
3705
5087
  h("div", { style: { maxWidth: "1020px", margin: "0 auto", display: "flex", flexDirection: "column", gap: "14px" } },
3706
- h("div", { style: { display: "flex", alignItems: "baseline", gap: "10px", flexWrap: "wrap" } },
3707
- h("h2", { style: { margin: 0, fontSize: "20px", fontWeight: 600 } }, "整合包"),
3708
- h("span", { style: hint }, ((status && status.config && status.config.tagline) || "谁说 dsh 不能整整合包呢?(你说这几个插件整一块不牛逼坏了)"))),
3709
- 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),
3710
5107
  eggNode,
3711
- panels,
5108
+ treeNode,
5109
+ staleNode, h("div", { style: panelSurface }, panels),
3712
5110
  footNote,
3713
5111
  h(RepoFooter, null)),
3714
5112
  h(JobDock, { jobs, onOpenResult: openResult })
@@ -3730,6 +5128,33 @@ window.__ModuleLoader__.load({
3730
5128
  const [tries, setTries] = useState(0)
3731
5129
  const [gen, setGen] = useState(0)
3732
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])
3733
5158
  useEffect(() => () => { alive.current = false }, [])
3734
5159
  // 宿主刚起来、会话还在建的时候,第一次可能拿不到状态(401/网络没就绪)。
3735
5160
  // 自己退避重试几次,别让用户看到一块红字或者一块空白。
@@ -3758,12 +5183,12 @@ window.__ModuleLoader__.load({
3758
5183
  }, [])
3759
5184
  useEffect(() => { load(3) }, [load])
3760
5185
  if (error) {
3761
- 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" } },
3762
5187
  h("span", null, "整合包没起来:" + error),
3763
5188
  h("button", { type: "button", style: btn, onClick: () => { setError(""); setTries(0); load(3) } }, "重试"))
3764
5189
  }
3765
5190
  if (!status) {
3766
- 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" } },
3767
5192
  tries > 0 ? "整合包:还在连 DSH 本体…(自动重试 " + tries + " 次)" : "整合包:读取环境…")
3768
5193
  }
3769
5194
  // 手动刷新:先重读 status,再把下面几个面板整体重挂一次(gen+1)。
@@ -3772,6 +5197,8 @@ window.__ModuleLoader__.load({
3772
5197
  return h(Home, {
3773
5198
  status,
3774
5199
  surface: (props && props.surface) || "sidebar",
5200
+ themeOn,
5201
+ plain: classicUi,
3775
5202
  gen,
3776
5203
  onRefresh: async () => {
3777
5204
  await load(3)
@@ -3785,14 +5212,14 @@ window.__ModuleLoader__.load({
3785
5212
  // 三处显示位各自注册什么。开关一翻就整组挂上 / 整组撤掉,不动别的插件。
3786
5213
  const PLACEMENT_MOUNTS = {
3787
5214
  settings: () => [
3788
- { slot: "settings.section", spec: { name: "settings.section", id: "dsh-modpack-kit", order: 45, label: () => "整合包" }, Comp: () => h(Page, { surface: "settings" }) },
3789
- { 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" }) },
3790
5217
  ],
3791
5218
  pluginsTab: () => [
3792
- { 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" }) },
3793
5220
  ],
3794
5221
  sidebar: () => [
3795
- { 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 },
3796
5223
  { slot: "main", spec: { name: "main", key: "dsh-modpack-kit" }, Comp: () => h(Page, { surface: "sidebar" }) },
3797
5224
  ],
3798
5225
  }
@@ -3860,12 +5287,24 @@ window.__ModuleLoader__.load({
3860
5287
  exports.MarketPanel = MarketPanel
3861
5288
  // 自测用:社区资源那层「切页签也保留」的状态存在模块里,测试要能塞一份进去看恢复得对不对
3862
5289
  exports.__marketUi = marketUi
5290
+ // 自测用:页签状态也是模块级的,dev/tools/ui-preview.mjs 与测试要能直接把初始页签摆好再渲染
5291
+ exports.__setPageTab = (tab) => { pageUi.tab = tab }
3863
5292
  exports.PluginBrowser = PluginBrowser
5293
+ exports.PluginManagerPanel = PluginManagerPanel
5294
+ exports.SubpluginList = SubpluginList
5295
+ exports.PluginTreeOverlay = PluginTreeOverlay
3864
5296
  exports.ModpackBrowser = ModpackBrowser
3865
5297
  exports.inject = inject
3866
5298
  exports.Page = Page
3867
5299
  exports.Home = Home
5300
+ exports.SettingsPanel = SettingsPanel
3868
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 // 只给预览与自检用:按同一份数据摆一遍,截图核对布局 // 同理:预览器要能按经典模式出图,否则看到的还是「主题色」
3869
5308
 
3870
5309
  return module.exports
3871
5310
  },