提交记录修改ui/scripts/macos-resources-smoke.mjs+3 −1看文件
修改ui/scripts/resources-smoke.mjs+21 −8看文件
修改ui/src/resources.jsx+48 −24看文件
修改ui/src/settings.jsx+4 −3看文件
修改ui/src/style.css+27 −2看文件
| @@ -48,6 +48,7 @@ try { | ||
| 48 | 48 | await panel.getByText("已保存,重启环境后生效。", { exact: true }).waitFor(); |
| 49 | 49 | assert.deepEqual(requests[0].allocation, { automatic: false, memory_gib: 6, cpus: 3 }); |
| 50 | 50 | failSave = true; |
| 51 | 新增: await panel.getByLabel("内存上限(GiB)", { exact: true }).fill("8"); | |
| 51 | 52 | await panel.getByRole("button", { name: "保存资源配置", exact: true }).click(); |
| 52 | 53 | const error = panel.getByRole("alert").filter({ hasText: "资源配置保存失败" }); |
| 53 | 54 | await error.waitFor(); |
| @@ -58,11 +59,12 @@ try { | ||
| 58 | 59 | assert.ok(await error.isVisible()); |
| 59 | 60 | failSave = false; |
| 60 | 61 | await panel.getByRole("button", { name: "重启并应用已保存配置", exact: true }).click(); |
| 61 | 删除: await page.getByRole("dialog", { name: "重启并应用已保存的资源配置?", exact: true }).getByRole("button", { name: "保存后重启", exact: true }).click(); | |
| 62 | 新增: await page.getByRole("dialog", { name: "重启并应用已保存的资源配置?", exact: true }).getByRole("button", { name: "重启并应用", exact: true }).click(); | |
| 62 | 63 | await error.waitFor({ state: "hidden" }); |
| 63 | 64 | assert.deepEqual(requests.at(-1), {}); |
| 64 | 65 | await panel.getByRole("heading", { name: "计算资源", exact: true }).scrollIntoViewIfNeeded(); |
| 65 | 66 | await page.screenshot({ path: join(output, "macos-resources.png"), animations: "disabled" }); |
| 67 | 新增: await panel.getByText("资源统计说明", { exact: true }).click(); | |
| 66 | 68 | await panel.getByText(/内存估算使用客机物理容量/).scrollIntoViewIfNeeded(); |
| 67 | 69 | await page.screenshot({ path: join(output, "macos-resource-observation.png"), animations: "disabled" }); |
| 68 | 70 | assert.deepEqual(errors, []); |
| @@ -14,27 +14,33 @@ await page.route("**/api/environment/resources", async (route) => { | ||
| 14 | 14 | if (body.allocation) allocation = body.allocation.automatic ? { automatic: true, memory_gib: 12, cpus: 5 } : body.allocation; |
| 15 | 15 | return route.fulfill({ json: { ok: true } }); |
| 16 | 16 | } |
| 17 | 删除: return route.fulfill({ json: { ...allocation, ...(windowsRuntime ? { runtime: "hyperv", min_memory_gib: 4, min_cpus: 2 } : {}), running: false, recommended_memory_bytes: 12 * 2 ** 30, recommended_cpus: rejectSave ? 6 : 5, max_memory_gib: 12, max_cpus: 5 } }); | |
| 17 | 新增: return route.fulfill({ json: { ...allocation, ...(windowsRuntime ? { runtime: "hyperv", min_memory_gib: 4, min_cpus: 2 } : {}), running: false, recommended_memory_bytes: 12 * 2 ** 30, recommended_cpus: 5, max_memory_gib: 12, max_cpus: 5 } }); | |
| 18 | 18 | }); |
| 19 | 19 | async function open() { |
| 20 | 20 | await page.getByRole("button", { name: "设置", exact: true }).click(); |
| 21 | 21 | await page.getByRole("navigation", { name: "设置分组" }).getByRole("button", { name: "环境与恢复", exact: true }).click(); |
| 22 | 删除: await page.getByLabel("自动分配资源上限").waitFor(); | |
| 22 | 新增: await page.getByLabel("内存上限(GiB)", { exact: true }).waitFor(); | |
| 23 | 23 | } |
| 24 | 24 | try { |
| 25 | 25 | await open(); |
| 26 | 删除: assert.equal(await page.getByLabel("自动分配资源上限").isChecked(), true); | |
| 27 | 删除: await page.getByLabel("自动分配资源上限").uncheck(); | |
| 26 | 新增: assert.equal(await page.getByRole("button", { name: "保存资源配置", exact: true }).isDisabled(), true); | |
| 27 | 新增: assert.equal(await page.getByRole("button", { name: "恢复默认", exact: true }).isDisabled(), true); | |
| 28 | 28 | if (windowsRuntime) { |
| 29 | 29 | assert.equal(await page.getByLabel("内存上限(GiB)", { exact: true }).getAttribute("min"), "4"); |
| 30 | 30 | assert.equal(await page.getByLabel("CPU 逻辑核心数", { exact: true }).getAttribute("min"), "2"); |
| 31 | 31 | await page.getByLabel("内存上限(GiB)", { exact: true }).fill("3"); |
| 32 | 32 | await page.getByRole("button", { name: "保存资源配置", exact: true }).click(); |
| 33 | 33 | assert.equal(saves.length, 0); |
| 34 | 删除: await page.getByText(/内存与 CPU 用量来自 Windows 客机的系统观测/).waitFor(); | |
| 34 | 新增: | |
| 35 | 35 | } |
| 36 | 36 | await page.getByLabel("内存上限(GiB)", { exact: true }).fill("4"); |
| 37 | 37 | await page.getByLabel("CPU 逻辑核心数", { exact: true }).fill("2"); |
| 38 | 新增: assert.equal(await page.getByText("没有未保存的修改", { exact: true }).count(), 0); | |
| 39 | 新增: await page.getByRole("button", { name: "返回工作台", exact: true }).click(); | |
| 40 | 新增: const discard = page.getByRole("dialog", { name: "放弃尚未保存的修改?", exact: true }); | |
| 41 | 新增: await discard.waitFor(); | |
| 42 | 新增: await discard.getByRole("button", { name: "取消", exact: true }).click(); | |
| 43 | 新增: assert.equal(await page.getByLabel("内存上限(GiB)", { exact: true }).inputValue(), "4"); | |
| 38 | 44 | await page.screenshot({ path: "/tmp/cage-resource-settings.png", fullPage: true }); |
| 39 | 45 | await page.getByRole("button", { name: "保存资源配置", exact: true }).click(); |
| 40 | 46 | await page.getByText("已保存,下次启动环境时生效。", { exact: true }).waitFor(); |
| @@ -52,15 +58,22 @@ try { | ||
| 52 | 58 | await page.getByRole("button", { name: "保存资源配置", exact: true }).click(); |
| 53 | 59 | await page.getByRole("alert").filter({ hasText: "资源配置保存失败" }).waitFor(); |
| 54 | 60 | await page.waitForResponse(response => response.url().endsWith("/api/environment/resources") && response.request().method() === "GET" && response.ok()); |
| 55 | 删除: await page.getByText("6 个逻辑核心", { exact: true }).waitFor(); | |
| 61 | 新增: | |
| 56 | 62 | assert.equal(await page.getByRole("alert").filter({ hasText: "资源配置保存失败" }).isVisible(), true); |
| 57 | 63 | assert.equal(await page.getByLabel("内存上限(GiB)", { exact: true }).inputValue(), "6"); |
| 58 | 64 | rejectSave = false; |
| 59 | 删除: await page.getByLabel("自动分配资源上限").check(); | |
| 65 | 新增: await page.getByRole("button", { name: "恢复默认", exact: true }).click(); | |
| 66 | 新增: assert.equal(await page.getByLabel("内存上限(GiB)", { exact: true }).inputValue(), "12"); | |
| 67 | 新增: assert.equal(await page.getByLabel("CPU 逻辑核心数", { exact: true }).inputValue(), "5"); | |
| 68 | 新增: assert.equal(allocation.automatic, false, "reset stays a draft until saved"); | |
| 60 | 69 | await page.getByRole("button", { name: "保存资源配置", exact: true }).click(); |
| 61 | 70 | await page.getByText("已保存,下次启动环境时生效。", { exact: true }).waitFor(); |
| 62 | 71 | assert.equal(allocation.automatic, true); |
| 72 | 新增: await page.reload(); | |
| 73 | 新增: await open(); | |
| 74 | 新增: assert.equal(await page.getByRole("button", { name: "恢复默认", exact: true }).isDisabled(), true); | |
| 75 | 新增: assert.equal(await page.getByLabel("内存上限(GiB)", { exact: true }).inputValue(), "12"); | |
| 63 | 76 | assert.equal(await page.getByRole("alert").filter({ hasText: "资源配置保存失败" }).count(), 0); |
| 64 | 77 | assert.deepEqual(errors, []); |
| 65 | 删除: console.log("Resource settings: manual save, reload, bounds, failure retention, automatic mode passed."); | |
| 78 | 新增: console.log("Resource settings: manual save, reload, bounds, failure retention, defaults, editing, reset and persistence passed."); | |
| 66 | 79 | } finally { await browser.close(); } |
| @@ -3,8 +3,9 @@ import { api } from "./api"; | ||
| 3 | 3 | import { SafetyMessage } from "./safety-message"; |
| 4 | 4 | |
| 5 | 5 | const gib = (bytes) => `${(bytes / 1073741824).toFixed(1)} GiB`; |
| 6 | 新增:const allocationFrom = (data) => ({ automatic: data.automatic, memory_gib: data.memory_gib, cpus: data.cpus }); | |
| 6 | 7 | |
| 7 | 删除:export function ResourceSettings({ status, onConfirm }) { | |
| 8 | 新增:export function ResourceSettings({ status, onConfirm, onDirtyChange }) { | |
| 8 | 9 | const [data, setData] = useState(null); |
| 9 | 10 | const [error, setError] = useState(""); |
| 10 | 11 | const [readError, setReadError] = useState(""); |
| @@ -12,7 +13,7 @@ export function ResourceSettings({ status, onConfirm }) { | ||
| 12 | 13 | const [draft, setDraft] = useState(null); |
| 13 | 14 | const [saved, setSaved] = useState(false); |
| 14 | 15 | useEffect(() => { |
| 15 | 删除: if (data && data.runtime !== "container") setDraft((current) => current || { automatic: data.automatic, memory_gib: data.memory_gib, cpus: data.cpus }); | |
| 16 | 新增: if (data && data.runtime !== "container") setDraft((current) => current || allocationFrom(data)); | |
| 16 | 17 | }, [data]); |
| 17 | 18 | const save = async (event) => { |
| 18 | 19 | event.preventDefault(); |
| @@ -20,7 +21,9 @@ export function ResourceSettings({ status, onConfirm }) { | ||
| 20 | 21 | setSaved(false); |
| 21 | 22 | try { |
| 22 | 23 | await api("/environment/resources", { allocation: draft }); |
| 23 | 删除: setData(await api("/environment/resources")); | |
| 24 | 新增: const next = await api("/environment/resources"); | |
| 25 | 新增: setData(next); | |
| 26 | 新增: setDraft(allocationFrom(next)); | |
| 24 | 27 | setSaved(true); |
| 25 | 28 | setError(""); |
| 26 | 29 | } catch (e) { setError(e.message); } |
| @@ -43,7 +46,7 @@ export function ResourceSettings({ status, onConfirm }) { | ||
| 43 | 46 | if (!(await onConfirm({ |
| 44 | 47 | title: "重启并应用已保存的资源配置?", |
| 45 | 48 | body: "正在运行的命令会结束,浏览器和编辑器会重启。请先保存内容;项目文件和登录数据保留。手动暂停的网络仍保持暂停。", |
| 46 | 删除: confirm: "保存后重启", | |
| 49 | 新增: confirm: "重启并应用", | |
| 47 | 50 | }))) return; |
| 48 | 51 | setStarting(true); |
| 49 | 52 | try { await api("/environment/resources", {}); setError(""); } |
| @@ -56,6 +59,21 @@ export function ResourceSettings({ status, onConfirm }) { | ||
| 56 | 59 | const fresh = observation && Date.now() - Date.parse(observation.observed_at) < 10000; |
| 57 | 60 | const resourceError = error || readError || data?.resource_error; |
| 58 | 61 | const resourcesVerified = data?.resources_verified === true && !resourceError; |
| 62 | 新增: const busy = starting || status.job?.running; | |
| 63 | 新增: const dirty = draft && data && (draft.automatic !== data.automatic || (!draft.automatic && (draft.memory_gib !== data.memory_gib || draft.cpus !== data.cpus))); | |
| 64 | 新增: useEffect(() => { | |
| 65 | 新增: onDirtyChange?.(Boolean(dirty)); | |
| 66 | 新增: return () => onDirtyChange?.(false); | |
| 67 | 新增: }, [dirty, onDirtyChange]); | |
| 68 | 新增: const edit = (key, value) => { | |
| 69 | 新增: setDraft((current) => ({ ...current, automatic: false, [key]: value === "" ? "" : Number(value) })); | |
| 70 | 新增: setSaved(false); | |
| 71 | 新增: }; | |
| 72 | 新增: const reset = () => { | |
| 73 | 新增: setDraft({ automatic: true, memory_gib: data.recommended_memory_bytes / 1073741824, cpus: data.recommended_cpus }); | |
| 74 | 新增: setSaved(false); | |
| 75 | 新增: setError(""); | |
| 76 | 新增: }; | |
| 59 | 77 | if (data?.runtime === "container") return <section className="environment-versions" aria-label="计算资源"> |
| 60 | 78 | <h4>服务器容器资源上限</h4> |
| 61 | 79 | <p className="field-help">CPU、内存与进程数量由服务器上的容器资源组限制。</p> |
| @@ -66,23 +84,31 @@ export function ResourceSettings({ status, onConfirm }) { | ||
| 66 | 84 | <p className="field-help">{data.running ? resourcesVerified ? "已从服务器核验容器所属资源组的实际限制。实时内存与 CPU 用量尚未提供。" : "无法确认运行中容器的实际资源限制,请查看下方错误或等待重新核验。" : "环境尚未运行,当前显示部署配置中的资源上限。"}</p> |
| 67 | 85 | {resourceError && <p role="alert" className="error-message"><SafetyMessage message={resourceError} /></p>} |
| 68 | 86 | </section>; |
| 69 | 删除: return <section className="environment-versions" aria-label="计算资源"> | |
| 87 | 新增: return <section className="environment-versions resource-settings" aria-label="计算资源"> | |
| 70 | 88 | <h4>计算资源</h4> |
| 71 | 删除: <p className="field-help">{macOS ? "macOS 客机使用固定的启动内存容量,修改容量需要重启。CPU 按实际任务使用,核心数表示可同时使用的逻辑核心数。自动上限使用主机资源的一半,并受这台客机的最低配置约束。" : "内存随程序需求增长,持续空闲后逐步归还主机。默认上限为主机资源的一半;CPU 按实际任务使用,上限表示可同时使用的逻辑核心数。"}</p> | |
| 72 | 删除: <div className="setting-summary-row"><span>自动内存上限</span><strong>{data ? gib(data.recommended_memory_bytes) : "正在读取…"}</strong></div> | |
| 73 | 删除: <div className="setting-summary-row"><span>自动 CPU 上限</span><strong>{data ? `${data.recommended_cpus} 个逻辑核心` : "—"}</strong></div> | |
| 74 | 删除: {draft && <form className="resource-allocation" onSubmit={save} onChange={() => setSaved(false)}> | |
| 75 | 删除: <label className="check-line"><input type="checkbox" checked={draft.automatic} onChange={(e) => setDraft({ ...draft, automatic: e.target.checked })} />自动分配资源上限</label> | |
| 76 | 删除: {!draft.automatic && <> | |
| 77 | 删除: <label>内存上限(GiB)<input aria-label="内存上限(GiB)" type="number" min={data.min_memory_gib || 2} max={data.max_memory_gib} step="1" required value={draft.memory_gib} onChange={(e) => setDraft({ ...draft, memory_gib: e.target.value === "" ? "" : Number(e.target.value) })} /></label> | |
| 78 | 删除: <label>CPU 逻辑核心数<input aria-label="CPU 逻辑核心数" type="number" min={data.min_cpus || 1} max={data.max_cpus} step="1" required value={draft.cpus} onChange={(e) => setDraft({ ...draft, cpus: e.target.value === "" ? "" : Number(e.target.value) })} /></label> | |
| 79 | 删除: <p className="field-help">可设置 {data.min_memory_gib || 2}–{data.max_memory_gib} GiB 内存、{data.min_cpus || 1}–{data.max_cpus} 个逻辑核心。{macOS ? "保存后在下次启动时应用。" : "内存仍会在上限内按需分配和回收。"}</p> | |
| 80 | 删除: </>} | |
| 81 | 删除: <button type="submit" disabled={starting || status.job?.running}>保存资源配置</button> | |
| 82 | 删除: {saved && <p role="status" className="field-help">已保存,{data.running ? "重启环境后生效。" : "下次启动环境时生效。"}</p>} | |
| 83 | 删除: </form>} | |
| 84 | 删除: {macOS && data.minimum_requirements?.source === "existing-configuration" && <p className="field-help">当前最低值沿用已有启动配置。尚未从原恢复镜像读回 Apple 的最低要求。</p>} | |
| 85 | 删除: {data?.running && <> | |
| 89 | 新增: <p className="field-help resource-intro">默认使用主机一半的资源,可在下方调整。{macOS ? "macOS 客机使用固定的启动内存容量。" : "内存按需使用,持续空闲后逐步归还主机。"}CPU 按实际任务使用。</p> | |
| 90 | 新增: {draft ? <form className="resource-allocation" onSubmit={save}> | |
| 91 | 新增: <fieldset disabled={busy} className="resource-fields"> | |
| 92 | 新增: <legend className="sr-only">资源配置</legend> | |
| 93 | 新增: <label><span>内存{macOS ? "容量" : "上限"}</span> | |
| 94 | 新增: <span className="resource-input"><input aria-label="内存上限(GiB)" aria-describedby="resource-memory-help" type="number" min={data.min_memory_gib || 2} max={data.max_memory_gib} step="1" required value={draft.memory_gib} onChange={(e) => edit("memory_gib", e.target.value)} /><span aria-hidden="true">GiB</span></span> | |
| 95 | 新增: <small id="resource-memory-help">默认 {gib(data.recommended_memory_bytes)} · 可调 {data.min_memory_gib || 2}–{data.max_memory_gib} GiB</small> | |
| 96 | 新增: </label> | |
| 97 | 新增: <label><span>CPU 上限</span> | |
| 98 | 新增: <span className="resource-input"><input aria-label="CPU 逻辑核心数" aria-describedby="resource-cpu-help" type="number" min={data.min_cpus || 1} max={data.max_cpus} step="1" required value={draft.cpus} onChange={(e) => edit("cpus", e.target.value)} /><span aria-hidden="true">逻辑核心</span></span> | |
| 99 | 新增: <small id="resource-cpu-help">默认 {data.recommended_cpus} 个 · 可调 {data.min_cpus || 1}–{data.max_cpus} 个</small> | |
| 100 | 新增: </label> | |
| 101 | 新增: </fieldset> | |
| 102 | 新增: <div className="resource-actions"> | |
| 103 | 新增: <span className="resource-mode">{draft.automatic ? "默认配置" : "自定义配置"}{dirty ? " · 未保存" : ""}</span> | |
| 104 | 新增: <button className="text-button" type="button" disabled={busy || draft.automatic} onClick={reset}>恢复默认</button> | |
| 105 | 新增: <button type="submit" disabled={busy || !dirty}>{starting ? "正在保存…" : "保存资源配置"}</button> | |
| 106 | 新增: </div> | |
| 107 | 新增: <p role={saved ? "status" : undefined} className="field-help resource-save-note">{saved ? "已保存," : "保存后,"}{data.running ? "重启环境后生效。" : "下次启动环境时生效。"}</p> | |
| 108 | 新增: </form> : !resourceError && <p role="status" className="field-help">正在读取资源配置…</p>} | |
| 109 | 新增: {macOS && data.minimum_requirements?.source === "existing-configuration" && <p className="field-help resource-minimum-note">当前最低值沿用已有启动配置。尚未从原恢复镜像读回 Apple 的最低要求。</p>} | |
| 110 | 新增: {data?.running && <div className="resource-runtime"> | |
| 111 | 新增: <div className="resource-runtime-heading"><h5>当前运行</h5>{data.restart_required && <button className="text-button" disabled={busy} onClick={apply}>重启并应用已保存配置</button>}</div> | |
| 86 | 112 | <div className="setting-summary-row"><span>本次启动的内存上限</span><strong>{gib(data.configured_memory_bytes)}</strong></div> |
| 87 | 113 | <div className="setting-summary-row"><span>本次启动的 CPU 上限</span><strong>{data.configured_cpus} 个逻辑核心</strong></div> |
| 88 | 114 | <div className="setting-summary-row"><span>{macOS ? "环境内存用量(估算)" : "环境内存用量"}</span><strong>{fresh && guest ? gib(guest.total_bytes - guest.available_bytes) : "等待采样"}</strong></div> |
| @@ -90,10 +116,8 @@ export function ResourceSettings({ status, onConfirm }) { | ||
| 90 | 116 | <div className="setting-summary-row"><span>CPU 使用率</span><strong>{fresh && Number.isFinite(observation.cpu_percent) ? `${observation.cpu_percent.toFixed(0)}% / ${observation.cpus} 个核心` : "等待采样"}</strong></div> |
| 91 | 117 | {fresh && guest?.oom_kills > 0 && <p className="field-help" role="status">本次环境启动后,系统因内存不足终止过 {guest.oom_kills} 个进程。请降低重任务的并行数量,或使用内存更多的主机。</p>} |
| 92 | 118 | {(observation?.pressure || observation?.host_pressure) && <p className="field-help" role="status">{macOS ? "客机内存压力升高,请减少并行任务,或保存工作后调整内存上限并重启。" : observation.host_pressure ? "主机内存紧张,暂缓扩大分配。" : "环境内存紧张,正在上限内增加可用内存。达到上限后请减少同时运行的任务。"}</p>} |
| 93 | 删除: {data.restart_required && <button disabled={starting || status.job?.running} onClick={apply}>重启并应用已保存配置</button>} | |
| 94 | 删除: </>} | |
| 95 | 删除: {!data?.running && data && <p className="field-help">下次启动环境时应用已保存的资源配置。</p>} | |
| 119 | 新增: </div>} | |
| 96 | 120 | {(resourceError || observation?.error) && <p role="alert" className="error-message"><SafetyMessage message={resourceError || observation.error} /></p>} |
| 97 | 删除: <p className="field-help">{macOS ? "内存估算使用客机物理容量减去空闲与非活跃页,压缩页计入用量。CPU 来自连续两次 Mach 计数采样。当前缺少可核验的内存回收量,Cage 使用固定容量;OOM 终止计数尚未提供。主机系统监视器还会统计虚拟化开销。" : data?.runtime === "hyperv" ? "内存与 CPU 用量来自 Windows 客机的系统观测。Hyper-V 会在设置的内存上下限内分配和回收内存;主机系统监视器还会统计虚拟化开销。" : "内存用量不含可回收缓存;这些数值反映环境内部状态,主机系统监视器还会统计虚拟化开销。短时故障导致内部断网后,会自动重新检查,通过后恢复;手动暂停需手动恢复。"}</p> | |
| 121 | 新增: {data?.running && <details className="resource-observation-note"><summary>资源统计说明</summary><p className="field-help">{macOS ? "内存估算使用客机物理容量减去空闲与非活跃页,压缩页计入用量。CPU 来自连续两次 Mach 计数采样。OOM 终止计数尚未提供。主机系统监视器还会统计虚拟化开销。" : data.runtime === "hyperv" ? "内存与 CPU 用量来自 Windows 客机的系统观测。Hyper-V 会在设置的内存上下限内分配和回收内存;主机系统监视器还会统计虚拟化开销。" : "内存用量不含可回收缓存;这些数值反映环境内部状态,主机系统监视器还会统计虚拟化开销。"}</p></details>} | |
| 98 | 122 | </section>; |
| 99 | 123 | } |
| @@ -59,6 +59,7 @@ export function SettingsPanel({ | ||
| 59 | 59 | const [localKeyboard, setLocalKeyboard] = useState(() => clientKeyboard(current.keyboard)); |
| 60 | 60 | const [accountDirty, setAccountDirty] = useState(false); |
| 61 | 61 | const [proxyDirty, setProxyDirty] = useState(false); |
| 62 | 新增: const [resourceDirty, setResourceDirty] = useState(false); | |
| 62 | 63 | const [draft, setDraft] = useState({ ...current }), |
| 63 | 64 | [section, setSection] = useState(initialSection), |
| 64 | 65 | [probe, setProbe] = useState(null), |
| @@ -106,7 +107,7 @@ export function SettingsPanel({ | ||
| 106 | 107 | return; |
| 107 | 108 | } |
| 108 | 109 | if ( |
| 109 | 删除: (!changed && !accountDirty && !proxyDirty) || | |
| 110 | 新增: (!changed && !accountDirty && !proxyDirty && !resourceDirty) || | |
| 110 | 111 | (await onConfirm({ |
| 111 | 112 | title: "放弃尚未保存的修改?", |
| 112 | 113 | body: "当前环境不会改变。关闭后会丢弃这次表单修改。", |
| @@ -599,7 +600,7 @@ export function SettingsPanel({ | ||
| 599 | 600 | 切换项目只改变新终端和文件编辑器的起始位置;已有终端、网页和登录态会保留。 |
| 600 | 601 | </p> |
| 601 | 602 | <EnvironmentVersions status={status} onConfirm={onConfirm} /> |
| 602 | 删除: <ResourceSettings status={status} onConfirm={onConfirm} /> | |
| 603 | 新增: <ResourceSettings status={status} onConfirm={onConfirm} onDirtyChange={setResourceDirty} /> | |
| 603 | 604 | <DiagnosticSettings /> |
| 604 | 605 | {status.can_restore && ( |
| 605 | 606 | <button |
| @@ -653,7 +654,7 @@ export function SettingsPanel({ | ||
| 653 | 654 | </div> |
| 654 | 655 | )} |
| 655 | 656 | </div> |
| 656 | 删除: {(!["appearance", "browser", "account", "claude-accounts", "vault", "mobile", "archived-sessions"].includes(section) || changed) && ( | |
| 657 | 新增: {(!["appearance", "browser", "account", "claude-accounts", "vault", "mobile", "archived-sessions", "project"].includes(section) || changed) && ( | |
| 657 | 658 | <footer className="settings-footer"> |
| 658 | 659 | {" "} |
| 659 | 660 | <> |
| @@ -546,8 +546,33 @@ button.large { | ||
| 546 | 546 | .browser-upload-body label { display: flex; flex-direction: column; gap: 8px; } |
| 547 | 547 | .browser-upload-body input, .browser-upload-body progress { width: 100%; } |
| 548 | 548 | .environment-versions { margin-top: 28px; } |
| 549 | 删除:.resource-allocation { margin: 24px 0; } | |
| 550 | 删除:.resource-allocation > [role="status"] { margin: 12px 0 0; } | |
| 549 | 新增:.resource-settings .resource-intro { margin: 0 0 20px; } | |
| 550 | 新增:.resource-allocation { margin: 0; } | |
| 551 | 新增:.resource-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; border: 0; padding: 0; margin: 0; min-width: 0; } | |
| 552 | 新增:.resource-fields legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } | |
| 553 | 新增:.settings-content .resource-fields label { margin: 0 !important; gap: 8px; min-width: 0; } | |
| 554 | 新增:.resource-fields small { color: var(--muted); font-size: 0.8571rem; font-weight: 400; line-height: 1.6; } | |
| 555 | 新增:.resource-input { position: relative; display: flex; align-items: center; } | |
| 556 | 新增:.settings-content .resource-input input { padding-right: 86px; font-variant-numeric: tabular-nums; font-size: 1.1429rem; height: 44px; } | |
| 557 | 新增:.resource-input > span { position: absolute; right: 30px; color: var(--muted); font-size: 0.8571rem; pointer-events: none; } | |
| 558 | 新增:.resource-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-top: 20px; } | |
| 559 | 新增:.resource-mode { margin-right: auto; color: var(--muted); font-size: 0.8571rem; } | |
| 560 | 新增:.resource-actions .text-button { margin: 0; } | |
| 561 | 新增:.resource-actions button[type="submit"] { background: var(--button); color: var(--button-ink); border-color: var(--button); } | |
| 562 | 新增:.resource-settings .resource-save-note { margin: 10px 0 0; } | |
| 563 | 新增:.resource-settings .resource-minimum-note { margin: 10px 0 0; } | |
| 564 | 新增:.resource-runtime { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; } | |
| 565 | 新增:.resource-runtime-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; } | |
| 566 | 新增:.resource-runtime-heading h5 { font-size: 0.9286rem; font-weight: 550; margin: 0; } | |
| 567 | 新增:.resource-runtime .setting-summary-row { margin: 0; padding: 10px 0; font-size: 0.9286rem; } | |
| 568 | 新增:.resource-runtime .field-help { margin: 12px 0 0; } | |
| 569 | 新增:.resource-observation-note { margin-top: 14px; color: var(--muted); font-size: 0.8571rem; } | |
| 570 | 新增:.resource-observation-note summary { cursor: pointer; width: fit-content; } | |
| 571 | 新增:.resource-observation-note .field-help { margin: 10px 0 0; } | |
| 572 | 新增:@media (max-width: 600px) { | |
| 573 | 新增: .resource-fields { grid-template-columns: 1fr; gap: 16px; } | |
| 574 | 新增: .resource-mode { flex-basis: 100%; } | |
| 575 | 新增:} | |
| 551 | 576 | .environment-versions .setting-summary-row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; } |
| 552 | 577 | .environment-versions .setting-summary-row strong { margin: 0; } |
| 553 | 578 | .environment-tool-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 12px 0; } |

