dsh-modpack-kit 0.1.9 → 0.2.0-1

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
@@ -33,7 +33,13 @@ window.__ModuleLoader__.load({
33
33
  const chipOn = { ...chipBtn, color: "var(--dsw-alias-label-primary)", borderColor: "var(--dsw-alias-fill-primary, #3b6cf6)" }
34
34
 
35
35
  const LEVEL_COLOR = { high: "#ff6b6b", error: "#ff6b6b", medium: "#ffb020", warn: "#ffb020", low: "#8a8f98", info: "#8a8f98" }
36
- const FORMAT_TEXT = { full: "完整版(含插件本体)", lite: "轻量版(联网取包)" }
36
+ const FORMAT_TEXT = { full: "完整版(含插件本体)", lite: "轻量版(联网取包)", hybrid: "混合包(联网取包 + 配置)" }
37
+ // 三种打包策略的介绍:服务端 /pack/plan 会给可用性与不可用原因,这里只做兜底展示
38
+ const STRATEGY_INFO = [
39
+ { id: "full", title: "完整包(懒人包)", online: false, note: "插件本体一起装进包,不联网也能装。有网时按市场版本装,装完依赖是 ^版本,插件市场认成市场版;离线才退回包内副本(显示本地安装)。可以带自定义配置与数据。" },
40
+ { id: "lite", title: "仅下载码(轻量包)", online: true, note: "只记 名字@版本,体积最小。安装时必须联网从市场取包,不带自定义配置与数据,插件市场按版本认成市场版。" },
41
+ { id: "hybrid", title: "混合包(轻量为主 + 必要的完整)", online: true, note: "能按版本装的就只记 名字@版本(安装时联网取包);没有确定版本、或者要带走本机改动的插件,连本体一起打进来(这部分安装时不用联网)。配置/数据/补丁片段照样带。" },
42
+ ]
37
43
  // 分类以插件市场为准:id 与市场目录一致,中文名由 host 从市场目录里带回来。
38
44
  const CATEGORY_LABELS = { all: "全部", other: "其它" }
39
45
  const categoryOf = (entry) => (entry && entry.category) || "other"
@@ -261,31 +267,47 @@ window.__ModuleLoader__.load({
261
267
 
262
268
  const ORIGIN_LABEL = { local: "本机", market: "市场", config: "配置", data: "数据", pack: "整合包" }
263
269
 
270
+ // 一整块可以折叠的区域:标题行常驻,点标题或「展开/收起」都行。
271
+ // 默认收起,只有真有问题(高危 / 阻断)才默认摊开。
272
+ function FoldBox(props) {
273
+ const [open, setOpen] = useState(props.defaultOpen === true)
274
+ const summary = Array.isArray(props.summary) ? props.summary : [props.summary]
275
+ // 标题行上的操作(比如「清空」):点它不该顺带把整块展开/收起
276
+ const actions = Array.isArray(props.actions) ? props.actions.filter(Boolean) : []
277
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: "8px", border: "0.5px solid var(--dsw-alias-border-l2)", borderRadius: "8px", padding: "8px 10px" } },
278
+ h("div", { style: { ...row, cursor: "pointer" }, onClick: () => setOpen((prev) => !prev) },
279
+ h("div", { style: strong }, props.title),
280
+ ...summary.filter(Boolean),
281
+ actions.length
282
+ ? h("span", { style: { display: "flex", gap: "6px", alignItems: "center", marginLeft: "auto" }, onClick: (event) => event.stopPropagation() }, ...actions,
283
+ h("span", { style: { ...chipBtn, marginLeft: "6px" } }, open ? "收起" : "展开"))
284
+ : h("span", { style: { ...chipBtn, marginLeft: "auto" } }, open ? "收起" : (props.hint || "展开"))),
285
+ open ? props.children : (props.collapsedNote ? h("div", { style: hint }, props.collapsedNote) : null))
286
+ }
287
+
264
288
  function ScanReport(props) {
265
289
  const scan = props.scan
266
290
  const counts = (scan && scan.counts) || { high: 0, medium: 0, low: 0 }
267
291
  const findings = scan && Array.isArray(scan.findings) ? scan.findings : []
268
- const [open, setOpen] = useState(counts.high > 0)
269
292
  const [openGroup, setOpenGroup] = useState({})
270
293
  if (!scan) return null
271
294
  const groups = Array.isArray(props.groups) && props.groups.length
272
295
  ? props.groups
273
296
  : (findings.length ? [{ key: "all", label: "全部命中", origin: "", counts, findings }] : [])
274
297
  const toggleGroup = (key) => setOpenGroup((prev) => ({ ...prev, [key]: !prev[key] }))
275
- const toggleOpen = () => setOpen((prev) => !prev)
276
- return h("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
277
- h("div", { style: row },
278
- h("div", { style: strong }, "安全检测"),
279
- h(Tag, { color: counts.high ? "#ff6b6b" : counts.medium ? "#ffb020" : "#2bb673" },
280
- "高 " + counts.high + " · 中 " + counts.medium + " · 低 " + counts.low),
281
- h("span", { style: hint }, "扫描 " + (scan.scannedFiles || 0) + " 个文件 / " + bytes(scan.scannedBytes || 0) + (scan.note ? " · " + scan.note : "")),
282
- findings.length
283
- ? h("button", { style: { ...chipBtn, marginLeft: "auto" }, onClick: toggleOpen },
284
- open ? "收起风险列表(" + findings.length + " 条)" : "展开风险列表(" + findings.length + " 条)")
285
- : null),
286
- findings.length === 0 ? h("div", { style: hint }, "没有命中敏感信息或可疑代码规则。") : null,
287
- open && findings.length
288
- ? h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
298
+ return h(FoldBox, {
299
+ title: "安全检测",
300
+ defaultOpen: counts.high > 0,
301
+ summary: [
302
+ h(Tag, { color: counts.high ? "#ff6b6b" : counts.medium ? "#ffb020" : "#2bb673" }, "高 " + counts.high + " · 中 " + counts.medium + " · 低 " + counts.low),
303
+ h("span", { style: hint }, "扫了 " + (scan.scannedFiles || 0) + " 个文件"),
304
+ ],
305
+ hint: findings.length ? "展开(" + findings.length + " 条)" : "没有命中",
306
+ collapsedNote: findings.length ? "共 " + findings.length + " 条命中,点标题展开看位置与掩码。" : "",
307
+ },
308
+ findings.length === 0
309
+ ? h("div", { style: hint }, "没有命中敏感信息或可疑代码规则。")
310
+ : h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
289
311
  groups.map((group) => {
290
312
  const expanded = openGroup[group.key] === true
291
313
  return h("div", { key: group.key, style: { border: "0.5px solid var(--dsw-alias-border-l2)", borderRadius: "6px", overflow: "hidden" } },
@@ -302,8 +324,7 @@ window.__ModuleLoader__.load({
302
324
  group.findings.map((f, i) => h("div", { key: i, style: { ...mono, color: LEVEL_COLOR[f.severity] || "inherit" } },
303
325
  "[" + String(f.severity || "").toUpperCase() + "] " + (f.label || f.rule) + " · " + f.file + (f.line ? ":" + f.line : "") + " · " + (f.masked || ""))))
304
326
  : null)
305
- }))
306
- : null,
327
+ })),
307
328
  h("div", { style: hint }, props.footNote || "命中内容只在内存里比对,报告只保留类型、位置与掩码,原文不落盘。"))
