dsh-modpack-kit 0.1.8 → 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/README.md +64 -8
- package/assets/install-stub.mjs +69 -14
- package/client.js +410 -98
- package/docs/DETAIL.md +72 -123
- package/index.js +160 -23
- package/lib/groups.mjs +133 -0
- package/lib/http.mjs +3 -0
- package/lib/install.mjs +105 -8
- package/lib/manifest.mjs +17 -4
- package/lib/net.mjs +4 -2
- package/lib/pack.mjs +55 -9
- package/lib/registry.mjs +88 -11
- package/lib/store.mjs +23 -0
- package/locale/en.json +2 -2
- package/locale/zh.json +1 -1
- package/package.json +10 -3
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"
|
|
@@ -133,9 +139,10 @@ window.__ModuleLoader__.load({
|
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
async function api(pathname, body) {
|
|
136
|
-
const init = body === undefined ? { headers: { Accept: "application/json" } } : {
|
|
142
|
+
const init = body === undefined ? { headers: { Accept: "application/json" }, credentials: "same-origin" } : {
|
|
137
143
|
method: "POST",
|
|
138
144
|
headers: { "Content-Type": "application/json" },
|
|
145
|
+
credentials: "same-origin",
|
|
139
146
|
body: JSON.stringify(body),
|
|
140
147
|
}
|
|
141
148
|
let res
|
|
@@ -260,31 +267,47 @@ window.__ModuleLoader__.load({
|
|
|
260
267
|
|
|
261
268
|
const ORIGIN_LABEL = { local: "本机", market: "市场", config: "配置", data: "数据", pack: "整合包" }
|
|
262
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
|
+
|
|
263
288
|
function ScanReport(props) {
|
|
264
289
|
const scan = props.scan
|
|
265
290
|
const counts = (scan && scan.counts) || { high: 0, medium: 0, low: 0 }
|
|
266
291
|
const findings = scan && Array.isArray(scan.findings) ? scan.findings : []
|
|
267
|
-
const [open, setOpen] = useState(counts.high > 0)
|
|
268
292
|
const [openGroup, setOpenGroup] = useState({})
|
|
269
293
|
if (!scan) return null
|
|
270
294
|
const groups = Array.isArray(props.groups) && props.groups.length
|
|
271
295
|
? props.groups
|
|
272
296
|
: (findings.length ? [{ key: "all", label: "全部命中", origin: "", counts, findings }] : [])
|
|
273
297
|
const toggleGroup = (key) => setOpenGroup((prev) => ({ ...prev, [key]: !prev[key] }))
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
h(Tag, { color: counts.high ? "#ff6b6b" : counts.medium ? "#ffb020" : "#2bb673" },
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
? 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" } },
|
|
288
311
|
groups.map((group) => {
|
|
289
312
|
const expanded = openGroup[group.key] === true
|
|
290
313
|
return h("div", { key: group.key, style: { border: "0.5px solid var(--dsw-alias-border-l2)", borderRadius: "6px", overflow: "hidden" } },
|
|
@@ -301,8 +324,7 @@ window.__ModuleLoader__.load({
|
|
|
301
324
|
group.findings.map((f, i) => h("div", { key: i, style: { ...mono, color: LEVEL_COLOR[f.severity] || "inherit" } },
|
|
302
325
|
"[" + String(f.severity || "").toUpperCase() + "] " + (f.label || f.rule) + " · " + f.file + (f.line ? ":" + f.line : "") + " · " + (f.masked || ""))))
|
|
303
326
|
: null)
|
|
304
|
-
}))
|
|
305
|
-
: null,
|
|
327
|
+
})),
|
|
306
328
|
h("div", { style: hint }, props.footNote || "命中内容只在内存里比对,报告只保留类型、位置与掩码,原文不落盘。"))
|
|
307
329
|
}
|
|
308
330
|
|
|
@@ -310,13 +332,18 @@ window.__ModuleLoader__.load({
|
|
|
310
332
|
const compat = props.compat
|
|
311
333
|
if (!compat) return null
|
|
312
334
|
const findings = compat.findings || []
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
findings.
|
|
318
|
-
|
|
319
|
-
|
|
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)))
|
|
320
347
|
}
|
|
321
348
|
|
|
322
349
|
const JOB_KIND_LABEL = { pack: "打包", install: "安装" }
|
|
@@ -611,7 +638,7 @@ window.__ModuleLoader__.load({
|
|
|
611
638
|
const [searching, setSearching] = useState(false)
|
|
612
639
|
const [syncing, setSyncing] = useState("")
|
|
613
640
|
const [options, setOptions] = useState(() => (draft.options ? { ...draft.options } : {
|
|
614
|
-
|
|
641
|
+
strategy: "full",
|
|
615
642
|
includeConfig: true,
|
|
616
643
|
scanBeforePack: true,
|
|
617
644
|
confirmLicense: false,
|
|
@@ -619,6 +646,38 @@ window.__ModuleLoader__.load({
|
|
|
619
646
|
description: "",
|
|
620
647
|
author: "",
|
|
621
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
|
+
})()
|
|
622
681
|
// 草稿只活在内存里:切页签不丢,刷新/重启 DSH 回到默认
|
|
623
682
|
useEffect(() => { setPackDraft({ selected }) }, [selected])
|
|
624
683
|
useEffect(() => { setPackDraft({ options }) }, [options])
|
|
@@ -776,12 +835,99 @@ window.__ModuleLoader__.load({
|
|
|
776
835
|
const addAllLocal = () => setSelected((prev) => {
|
|
777
836
|
const next = { ...prev }
|
|
778
837
|
for (const entry of localRows) {
|
|
779
|
-
if (!next[entry.name]) next[entry.name] = { name: entry.name, source: entrySource(entry), spec: entrySpec(entry), choice: "preset" }
|
|
838
|
+
if (!next[entry.name]) next[entry.name] = { name: entry.name, source: entrySource(entry), spec: entrySpec(entry), choice: "preset", group: section.name }
|
|
780
839
|
}
|
|
781
840
|
return next
|
|
782
841
|
})
|
|
783
842
|
const clearSelected = () => setSelected({})
|
|
784
843
|
|
|
844
|
+
const groupInfo = (props.status && Array.isArray(props.status.groups)) ? props.status.groups : []
|
|
845
|
+
const [folded, setFolded] = useState({})
|
|
846
|
+
const sections = useMemo(() => {
|
|
847
|
+
if (groupInfo.length === 0) return []
|
|
848
|
+
const byName = new Map(localRows.map((entry) => [entry.name, entry]))
|
|
849
|
+
const used = new Set()
|
|
850
|
+
const out = []
|
|
851
|
+
for (const group of groupInfo) {
|
|
852
|
+
const entries = (group.members || []).map((name) => byName.get(name)).filter(Boolean)
|
|
853
|
+
for (const entry of entries) used.add(entry.name)
|
|
854
|
+
if (entries.length === 0) continue
|
|
855
|
+
out.push({ key: "group:" + group.name, name: group.name, entries, missing: group.missing || [] })
|
|
856
|
+
}
|
|
857
|
+
const rest = localRows.filter((entry) => !used.has(entry.name))
|
|
858
|
+
if (rest.length > 0) out.push({ key: "group:__rest", name: "未分组", entries: rest, missing: [] })
|
|
859
|
+
return out
|
|
860
|
+
}, [localRows, groupInfo])
|
|
861
|
+
const addGroup = (section) => setSelected((prev) => {
|
|
862
|
+
const next = { ...prev }
|
|
863
|
+
for (const entry of section.entries) {
|
|
864
|
+
if (!next[entry.name]) next[entry.name] = { name: entry.name, source: entrySource(entry), spec: entrySpec(entry), choice: "preset" }
|
|
865
|
+
}
|
|
866
|
+
return next
|
|
867
|
+
})
|
|
868
|
+
const removeGroup = (section) => setSelected((prev) => {
|
|
869
|
+
const next = { ...prev }
|
|
870
|
+
for (const entry of section.entries) delete next[entry.name]
|
|
871
|
+
return next
|
|
872
|
+
})
|
|
873
|
+
const renderOne = (entry) => {
|
|
874
|
+
const on = Boolean(selected[entry.name])
|
|
875
|
+
const chosenSource = on ? selected[entry.name].source : (entry.installed === false ? "npm" : "profile")
|
|
876
|
+
const sourceText = on ? (chosenSource === "npm" ? "市场版" : "本机版") : (entry.installed === false ? "市场未装" : "已装")
|
|
877
|
+
const sourceStyle = on
|
|
878
|
+
? { ...chip, minWidth: "58px", textAlign: "center", fontWeight: 600, color: "var(--dsw-alias-label-primary)", borderColor: "var(--dsw-alias-border-l2)" }
|
|
879
|
+
: { ...chip, minWidth: "58px", textAlign: "center", color: "var(--dsw-alias-label-tertiary)" }
|
|
880
|
+
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" } },
|
|
881
|
+
h("span", {
|
|
882
|
+
style: sourceStyle,
|
|
883
|
+
title: on
|
|
884
|
+
? (chosenSource === "npm" ? "当前选的是插件市场版:按上游版本取包,装出来和从市场装一样" : "当前选的是本机版:代码、配置条目与数据快照都取本机这份")
|
|
885
|
+
: "还没勾选;勾上后默认按" + (entry.installed === false ? "市场版" : (entry.hasMarket ? "市场版" : "本机版")) + "打包",
|
|
886
|
+
}, sourceText),
|
|
887
|
+
h("input", { type: "checkbox", checked: on, onChange: () => toggle(entry) }),
|
|
888
|
+
h("div", { style: { flex: "1 1 220px", minWidth: "180px" } },
|
|
889
|
+
h("div", { style: label }, entry.title || entry.name, " ", h("span", { style: hint }, "@" + (entry.version || "?"))),
|
|
890
|
+
h("div", { style: hint }, (entry.description || "").slice(0, 110))),
|
|
891
|
+
h("span", { style: { ...chip, color: "var(--dsw-alias-label-tertiary)" } }, labelOf(categoryOf(entry))),
|
|
892
|
+
entry.updateAvailable ? h(Tag, { color: "#2bb673" }, "市场版 " + (entry.marketVersion || entry.version) + " 更新") : 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,
|
|
897
|
+
on ? h("div", { style: { display: "flex", gap: "4px" } },
|
|
898
|
+
h("button", { style: selected[entry.name].choice !== "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "preset"), title: "只打插件默认配置:不带本机的配置与数据快照(代码按所选来源)" }, "插件预设"),
|
|
899
|
+
h("button", { style: selected[entry.name].choice === "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "custom"), title: "带上本机这份插件的配置与数据快照;本机来源的连代码改动一起打" }, "自定义配置")) : null,
|
|
900
|
+
entry.hasMarket && entry.source === "profile" && on ? h("button", {
|
|
901
|
+
style: { ...chipBtn, border: "none", fontSize: "10.5px", color: "var(--dsw-alias-label-tertiary)" },
|
|
902
|
+
onClick: () => switchMarket(entry, selected[entry.name].source !== "npm"),
|
|
903
|
+
title: "改用插件市场发的同名版本(上游原版代码 + 默认配置),装出来和从市场装一样",
|
|
904
|
+
}, selected[entry.name].source === "npm" ? "改为本机版" : "改为市场版") : null)}
|
|
905
|
+
|
|
906
|
+
const renderList = () => {
|
|
907
|
+
if (active || sections.length === 0) return rows.map(renderOne)
|
|
908
|
+
const out = []
|
|
909
|
+
for (const section of sections) {
|
|
910
|
+
const onCount = section.entries.filter((entry) => Boolean(selected[entry.name])).length
|
|
911
|
+
const isFolded = folded[section.name] === true
|
|
912
|
+
out.push(h("div", {
|
|
913
|
+
key: section.key,
|
|
914
|
+
style: { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap", padding: "7px 2px", borderTop: "0.5px solid var(--dsw-alias-border-l2)" },
|
|
915
|
+
},
|
|
916
|
+
h("button", {
|
|
917
|
+
style: { ...chipBtn, border: "none", padding: "0 4px", fontSize: "12px", color: "var(--dsw-alias-label-secondary)" },
|
|
918
|
+
onClick: () => setFolded((prev) => ({ ...prev, [section.name]: !isFolded })),
|
|
919
|
+
title: isFolded ? "展开「" + section.name + "」" : "收起「" + section.name + "」",
|
|
920
|
+
}, isFolded ? "▸" : "▾"),
|
|
921
|
+
h("div", { style: { flex: "1 1 200px", minWidth: "160px" } },
|
|
922
|
+
h("div", { style: label }, section.name, " ", h("span", { style: hint }, section.entries.length + " 个" + (onCount > 0 ? " · 已选 " + onCount : ""))),
|
|
923
|
+
section.missing.length > 0 ? h("div", { style: hint }, "有 " + section.missing.length + " 个成员已不在本机") : null),
|
|
924
|
+
h("button", { style: btn, onClick: () => addGroup(section), title: "把这一组的插件都加入选择(默认插件预设,可逐个改)" }, "一键加入"),
|
|
925
|
+
onCount > 0 ? h("button", { style: btn, onClick: () => removeGroup(section) }, "清空本组") : null))
|
|
926
|
+
if (!isFolded) for (const entry of section.entries) out.push(renderOne(entry))
|
|
927
|
+
}
|
|
928
|
+
return out
|
|
929
|
+
}
|
|
930
|
+
|
|
785
931
|
const [jobMsg, setJobMsg] = useState("")
|
|
786
932
|
const pausedJobs = (props.jobs || []).filter((job) => job.kind === "pack" && job.status === "paused" && job.risk)
|
|
787
933
|
|
|
@@ -841,7 +987,7 @@ window.__ModuleLoader__.load({
|
|
|
841
987
|
async: true,
|
|
842
988
|
selection: picked.map((name) => selected[name]),
|
|
843
989
|
options: {
|
|
844
|
-
|
|
990
|
+
strategy: options.strategy,
|
|
845
991
|
includeConfig: options.includeConfig,
|
|
846
992
|
acknowledge: ack === true,
|
|
847
993
|
force: false,
|
|
@@ -921,10 +1067,25 @@ window.__ModuleLoader__.load({
|
|
|
921
1067
|
} finally { setBusy("") }
|
|
922
1068
|
}
|
|
923
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
|
|
924
1085
|
return h("div", { style: { display: "flex", flexDirection: "column", gap: "14px" } },
|
|
925
1086
|
h(Notice, null,
|
|
926
1087
|
h("b", null, "打包:将所选插件封装为一个 .dshpack 文件"),
|
|
927
|
-
"
|
|
1088
|
+
" 三种策略:完整包自带插件本体、不联网也能装;仅下载码只记版本、体积最小;混合包带版本与配置片段、体积接近仅下载码。完整包与混合包在安装前均不允许修改 profile 内容。",
|
|
928
1089
|
status && status.market && status.market.installed
|
|
929
1090
|
? h("div", { style: { ...hint, marginTop: "6px" } }, "已检测到插件市场 v" + status.market.version + ":本插件与其共用目录源与安装链路,但不依赖该插件,移除后打包与安装功能不受影响。")
|
|
930
1091
|
: h("div", { style: { ...hint, marginTop: "6px" } }, "未检测到插件市场,功能不受影响:打包、安装与检测均在本地完成。建议先安装 dshmarket 以获得分类、搜索与「切换市场版」入口;未安装时,首次使用请点击「建立目录索引」。"),
|
|
@@ -956,41 +1117,7 @@ window.__ModuleLoader__.load({
|
|
|
956
1117
|
h("div", { style: { display: "flex", flexDirection: "column", gap: "3px", maxHeight: "320px", overflow: "auto" } },
|
|
957
1118
|
rows.length === 0
|
|
958
1119
|
? h("div", { style: hint }, loading ? "读取中…" : active ? (searching ? "搜索中…" : "无匹配条目") : "本机尚未安装插件")
|
|
959
|
-
:
|
|
960
|
-
const on = Boolean(selected[entry.name])
|
|
961
|
-
const chosenSource = on ? selected[entry.name].source : (entry.installed === false ? "npm" : "profile")
|
|
962
|
-
const sourceText = on ? (chosenSource === "npm" ? "市场版" : "本机版") : (entry.installed === false ? "市场未装" : "已装")
|
|
963
|
-
const sourceStyle = on
|
|
964
|
-
? { ...chip, minWidth: "58px", textAlign: "center", fontWeight: 600, color: "var(--dsw-alias-label-primary)", borderColor: "var(--dsw-alias-border-l2)" }
|
|
965
|
-
: { ...chip, minWidth: "58px", textAlign: "center", color: "var(--dsw-alias-label-tertiary)" }
|
|
966
|
-
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" } },
|
|
967
|
-
h("span", {
|
|
968
|
-
style: sourceStyle,
|
|
969
|
-
title: on
|
|
970
|
-
? (chosenSource === "npm" ? "当前选的是插件市场版:按上游版本取包,装出来和从市场装一样" : "当前选的是本机版:代码、配置条目与数据快照都取本机这份")
|
|
971
|
-
: "还没勾选;勾上后默认按" + (entry.installed === false ? "市场版" : (entry.hasMarket ? "市场版" : "本机版")) + "打包",
|
|
972
|
-
}, sourceText),
|
|
973
|
-
h("input", { type: "checkbox", checked: on, onChange: () => toggle(entry) }),
|
|
974
|
-
h("div", { style: { flex: "1 1 220px", minWidth: "180px" } },
|
|
975
|
-
h("div", { style: label }, entry.title || entry.name, " ", h("span", { style: hint }, "@" + (entry.version || "?"))),
|
|
976
|
-
h("div", { style: hint }, (entry.description || "").slice(0, 110))),
|
|
977
|
-
h("span", { style: { ...chip, color: "var(--dsw-alias-label-tertiary)" } }, labelOf(categoryOf(entry))),
|
|
978
|
-
entry.updateAvailable ? h(Tag, { color: "#2bb673" }, "市场版 " + (entry.marketVersion || entry.version) + " 更新") : null,
|
|
979
|
-
on ? h("input", {
|
|
980
|
-
style: { ...input, width: "120px" },
|
|
981
|
-
placeholder: selected[entry.name].source === "npm" ? "版本,空=最新(从市场取包)" : "版本,空=本机版本",
|
|
982
|
-
value: selected[entry.name].spec || "",
|
|
983
|
-
onChange: (e) => setSpec(entry.name, e.target.value),
|
|
984
|
-
}) : null,
|
|
985
|
-
on ? h("div", { style: { display: "flex", gap: "4px" } },
|
|
986
|
-
h("button", { style: selected[entry.name].choice !== "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "preset"), title: "只打插件默认配置:不带本机的配置与数据快照(代码按所选来源)" }, "插件预设"),
|
|
987
|
-
h("button", { style: selected[entry.name].choice === "custom" ? chipOn : chipBtn, onClick: () => setChoice(entry.name, "custom"), title: "带上本机这份插件的配置与数据快照;本机来源的连代码改动一起打" }, "自定义配置")) : null,
|
|
988
|
-
entry.hasMarket && entry.source === "profile" && on ? h("button", {
|
|
989
|
-
style: { ...chipBtn, border: "none", fontSize: "10.5px", color: "var(--dsw-alias-label-tertiary)" },
|
|
990
|
-
onClick: () => switchMarket(entry, selected[entry.name].source !== "npm"),
|
|
991
|
-
title: "改用插件市场发的同名版本(上游原版代码 + 默认配置),装出来和从市场装一样",
|
|
992
|
-
}, selected[entry.name].source === "npm" ? "改为本机版" : "改为市场版") : null)
|
|
993
|
-
})),
|
|
1120
|
+
: renderList()),
|
|
994
1121
|
active && search.hasMore ? h("div", { style: row },
|
|
995
1122
|
h("button", { style: btn, disabled: searching, onClick: loadMore }, searching ? "加载中…" : ("加载更多(还有 " + Math.max(0, search.total - rows.length) + " 条)"))) : null,
|
|
996
1123
|
h("div", { style: hint }, active
|
|
@@ -998,10 +1125,48 @@ window.__ModuleLoader__.load({
|
|
|
998
1125
|
: "首屏只列本机已装。插件自带的内部组件(随父包一起装的那种)不单独列出" + (props.status && props.status.installedHidden ? "(本次隐藏 " + props.status.installedHidden + " 个)" : "") + "。每行最前面标出当前来源:市场版按上游版本取包,本机版取本机这份。勾选时默认「插件预设」——只打插件默认配置;要带上本机的配置条目与数据快照就改成「自定义配置」(本机版还会连代码改动一起打)。本机已装且市场里有同名条目的,默认按市场版勾选;要打本机这份就点行末「改为本机版」。搜索或点分类才去插件市场目录里查,服务端分页、一次一页。搜索结果里没装的插件也能直接勾选——打包时按版本从插件市场取包,装的时候同样从市场下载。")
|
|
999
1126
|
),
|
|
1000
1127
|
h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
|
|
1001
|
-
h("div", { style: strong }, "
|
|
1002
|
-
h("div", { style:
|
|
1003
|
-
|
|
1004
|
-
|
|
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,
|
|
1005
1170
|
h(NagText, { text: packNag }),
|
|
1006
1171
|
h("div", { style: { ...row, rowGap: "6px" } },
|
|
1007
1172
|
h("input", { style: { ...input, flex: "1 1 200px" }, placeholder: "整合包名", value: options.name, onChange: (e) => setOptions({ ...options, name: e.target.value }) }),
|
|
@@ -1009,7 +1174,7 @@ window.__ModuleLoader__.load({
|
|
|
1009
1174
|
h("input", { style: { ...input, width: "100%" }, placeholder: "一句话描述(可空)", value: options.description, onChange: (e) => setOptions({ ...options, description: e.target.value }) }),
|
|
1010
1175
|
h(Switch, { checked: options.confirmLicense, label: "我确认所选插件的许可证允许再分发,或已获得作者授权", onChange: (v) => setOptions({ ...options, confirmLicense: v }) }),
|
|
1011
1176
|
h("div", { style: row },
|
|
1012
|
-
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 + " 个插件"))),
|
|
1013
1178
|
started ? h("span", { style: hint }, "已开始:" + started + "(进度在左下角,可以接着选别的再打一个)") : null,
|
|
1014
1179
|
status ? h("span", { style: hint }, "DSH " + (status.dshVersion || "?") + " · profile " + status.profile) : null)),
|
|
1015
1180
|
pausedRiskNodes.length ? h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "10px", borderColor: "#d9534f" } }, pausedRiskNodes) : null,
|
|
@@ -1059,6 +1224,9 @@ window.__ModuleLoader__.load({
|
|
|
1059
1224
|
// 安装也走任务队列:进度直接显示在左下角那个窗里,这里留一份给页面内看
|
|
1060
1225
|
const [progress, setProgress] = useState(null)
|
|
1061
1226
|
const [deferred, setDeferred] = useState([])
|
|
1227
|
+
// 预览里逐个插件勾选要不要装、以及每个插件「包内配置 / 保持本机」
|
|
1228
|
+
const [pickedNames, setPickedNames] = useState({})
|
|
1229
|
+
const [configChoice, setConfigChoice] = useState({})
|
|
1062
1230
|
const [askReplace, setAskReplace] = useState(false)
|
|
1063
1231
|
const [imports, setImportsState] = useState(readImports())
|
|
1064
1232
|
|
|
@@ -1174,10 +1342,14 @@ window.__ModuleLoader__.load({
|
|
|
1174
1342
|
const install = async () => {
|
|
1175
1343
|
setBusy("install"); setError(""); setDone(null); setDeferred([]); setAskReplace(false); setProgress(null)
|
|
1176
1344
|
try {
|
|
1177
|
-
const
|
|
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 })
|
|
1178
1350
|
if (!data || data.ok !== true || !data.job) {
|
|
1179
1351
|
// 老宿主不认 async:退回同步调用
|
|
1180
|
-
const plain = await api("/install", { ...bodyFor(), ...
|
|
1352
|
+
const plain = await api("/install", { ...bodyFor(), ...installOptions })
|
|
1181
1353
|
if (!plain.ok) {
|
|
1182
1354
|
setDone({ ok: false, error: plain.error, refused: plain.refused, scan: plain.scan, report: plain.report })
|
|
1183
1355
|
return
|
|
@@ -1226,6 +1398,12 @@ window.__ModuleLoader__.load({
|
|
|
1226
1398
|
} finally { setBusy(""); setProgress(null) }
|
|
1227
1399
|
}
|
|
1228
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
|
+
: []
|
|
1229
1407
|
return h("div", { style: { display: "flex", flexDirection: "column", gap: "14px" } },
|
|
1230
1408
|
h(Notice, null,
|
|
1231
1409
|
h("b", null, "先看清楚,再装"),
|
|
@@ -1318,7 +1496,9 @@ window.__ModuleLoader__.load({
|
|
|
1318
1496
|
h(Switch, { checked: options.keepLocal, label: "保留本地已有修改(不覆盖已装插件)", onChange: (v) => setOptions({ ...options, keepLocal: v }) }),
|
|
1319
1497
|
h(Switch, { checked: options.applyConfig, label: "安装后回填包内配置", onChange: (v) => setOptions({ ...options, applyConfig: v }) }),
|
|
1320
1498
|
h(Switch, { checked: options.preferMarket, label: "联网时优先用插件市场的版本(市场查不到就用包内的)", onChange: (v) => setOptions({ ...options, preferMarket: v }) }),
|
|
1321
|
-
h(Switch, { checked: options.enableBundles, label: "
|
|
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 }) }),
|
|
1322
1502
|
h(Switch, { checked: options.force, label: "忽略阻断(我知道自己在干什么)", onChange: (v) => setOptions({ ...options, force: v }) })),
|
|
1323
1503
|
h("div", { style: row },
|
|
1324
1504
|
h("button", { style: btnPrimary, disabled: busy !== "" || (source.kind === "url" ? !source.url.trim() : !source.file), onClick: inspect }, busy === "inspect" ? "检测中…" : "检测这个包"),
|
|
@@ -1342,9 +1522,22 @@ window.__ModuleLoader__.load({
|
|
|
1342
1522
|
preview.blockingReasons && preview.blockingReasons.length
|
|
1343
1523
|
? h(Notice, { tone: "bad" }, h("b", null, "阻断:" ), preview.blockingReasons.join(";"), " (真要装,勾上面的「忽略阻断」)")
|
|
1344
1524
|
: null,
|
|
1345
|
-
h("div", { style: { display: "flex", flexDirection: "column", gap: "
|
|
1346
|
-
|
|
1347
|
-
|
|
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
|
+
})),
|
|
1348
1541
|
h(ScanReport, { scan: preview.scan, groups: preview.scanGroups }),
|
|
1349
1542
|
h(CompatList, { compat: preview.compat }),
|
|
1350
1543
|
preview.notes && preview.notes.length ? h("div", { style: hint }, preview.notes.map((n, i) => h("div", { key: i }, "· " + n))) : null,
|
|
@@ -1408,7 +1601,25 @@ window.__ModuleLoader__.load({
|
|
|
1408
1601
|
const [saved, setSaved] = useState("")
|
|
1409
1602
|
const [busy, setBusy] = useState(false)
|
|
1410
1603
|
const [scanNag, fireScanNag] = useNag()
|
|
1411
|
-
|
|
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
|
+
}
|
|
1412
1623
|
|
|
1413
1624
|
const patch = async (p) => {
|
|
1414
1625
|
setBusy(true); setSaved("")
|
|
@@ -1490,7 +1701,7 @@ window.__ModuleLoader__.load({
|
|
|
1490
1701
|
const bytes = Math.min(4096, Math.max(16, mb)) * 1048576
|
|
1491
1702
|
if (bytes !== mb * 1048576) setSaved("已按范围收到 16~4096 MB")
|
|
1492
1703
|
setField("maxPackBytes", bytes)
|
|
1493
|
-
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 })
|
|
1494
1705
|
},
|
|
1495
1706
|
}, "保存数值"),
|
|
1496
1707
|
h("span", { style: hint }, "默认 256 MB,可填 16~4096"),
|
|
@@ -1500,12 +1711,14 @@ window.__ModuleLoader__.load({
|
|
|
1500
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)) }),
|
|
1501
1712
|
h("span", { style: label }, "重试"),
|
|
1502
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)) }),
|
|
1503
1716
|
h(Switch, {
|
|
1504
1717
|
checked: cfg.curlFallback !== false,
|
|
1505
1718
|
label: "fetch 失败时用系统 curl 兜底",
|
|
1506
1719
|
onChange: (v) => { setField("curlFallback", v); patch({ curlFallback: v }) },
|
|
1507
1720
|
})),
|
|
1508
|
-
h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl
|
|
1721
|
+
h("div", { style: hint }, "registry 报 fetch failed / 超时,多半是代理或证书链:调大超时、加一次重试,或让 curl 兜底(走系统证书库)。提示「下载超过上限」时是版本清单太大(billion-context 这类包的清单十几 MB):把「版本清单上限」调大,或改用确定的版本号(插件会直接取单版本清单,体积最小)。保存后立即生效。"),
|
|
1509
1722
|
h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
|
|
1510
1723
|
h("div", { style: strong }, "信任清单"),
|
|
1511
1724
|
h("div", { style: hint }, "允许的许可证(一行一个,例如 MIT):"),
|
|
@@ -1522,10 +1735,36 @@ window.__ModuleLoader__.load({
|
|
|
1522
1735
|
h("div", { style: mono }, "整合包:" + ((props.status && props.status.paths && props.status.paths.packs) || "?")),
|
|
1523
1736
|
h("div", { style: mono }, "缓存与暂存:" + ((props.status && props.status.paths && props.status.paths.vendor) || "?")),
|
|
1524
1737
|
h("div", { style: mono }, "卸载临时文件:删掉 vendor 目录即可,装好的插件不受影响。")),
|
|
1525
|
-
h(
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
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))),
|
|
1529
1768
|
h("div", { style: { ...box, display: "flex", flexDirection: "column", gap: "8px" } },
|
|
1530
1769
|
h("div", { style: strong }, "显示位置"),
|
|
1531
1770
|
h("div", { style: hint }, "三处互相独立,一点就生效,不用重启。关掉只是不挂载入口,功能与接口都还在。至少留一处:只剩一个时,那个开关会变灰、点不动。"),
|
|
@@ -1556,6 +1795,10 @@ window.__ModuleLoader__.load({
|
|
|
1556
1795
|
const [tab, setTab] = useState("pack")
|
|
1557
1796
|
const jobs = useJobs()
|
|
1558
1797
|
const status = props.status
|
|
1798
|
+
const surface = (props && props.surface) || "sidebar"
|
|
1799
|
+
// 插件页里的那一栏外面已经有一层页头与标签:嵌进去不能再摆一遍大标题,
|
|
1800
|
+
// 否则同一屏里会出现两个名字、两套边距,看着像画坏了。
|
|
1801
|
+
const embedded = surface === "plugins"
|
|
1559
1802
|
const [packResult, setPackResult] = useState(() => readPackValue())
|
|
1560
1803
|
const [focus, setFocus] = useState(0)
|
|
1561
1804
|
useEffect(() => subscribePack((value) => { setPackResult(value) }), [])
|
|
@@ -1581,26 +1824,54 @@ window.__ModuleLoader__.load({
|
|
|
1581
1824
|
onClick: () => setTab(key),
|
|
1582
1825
|
style: {
|
|
1583
1826
|
...btn,
|
|
1827
|
+
fontSize: embedded ? "12px" : btn.fontSize,
|
|
1828
|
+
padding: embedded ? "3px 9px" : btn.padding,
|
|
1584
1829
|
borderColor: tab === key ? "transparent" : "var(--dsw-alias-border-l2)",
|
|
1585
1830
|
background: tab === key ? "var(--dsw-alias-fill-primary, #3b6cf6)" : "transparent",
|
|
1586
1831
|
color: tab === key ? "#fff" : "var(--dsw-alias-label-primary)",
|
|
1587
1832
|
},
|
|
1588
1833
|
}, text)
|
|
1589
1834
|
|
|
1835
|
+
const panels = [
|
|
1836
|
+
tab === "pack" ? h(PackPanel, { status, jobs, result: packResult, setResult: savePackResult, focus }) : null,
|
|
1837
|
+
tab === "install" ? h(InstallPanel, { status }) : null,
|
|
1838
|
+
tab === "settings" ? h(SettingsPanel, { status }) : null,
|
|
1839
|
+
]
|
|
1840
|
+
const footNote = h("div", { style: hint }, "说明:整合包只打包你选择的插件与必要配置。打包与安装安全检测在内存中进行,命中原文不落盘;请遵守插件作者许可证与你所在地区的法律法规。")
|
|
1841
|
+
const envLine = h("span", { style: { ...hint, marginLeft: "auto" } },
|
|
1842
|
+
status ? ("DSH " + (status.dshVersion || "?") + " · 已装 " + ((status.installed || []).length) + " 个 · v" + (status.pluginVersion || "?")) : "读取环境…")
|
|
1843
|
+
|
|
1844
|
+
// 嵌在插件页标签里:不重复页头,也不自己再造一层滚动区——外层插件页本来就会滚,
|
|
1845
|
+
// 里面再套一个固定高度的滚轮,遇到外层高度是 auto 时会被压成一条缝。
|
|
1846
|
+
if (embedded) {
|
|
1847
|
+
return h("div", {
|
|
1848
|
+
style: {
|
|
1849
|
+
display: "flex",
|
|
1850
|
+
flexDirection: "column",
|
|
1851
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1852
|
+
padding: "10px 2px 24px",
|
|
1853
|
+
position: "relative",
|
|
1854
|
+
},
|
|
1855
|
+
},
|
|
1856
|
+
h("div", { style: { maxWidth: "1020px", margin: "0 auto", width: "100%", display: "flex", flexDirection: "column", gap: "10px" } },
|
|
1857
|
+
h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)), envLine),
|
|
1858
|
+
panels,
|
|
1859
|
+
footNote,
|
|
1860
|
+
h(RepoFooter, null)),
|
|
1861
|
+
h(JobDock, { jobs, onOpenResult: openResult })
|
|
1862
|
+
)
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1590
1865
|
return h("div", {
|
|
1591
1866
|
style: { height: "100%", overflow: "auto", boxSizing: "border-box", padding: "22px 26px 44px", color: "var(--dsw-alias-label-primary)", position: "relative" },
|
|
1592
1867
|
},
|
|
1593
1868
|
h("div", { style: { maxWidth: "1020px", margin: "0 auto", display: "flex", flexDirection: "column", gap: "14px" } },
|
|
1594
1869
|
h("div", { style: { display: "flex", alignItems: "baseline", gap: "10px", flexWrap: "wrap" } },
|
|
1595
1870
|
h("h2", { style: { margin: 0, fontSize: "20px", fontWeight: 600 } }, "整合包"),
|
|
1596
|
-
h("span", { style: hint },
|
|
1597
|
-
h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)),
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
tab === "pack" ? h(PackPanel, { status, jobs, result: packResult, setResult: savePackResult, focus }) : null,
|
|
1601
|
-
tab === "install" ? h(InstallPanel, { status }) : null,
|
|
1602
|
-
tab === "settings" ? h(SettingsPanel, { status }) : null,
|
|
1603
|
-
h("div", { style: hint }, "说明:整合包只打包你选择的插件与必要配置。打包与安装安全检测在内存中进行,命中原文不落盘;请遵守插件作者许可证与你所在地区的法律法规。"),
|
|
1871
|
+
h("span", { style: hint }, ((status && status.config && status.config.tagline) || "谁说 dsh 不能整整合包呢?(你说这几个插件整一块不牛逼坏了)"))),
|
|
1872
|
+
h("div", { style: row }, tabs.map(([key, text]) => tabBtn(key, text)), envLine),
|
|
1873
|
+
panels,
|
|
1874
|
+
footNote,
|
|
1604
1875
|
h(RepoFooter, null)),
|
|
1605
1876
|
h(JobDock, { jobs, onOpenResult: openResult })
|
|
1606
1877
|
)
|
|
@@ -1617,19 +1888,43 @@ window.__ModuleLoader__.load({
|
|
|
1617
1888
|
function Page(props) {
|
|
1618
1889
|
const [status, setStatus] = useState(null)
|
|
1619
1890
|
const [error, setError] = useState("")
|
|
1620
|
-
const
|
|
1891
|
+
const [tries, setTries] = useState(0)
|
|
1892
|
+
const alive = useRef(true)
|
|
1893
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1894
|
+
// 宿主刚起来、会话还在建的时候,第一次可能拿不到状态(401/网络没就绪)。
|
|
1895
|
+
// 自己退避重试几次,别让用户看到一块红字或者一块空白。
|
|
1896
|
+
const load = useCallback(async (left) => {
|
|
1621
1897
|
try {
|
|
1622
1898
|
const data = await api("/status")
|
|
1899
|
+
if (!alive.current) return
|
|
1623
1900
|
if (data && data.ok) {
|
|
1624
1901
|
setStatus(data)
|
|
1625
1902
|
setError("")
|
|
1626
1903
|
if (data.placements) setPlacement(data.placements)
|
|
1627
|
-
|
|
1628
|
-
|
|
1904
|
+
setTries(0)
|
|
1905
|
+
return
|
|
1906
|
+
}
|
|
1907
|
+
setError((data && data.error) || "读取状态失败")
|
|
1908
|
+
} catch (e) {
|
|
1909
|
+
if (!alive.current) return
|
|
1910
|
+
if (left > 0) {
|
|
1911
|
+
setTimeout(() => { load(left - 1) }, 500 * (4 - left))
|
|
1912
|
+
setTries(left)
|
|
1913
|
+
return
|
|
1914
|
+
}
|
|
1915
|
+
setError(String((e && e.message) || e))
|
|
1916
|
+
}
|
|
1629
1917
|
}, [])
|
|
1630
|
-
useEffect(() => {
|
|
1631
|
-
if (error)
|
|
1632
|
-
|
|
1918
|
+
useEffect(() => { load(3) }, [load])
|
|
1919
|
+
if (error) {
|
|
1920
|
+
return h("div", { style: { padding: "20px 24px", color: "#ff6b6b", fontSize: "13px", display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" } },
|
|
1921
|
+
h("span", null, "整合包没起来:" + error),
|
|
1922
|
+
h("button", { type: "button", style: btn, onClick: () => { setError(""); setTries(0); load(3) } }, "重试"))
|
|
1923
|
+
}
|
|
1924
|
+
if (!status) {
|
|
1925
|
+
return h("div", { style: { padding: "20px 24px", color: "var(--dsw-alias-label-tertiary, #8b909b)", fontSize: "13px" } },
|
|
1926
|
+
tries > 0 ? "整合包:还在连 DSH 本体…(自动重试 " + tries + " 次)" : "整合包:读取环境…")
|
|
1927
|
+
}
|
|
1633
1928
|
return h(Home, { status, surface: (props && props.surface) || "sidebar" })
|
|
1634
1929
|
}
|
|
1635
1930
|
|
|
@@ -1683,10 +1978,27 @@ window.__ModuleLoader__.load({
|
|
|
1683
1978
|
}
|
|
1684
1979
|
} catch {}
|
|
1685
1980
|
|
|
1981
|
+
// 启动那一刻:/status 还没回来、插件页的槽位也还没被声明,插件页那条标签常常错过第一次机会。
|
|
1982
|
+
// 自己拉一次状态拿到开关,并在前十几秒补看几次——晚声明的槽位也能补挂上。
|
|
1983
|
+
const refreshPlacement = async (left) => {
|
|
1984
|
+
try {
|
|
1985
|
+
const data = await api("/status")
|
|
1986
|
+
if (data && data.ok && data.placements) setPlacement(data.placements)
|
|
1987
|
+
} catch (e) {
|
|
1988
|
+
if (left > 0) setTimeout(() => { refreshPlacement(left - 1) }, 700 * (3 - left))
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1686
1992
|
ctx.effect(() => {
|
|
1687
1993
|
const unsubscribe = subscribePlacement(sync)
|
|
1688
1994
|
sync(placement.value)
|
|
1689
|
-
|
|
1995
|
+
refreshPlacement(3)
|
|
1996
|
+
const timers = [900, 2600, 6000, 11000].map((ms) => setTimeout(() => sync(placement.value), ms))
|
|
1997
|
+
return () => {
|
|
1998
|
+
unsubscribe()
|
|
1999
|
+
for (const timer of timers) clearTimeout(timer)
|
|
2000
|
+
for (const key of [...mounted.keys()]) unmount(key)
|
|
2001
|
+
}
|
|
1690
2002
|
}, "dsh-modpack-kit: 三处显示位")
|
|
1691
2003
|
}
|
|
1692
2004
|
|