308
329
  }
309
330
 
@@ -311,13 +332,18 @@ window.__ModuleLoader__.load({
311
332
  const compat = props.compat
312
333
  if (!compat) return null
313
334
  const findings = compat.findings || []
314
- if (findings.length === 0) return h("div", { style: hint }, "兼容性:没有发现问题。")
315
- return h("div", { style: { display: "flex", flexDirection: "column", gap: "5px" } },
316
- h("div", { style: row }, h("div", { style: strong }, "兼容性"), h("span", { style: hint }, compat.summary || ""),
317
- compat.blocking ? h(Tag, { color: "#ff6b6b" }, "有阻断项") : null),
318
- findings.map((f, i) => h("div", { key: i, style: { borderLeft: "2px solid " + (LEVEL_COLOR[f.level] || "transparent"), paddingLeft: "8px" } },
319
- h("div", { style: { ...label, color: LEVEL_COLOR[f.level] || "inherit" } }, (f.plugin ? f.plugin + ":" : "") + f.message),
320
- f.suggestion ? h("div", { style: hint }, "建议:" + f.suggestion) : null)))
335
+ return h(FoldBox, {
336
+ title: "兼容性",
337
+ defaultOpen: compat.blocking === true || findings.some((f) => f.level === "error"),
338
+ summary: h("span", { style: hint }, findings.length ? (compat.summary || "") : "没有发现问题"),
339
+ hint: findings.length ? "展开(" + findings.length + " 条)" : "没有发现",
340
+ collapsedNote: findings.length ? "有 " + findings.length + " 条问题或提醒,点标题展开看建议。" : "",
341
+ },
342
+ findings.length === 0
343
+ ? h("div", { style: hint }, "兼容性:没有发现问题。")
344
+ : findings.map((f, i) => h("div", { key: i, style: { borderLeft: "2px solid " + (LEVEL_COLOR[f.level] || "transparent"), paddingLeft: "8px" } },
345
+ h("div", { style: { ...label, color: LEVEL_COLOR[f.level] || "inherit" } }, (f.plugin ? f.plugin + ":" : "") + f.message),
346
+ f.suggestion ? h("div", { style: hint }, "建议:" + f.suggestion) : null)))
321
347
  }
322
348
 
323
349
  const JOB_KIND_LABEL = { pack: "打包", install: "安装" }
@@ -612,7 +638,7 @@ window.__ModuleLoader__.load({
612
638
  const [searching, setSearching] = useState(false)
613
639
  const [syncing, setSyncing] = useState("")
614
640
  const [options, setOptions] = useState(() => (draft.options ? { ...draft.options } : {
615
- includePayload: true,
641
+ strategy: "full",
616
642
  includeConfig: true,
617
643
  scanBeforePack: true,
618
644
  confirmLicense: false,
@@ -620,6 +646,38 @@ window.__ModuleLoader__.load({
620
646
  description: "",
621
647
  author: "",
622
648
  }))
649
+ // 三种策略的可选性随所选插件变化(比如只在本机、没有 semver 版本的插件选不了轻量包)
650
+ const [plan, setPlan] = useState(null)
651
+ const [planError, setPlanError] = useState("")
652
+ useEffect(() => {
653
+ const names = Object.keys(selected)
654
+ setPlanError("")
655
+ if (names.length === 0) { setPlan(null); return undefined }
656
+ let alive = true
657
+ api("/pack/plan", { selection: names.map((name) => selected[name]) })
658
+ .then((data) => {
659
+ if (!alive) return
660
+ if (data && data.ok && Array.isArray(data.strategies)) setPlan(data.strategies)
661
+ else { setPlan(null); setPlanError((data && data.error) || "服务端没给出判定") }
662
+ })
663
+ .catch((error) => {
664
+ if (!alive) return
665
+ setPlan(null)
666
+ setPlanError((error && error.message) || String(error))
667
+ })
668
+ return () => { alive = false }
669
+ }, [selected])
670
+ const planEntries = Array.isArray(plan) ? plan : []
671
+ const strategyLabel = (id) => {
672
+ const found = (planEntries.length ? planEntries : STRATEGY_INFO).find((entry) => entry.id === id)
673
+ return found ? found.title : id
674
+ }
675
+ // 先选了一个策略、之后又勾了让它不可用的插件:这里提示并挡住打包,而不是悄悄替你换
676
+ const currentBlocked = (() => {
677
+ if (!planEntries.length) return null
678
+ const found = planEntries.find((entry) => entry.id === options.strategy)
679
+ return found && found.ok === false ? found : null
680
+ })()
623
681
  // 草稿只活在内存里:切页签不丢,刷新/重启 DSH 回到默认
624
682
  useEffect(() => { setPackDraft({ selected }) }, [selected])
625
683
  useEffect(() => { setPackDraft({ options }) }, [options])
@@ -832,12 +890,10 @@ window.__ModuleLoader__.load({
832
890
  h("div", { style: hint }, (entry.description || "").slice(0, 110))),
833
891
  h("span", { style: { ...chip, color: "var(--dsw-alias-label-tertiary)" } }, labelOf(categoryOf(entry))),
834
892
  entry.updateAvailable ? h(Tag, { color: "#2bb673" }, "市场版 " + (entry.marketVersion || entry.version) + " 更新") : null,
835
- on ? h("input", {
836
- style: { ...input, width: "120px" },
837
- placeholder: selected[entry.name].source === "npm" ? "版本,空=最新(从市场取包)" : "版本,空=本机版本",
838
- value: selected[entry.name].spec || "",
839
- onChange: (e) => setSpec(entry.name, e.target.value),
840
- }) : null,
893
+ on ? h("span", { style: { ...chip, color: "var(--dsw-alias-label-secondary)", fontWeight: 600 } },
894
+ "版本 " + (selected[entry.name].source === "npm"
895
+ ? (entry.marketVersion || (selected[entry.name].spec || "").replace(/^[^@]+@/u, "") || entry.version || "最新")
896
+ : (entry.version || "本机"))) : null,
841
897
  on ? h("div", { style: { display: "flex", gap: "4px" } },
842
898
  h("button", { style: selected[entry.name].choice !== "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "preset"), title: "只打插件默认配置:不带本机的配置与数据快照(代码按所选来源)" }, "插件预设"),
843
899
  h("button", { style: selected[entry.name].choice === "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "custom"), title: "带上本机这份插件的配置与数据快照;本机来源的连代码改动一起打" }, "自定义配置")) : null,
@@ -931,7 +987,7 @@ window.__ModuleLoader__.load({
931
987
  async: true,
932
988
  selection: picked.map((name) => selected[name]),
933
989
  options: {
934
- includePayload: options.includePayload,
990
+ strategy: options.strategy,
935
991
  includeConfig: options.includeConfig,
936
992
  acknowledge: ack === true,
937
993
  force: false,
@@ -1011,10 +1067,25 @@ window.__ModuleLoader__.load({
1011
1067
  } finally { setBusy("") }
1012
1068
  }
1013
1069
 
1070
+ const strategyNotice = currentBlocked
1071
+ ? h(Notice, { tone: "warn" },
1072
+ h("b", null, "当前选的「" + strategyLabel(options.strategy) + "」现在不适用:"),
1073
+ currentBlocked.reason || "",
1074
+ h("div", { style: { ...row, marginTop: "6px" } },
1075
+ ...planEntries
1076
+ .filter((entry) => entry.ok !== false && entry.id !== options.strategy)
1077
+ .map((entry) => h("button", {
1078
+ key: entry.id,
1079
+ type: "button",
1080
+ style: chipBtn,
1081
+ onClick: () => setOptions({ ...options, strategy: entry.id }),
1082
+ }, "换成" + entry.title)),
1083
+ ))
1084
+ : null
1014
1085
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "14px" } },
1015
1086
  h(Notice, null,
1016
1087
  h("b", null, "打包:将所选插件封装为一个 .dshpack 文件"),
1017
- " 完整版包含插件本体的全部文件;轻量版仅记录插件名称与版本,安装时按版本从插件市场下载。两种包在安装前均不修改 profile 内容。",
1088
+ " 三种策略:完整包自带插件本体、不联网也能装;仅下载码只记版本、体积最小;混合包带版本与配置片段、体积接近仅下载码。完整包与混合包在安装前均不允许修改 profile 内容。",
1018
1089
  status && status.market && status.market.installed
1019
1090
  ? h("div", { style: { ...hint, marginTop: "6px" } }, "已检测到插件市场 v" + status.market.version + ":本插件与其共用目录源与安装链路,但不依赖该插件,移除后打包与安装功能不受影响。")
1020
1091
  : h("div", { style: { ...hint, marginTop: "6px" } }, "未检测到插件市场,功能不受影响:打包、安装与检测均在本地完成。建议先安装 dshmarket 以获得分类、搜索与「切换市场版」入口;未安装时,首次使用请点击「建立目录索引」。"),
@@ -1054,10 +1125,48 @@ window.__ModuleLoader__.load({
1054
1125
  : "首屏只列本机已装。插件自带的内部组件(随父包一起装的那种)不单独列出" + (props.status && props.status.installedHidden ? "(本次隐藏 " + props.status.installedHidden + " 个)" : "") + "。每行最前面标出当前来源:市场版按上游版本取包,本机版取本机这份。勾选时默认「插件预设」——只打插件默认配置;要带上本机的配置条目与数据快照就改成「自定义配置」(本机版还会连代码改动一起打)。本机已装且市场里有同名条目的,默认按市场版勾选;要打本机这份就点行末「改为本机版」。搜索或点分类才去插件市场目录里查,服务端分页、一次一页。搜索结果里没装的插件也能直接勾选——打包时按版本从插件市场取包,装的时候同样从市场下载。")
1055
1126
  ),
1056
1127
  h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
1057
- h("div", { style: strong }, "包选项"),
1058
- h("div", { style: { ...row, rowGap: "6px" } },
1059
- h(Switch, { checked: options.includePayload, label: "包含插件本体(关=轻量版)", onChange: (v) => setOptions({ ...options, includePayload: v }) }),
1060
- h(ForcedSwitch, { label: "打包前安全检测(强制)", onNag: () => firePackNag("你想干什么") })),
1128
+ h("div", { style: strong }, "打包策略(必选)"),
1129
+ h("div", { style: hint }, "三选一,可不可选按你勾的插件实时判定:灰掉的那张整块变灰,点一下会弹出原因。安全检测在服务端强制进行,不提供关闭;版本号不能手改,只显示所选来源的版本。"),
1130
+ h("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" } },
1131
+ (planEntries.length ? planEntries : STRATEGY_INFO.map((item) => ({ ...item, ok: true }))).map((item) => {
1132
+ const disabled = item.ok === false
1133
+ const chosen = options.strategy === item.id
1134
+ const muted = disabled ? "var(--dsw-alias-label-tertiary, #8b8f99)" : "var(--dsw-alias-label-secondary)"
1135
+ return h("div", {
1136
+ key: item.id,
1137
+ role: "button",
1138
+ tabIndex: 0,
1139
+ "aria-disabled": disabled ? "true" : "false",
1140
+ style: {
1141
+ flex: "1 1 210px", minWidth: "190px", padding: "9px 10px", borderRadius: "8px",
1142
+ cursor: disabled ? "not-allowed" : "pointer",
1143
+ border: "1px solid " + (chosen && !disabled ? "#4C7DF0" : "var(--dsw-alias-border-l2)"),
1144
+ borderStyle: disabled ? "dashed" : "solid",
1145
+ background: chosen && !disabled ? "rgba(76,125,240,0.08)" : "transparent",
1146
+ opacity: disabled ? 0.7 : 1,
1147
+ },
1148
+ onClick: () => {
1149
+ if (disabled) { firePackNag(item.reason || "这个策略现在不能选"); return }
1150
+ setOptions({ ...options, strategy: item.id })
1151
+ },
1152
+ onKeyDown: (event) => {
1153
+ if (event.key !== "Enter" && event.key !== " ") return
1154
+ event.preventDefault()
1155
+ if (disabled) { firePackNag(item.reason || "这个策略现在不能选"); return }
1156
+ setOptions({ ...options, strategy: item.id })
1157
+ },
1158
+ title: disabled ? (item.reason || "") : (item.online ? "安装时需要联网" : "不联网也能装"),
1159
+ },
1160
+ h("div", { style: { display: "flex", gap: "6px", alignItems: "baseline", color: disabled ? muted : "var(--dsw-alias-label-primary)" } },
1161
+ h("span", { style: { fontWeight: 600 } }, item.title),
1162
+ h("span", { style: { fontSize: "11px", color: muted } }, item.online ? "需联网" : "不联网"),
1163
+ disabled ? h("span", { style: { ...chip, marginLeft: "auto", color: muted, cursor: "pointer" } }, "不可选") : null),
1164
+ h("div", { style: { marginTop: "4px", lineHeight: 1.45, fontSize: "12px", color: muted } },
1165
+ disabled ? (item.reason || "这个策略现在不能选") : (item.note || "")))
1166
+ })),
1167
+ strategyNotice,
1168
+ planEntries.length === 0 && picked.length > 0 ? h("div", { style: hint }, "正在判定…") : null,
1169
+ planError ? h("div", { style: hint }, "策略判定失败(打包时会再判一次):" + planError) : null,
1061
1170
  h(NagText, { text: packNag }),
1062
1171
  h("div", { style: { ...row, rowGap: "6px" } },
1063
1172
  h("input", { style: { ...input, flex: "1 1 200px" }, placeholder: "整合包名", value: options.name, onChange: (e) => setOptions({ ...options, name: e.target.value }) }),
@@ -1065,7 +1174,7 @@ window.__ModuleLoader__.load({
1065
1174
  h("input", { style: { ...input, width: "100%" }, placeholder: "一句话描述(可空)", value: options.description, onChange: (e) => setOptions({ ...options, description: e.target.value }) }),
1066
1175
  h(Switch, { checked: options.confirmLicense, label: "我确认所选插件的许可证允许再分发,或已获得作者授权", onChange: (v) => setOptions({ ...options, confirmLicense: v }) }),
1067
1176
  h("div", { style: row },
1068
- h("button", { style: btnPrimary, disabled: picked.length === 0 || busy === "start", onClick: doPack }, busy === "start" ? "提交中…" : ("打包 " + picked.length + " 个插件")),
1177
+ h("button", { style: btnPrimary, disabled: picked.length === 0 || busy === "start" || Boolean(currentBlocked), onClick: doPack }, busy === "start" ? "提交中…" : (currentBlocked ? "先换个可用的策略" : ("打包 " + picked.length + " 个插件"))),
1069
1178
  started ? h("span", { style: hint }, "已开始:" + started + "(进度在左下角,可以接着选别的再打一个)") : null,
1070
1179
  status ? h("span", { style: hint }, "DSH " + (status.dshVersion || "?") + " · profile " + status.profile) : null)),
1071
1180
  pausedRiskNodes.length ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px", borderColor: "#d9534f" } }, pausedRiskNodes) : null,
@@ -1115,6 +1224,9 @@ window.__ModuleLoader__.load({
1115
1224
  // 安装也走任务队列:进度直接显示在左下角那个窗里,这里留一份给页面内看
1116
1225
  const [progress, setProgress] = useState(null)
1117
1226
  const [deferred, setDeferred] = useState([])
1227
+ // 预览里逐个插件勾选要不要装、以及每个插件「包内配置 / 保持本机」
1228
+ const [pickedNames, setPickedNames] = useState({})
1229
+ const [configChoice, setConfigChoice] = useState({})
1118
1230
  const [askReplace, setAskReplace] = useState(false)
1119
1231
  const [imports, setImportsState] = useState(readImports())
1120
1232
 
@@ -1230,10 +1342,14 @@ window.__ModuleLoader__.load({
1230
1342
  const install = async () => {
1231
1343
  setBusy("install"); setError(""); setDone(null); setDeferred([]); setAskReplace(false); setProgress(null)
1232
1344
  try {
1233
- const data = await api("/install", { ...bodyFor(), ...options, async: true })
1345
+ const allNames = (preview && preview.manifest && preview.manifest.plugins ? preview.manifest.plugins : []).map((p) => p.name)
1346
+ const keepNames = allNames.filter((name) => pickedNames[name] !== false)
1347
+ const only = keepNames.length === allNames.length || keepNames.length === 0 ? undefined : keepNames
1348
+ const installOptions = { ...options, ...(only ? { only } : {}), configChoice, syncGroups: options.syncGroups !== false, ...(options.offline === true ? { offline: true } : {}) }
1349
+ const data = await api("/install", { ...bodyFor(), ...installOptions, async: true })
1234
1350
  if (!data || data.ok !== true || !data.job) {
1235
1351
  // 老宿主不认 async:退回同步调用
1236
- const plain = await api("/install", { ...bodyFor(), ...options })
1352
+ const plain = await api("/install", { ...bodyFor(), ...installOptions })
1237
1353
  if (!plain.ok) {
1238
1354
  setDone({ ok: false, error: plain.error, refused: plain.refused, scan: plain.scan, report: plain.report })
1239
1355
  return
@@ -1282,6 +1398,12 @@ window.__ModuleLoader__.load({
1282
1398
  } finally { setBusy(""); setProgress(null) }
1283
1399
  }
1284
1400
 
1401
+ const previewFindings = preview && preview.compat && Array.isArray(preview.compat.findings) ? preview.compat.findings : []
1402
+ const previewProblems = previewFindings.filter((f) => f.level !== "info")
1403
+ const previewRows = preview && preview.manifest && Array.isArray(preview.manifest.plugins)
1404
+ ? preview.manifest.plugins.map((plugin) => ({ plugin, problems: previewProblems.filter((f) => f.plugin === plugin.name) }))
1405
+ .sort((a, b) => (b.problems.length > 0 ? 1 : 0) - (a.problems.length > 0 ? 1 : 0))
1406
+ : []
1285
1407
  return h("div", { style: { display: "flex", flexDirection: "column", gap: "14px" } },
1286
1408
  h(Notice, null,
1287
1409
  h("b", null, "先看清楚,再装"),
@@ -1374,7 +1496,9 @@ window.__ModuleLoader__.load({
1374
1496
  h(Switch, { checked: options.keepLocal, label: "保留本地已有修改(不覆盖已装插件)", onChange: (v) => setOptions({ ...options, keepLocal: v }) }),
1375
1497
  h(Switch, { checked: options.applyConfig, label: "安装后回填包内配置", onChange: (v) => setOptions({ ...options, applyConfig: v }) }),
1376
1498
  h(Switch, { checked: options.preferMarket, label: "联网时优先用插件市场的版本(市场查不到就用包内的)", onChange: (v) => setOptions({ ...options, preferMarket: v }) }),
1377
- h(Switch, { checked: options.enableBundles, label: "安装后直接启用(登记 bundle,重启后加载;默认关)", onChange: (v) => setOptions({ ...options, enableBundles: v }) }),
1499
+ h(Switch, { checked: options.enableBundles, label: "安装后整体启用(全部登记 bundle,重启后加载)", onChange: (v) => setOptions({ ...options, enableBundles: v }) }),
1500
+ h(Switch, { checked: options.syncGroups !== false, label: "安装后同步插件市场分组(包内组名并进同名组)", onChange: (v) => setOptions({ ...options, syncGroups: v }) }),
1501
+ h(Switch, { checked: options.offline === true, label: "离线安装(不联网,直接用包里自带的)", onChange: (v) => setOptions({ ...options, offline: v ? true : undefined }) }),
1378
1502
  h(Switch, { checked: options.force, label: "忽略阻断(我知道自己在干什么)", onChange: (v) => setOptions({ ...options, force: v }) })),
1379
1503
  h("div", { style: row },
1380
1504
  h("button", { style: btnPrimary, disabled: busy !== "" || (source.kind === "url" ? !source.url.trim() : !source.file), onClick: inspect }, busy === "inspect" ? "检测中…" : "检测这个包"),
@@ -1398,9 +1522,22 @@ window.__ModuleLoader__.load({
1398
1522
  preview.blockingReasons && preview.blockingReasons.length
1399
1523
  ? h(Notice, { tone: "bad" }, h("b", null, "阻断:" ), preview.blockingReasons.join(";"), " (真要装,勾上面的「忽略阻断」)")
1400
1524
  : null,
1401
- h("div", { style: { display: "flex", flexDirection: "column", gap: "2px" } },
1402
- preview.manifest.plugins.map((p) => h("div", { key: p.name, style: mono },
1403
- "· " + p.name + "@" + p.version + (p.localEdits ? " [含本机修改]" : "") + (p.configIncluded ? " [有配置]" : "") + (p.dataIncluded ? " [有数据快照]" : "")))),
1525
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "4px", maxHeight: "280px", overflow: "auto" } },
1526
+ previewProblems.length ? h("div", { style: { ...hint, color: "#ffb020" } }, "有 " + previewProblems.length + " 条问题/提醒,相关插件已排在最前面") : null,
1527
+ previewRows.map((row) => {
1528
+ const p = row.plugin
1529
+ const checked = pickedNames[p.name] !== false
1530
+ 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)" } },
1531
+ h("input", { type: "checkbox", checked, onChange: () => setPickedNames((prev) => ({ ...prev, [p.name]: !checked })) }),
1532
+ h("div", { style: { flex: "1 1 220px", minWidth: "170px" } },
1533
+ h("div", { style: label }, p.name, " ", h("span", { style: hint }, "@" + (p.version || "?"))),
1534
+ h("div", { style: hint }, [p.localEdits ? "含本机修改" : "", p.configIncluded ? "有配置" : "", p.dataIncluded ? "有数据快照" : ""].filter(Boolean).join(" · ")),
1535
+ row.problems.length ? h("div", { style: { ...hint, color: row.problems.some((f) => f.level === "error") ? "#ff6b6b" : "#ffb020" } },
1536
+ row.problems.slice(0, 3).map((f) => "· " + f.message).join(";") + (row.problems.length > 3 ? "(还有 " + (row.problems.length - 3) + " 条)" : "")) : null),
1537
+ p.configIncluded ? h("div", { style: { display: "flex", gap: "4px" } },
1538
+ h("button", { style: (configChoice[p.name] || "pack") === "pack" ? chipOn : chipBtn, onClick: () => setConfigChoice((prev) => ({ ...prev, [p.name]: "pack" })), title: "用包里的配置条目覆盖/补上" }, "包内配置"),
1539
+ h("button", { style: configChoice[p.name] === "local" ? chipOn : chipBtn, onClick: () => setConfigChoice((prev) => ({ ...prev, [p.name]: "local" })), title: "保留本机这份配置,不用包里的" }, "保持本机")) : null)
1540
+ })),
1404
1541
  h(ScanReport, { scan: preview.scan, groups: preview.scanGroups }),
1405
1542
  h(CompatList, { compat: preview.compat }),
1406
1543
  preview.notes && preview.notes.length ? h("div", { style: hint }, preview.notes.map((n, i) => h("div", { key: i }, "· " + n))) : null,
@@ -1464,7 +1601,25 @@ window.__ModuleLoader__.load({
1464
1601
  const [saved, setSaved] = useState("")
1465
1602
  const [busy, setBusy] = useState(false)
1466
1603
  const [scanNag, fireScanNag] = useNag()
1467
- const history = (props.status && props.status.history) || []
1604
+ // 记录用本地状态:删一条不用整页重读,删完立刻看到结果
1605
+ const [history, setHistory] = useState((((props.status || {}).history) || []).slice())
1606
+ const [historyMsg, setHistoryMsg] = useState("")
1607
+ const dropHistory = async (item, all) => {
1608
+ setHistoryMsg("")
1609
+ try {
1610
+ const data = all
1611
+ ? await api("/history/clear", {})
1612
+ : await api("/history/remove", { at: item && item.at })
1613
+ if (data && data.ok) {
1614
+ setHistory(Array.isArray(data.items) ? data.items.slice(-12).reverse() : [])
1615
+ setHistoryMsg(all ? "已清空最近记录" : "已删掉这一条")
1616
+ } else {
1617
+ setHistoryMsg((data && data.error) || "没删成")
1618
+ }
1619
+ } catch (e) {
1620
+ setHistoryMsg((e && e.message) || String(e))
1621
+ }
1622
+ }
1468
1623
 
1469
1624
  const patch = async (p) => {
1470
1625
  setBusy(true); setSaved("")
@@ -1546,7 +1701,7 @@ window.__ModuleLoader__.load({
1546
1701
  const bytes = Math.min(4096, Math.max(16, mb)) * 1048576
1547
1702
  if (bytes !== mb * 1048576) setSaved("已按范围收到 16~4096 MB")
1548
1703
  setField("maxPackBytes", bytes)
1549
- patch({ maxPackBytes: bytes, maxDownloadBytes: cfg.maxDownloadBytes, maxFileBytes: cfg.maxFileBytes, netTimeoutSeconds: cfg.netTimeoutSeconds, netRetries: cfg.netRetries, curlFallback: cfg.curlFallback !== false, licenseAllow: cfg.licenseAllow, registries: cfg.registries, allowHosts: cfg.allowHosts })
1704
+ patch({ maxPackBytes: bytes, maxDownloadBytes: cfg.maxDownloadBytes, maxFileBytes: cfg.maxFileBytes, maxMetadataBytes: cfg.maxMetadataBytes, netTimeoutSeconds: cfg.netTimeoutSeconds, netRetries: cfg.netRetries, curlFallback: cfg.curlFallback !== false, licenseAllow: cfg.licenseAllow, registries: cfg.registries, allowHosts: cfg.allowHosts })
1550
1705
  },
1551
1706
  }, "保存数值"),
1552
1707
  h("span", { style: hint }, "默认 256 MB,可填 16~4096"),
@@ -1556,12 +1711,14 @@ window.__ModuleLoader__.load({
1556
1711
  h("input", { style: { ...input, width: "70px" }, type: "number", min: "5", max: "120", value: String(cfg.netTimeoutSeconds || 20), onChange: (e) => setField("netTimeoutSeconds", Number(e.target.value)) }),
1557
1712
  h("span", { style: label }, "重试"),
1558
1713
  h("input", { style: { ...input, width: "56px" }, type: "number", min: "0", max: "5", value: String(cfg.netRetries || 0), onChange: (e) => setField("netRetries", Number(e.target.value)) }),
1714
+ h("span", { style: label }, "版本清单上限(MB)"),
1715
+ h("input", { style: { ...input, width: "70px" }, type: "number", min: "4", max: "512", value: String(cfg.maxMetadataBytes || 64), onChange: (e) => setField("maxMetadataBytes", Number(e.target.value)) }),
1559
1716
  h(Switch, {
1560
1717
  checked: cfg.curlFallback !== false,
1561
1718
  label: "fetch 失败时用系统 curl 兜底",
1562
1719
  onChange: (v) => { setField("curlFallback", v); patch({ curlFallback: v }) },
1563
1720
  })),
1564
- h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl 兜底(走系统证书库)。保存后立即生效。"),
1721
+ h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl 兜底(走系统证书库)。提示「下载超过上限」时是版本清单太大(billion-context 这类包的清单十几 MB):把「版本清单上限」调大,或改用确定的版本号(插件会直接取单版本清单,体积最小)。保存后立即生效。"),
1565
1722
  h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
1566
1723
  h("div", { style: strong }, "信任清单"),
1567
1724
  h("div", { style: hint }, "允许的许可证(一行一个,例如 MIT):"),
@@ -1578,10 +1735,36 @@ window.__ModuleLoader__.load({
1578
1735
  h("div", { style: mono }, "整合包:" + ((props.status && props.status.paths && props.status.paths.packs) || "?")),
1579
1736
  h("div", { style: mono }, "缓存与暂存:" + ((props.status && props.status.paths && props.status.paths.vendor) || "?")),
1580
1737
  h("div", { style: mono }, "卸载临时文件:删掉 vendor 目录即可,装好的插件不受影响。")),
1581
- h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "6px" } },
1582
- h("div", { style: strong }, "最近记录"),
1583
- history.length === 0 ? h("div", { style: hint }, "还没有记录。") : history.map((item, i) => h("div", { key: i, style: { ...mono, borderTop: "0.5px solid var(--dsw-alias-border-l2)", paddingTop: "4px" } },
1584
- "[" + (item.kind || "?") + "] " + (item.name || item.pack || "") + " · " + when(item.at) + (item.size ? " · " + bytes(item.size) : "") + (item.ok === false ? " · 失败" : "")))),
1738
+ h(FoldBox, {
1739
+ title: "最近记录",
1740
+ defaultOpen: false,
1741
+ summary: h("span", { style: hint }, history.length ? "共 " + history.length + " 条" : "还没有记录"),
1742
+ actions: history.length
1743
+ ? [h("button", {
1744
+ type: "button",
1745
+ style: chipBtn,
1746
+ title: "清空全部最近记录(只删记录,不动插件与包)",
1747
+ onClick: () => dropHistory(null, true),
1748
+ }, "清空最近记录")]
1749
+ : [],
1750
+ hint: "展开(" + history.length + " 条)",
1751
+ collapsedNote: history.length ? "打包与安装的历史都记在这里,点开可以逐条删除。" : "",
1752
+ },
1753
+ history.length === 0
1754
+ ? h("div", { style: hint }, "还没有记录。")
1755
+ : h("div", { style: { display: "flex", flexDirection: "column", gap: "2px" } },
1756
+ 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" } },
1757
+ h("span", { style: { flex: "1 1 auto" } },
1758
+ "[" + (item.kind || "?") + "] " + (item.name || item.pack || "") + " · " + when(item.at) + (item.size ? " · " + bytes(item.size) : "") + (item.ok === false ? " · 失败" : "")),
1759
+ h("button", {
1760
+ type: "button",
1761
+ style: { ...chipBtn, flexShrink: 0 },
1762
+ title: "删掉这一条(只删记录,不动插件与包)",
1763
+ onClick: () => dropHistory(item, false),
1764
+ }, "删除"))),
1765
+ h("div", { style: row },
1766
+ h("button", { type: "button", style: btn, onClick: () => dropHistory(null, true) }, "清空记录"),
1767
+ historyMsg ? h("span", { style: hint }, historyMsg) : null))),
1585
1768
  h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
1586
1769
  h("div", { style: strong }, "显示位置"),
1587
1770
  h("div", { style: hint }, "三处互相独立,一点就生效,不用重启。关掉只是不挂载入口,功能与接口都还在。至少留一处:只剩一个时,那个开关会变灰、点不动。"),
@@ -1685,7 +1868,7 @@ window.__ModuleLoader__.load({
1685
1868
  h("div", { style: { maxWidth: "1020px", margin: "0 auto", display: "flex", flexDirection: "column", gap: "14px" } },
1686
1869
  h("div", { style: { display: "flex", alignItems: "baseline", gap: "10px", flexWrap: "wrap" } },
1687
1870
  h("h2", { style: { margin: 0, fontSize: "20px", fontWeight: 600 } }, "整合包"),
1688
- h("span", { style: hint }, "把多个插件打成一个 .dshpack:完整版自带本体,轻量版联网取包")),
1871
+ h("span", { style: hint }, ((status && status.config && status.config.tagline) || "谁说 dsh 不能整整合包呢?(你说这几个插件整一块不牛逼坏了)"))),
1689
1872
  h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)), envLine),
1690
1873
  panels,
1691
1874
  footNote,