fix(ui): 设置页适配额外出站主机授权 —— hosts_declared/hosts_granted

上一提交把 auth_hosts 语义泛化为 plugin.hosts(额外出站主机授权),但设置页
仍读旧字段名 auth_hosts_declared/auth_hosts_granted、提交 auth_hosts 键 ——
导致内核权限面板的主机授权区永远显示"未声明",勾选保存也不生效。

- 读取: auth_hosts_declared/granted → hosts_declared/granted
- 提交: { auth_hosts } → { hosts }
- 文案: "登录主机" → "额外出站主机"(授权与登录无关,登录是插件自己的事)

内联 JS node --check 全部通过;UI 契约测试通过。
This commit is contained in:
JianFeeeee
2026-10-11 16:47:24 +08:00
parent 74ec1e7874
commit 50997a4e3a

View File

@ -864,11 +864,11 @@
plDanger: "危险级",
plSave: "保存",
plClose: "关闭",
plAuthHosts: "登录主机(出站白名单)",
plAuthHostsHint: "登录流程要访问的主机不是上游源,默认被出站白名单拒绝。勾选即批准;只能批准插件自己声明过的。",
plAuthHosts: "额外出站主机(白名单)",
plAuthHostsHint: "插件要访问的主机若不是上游源,默认被出站白名单拒绝。勾选即批准;只能批准插件自己声明过的。",
plHostOk: "已批准",
plHostPending: "待批准",
plNoAuthHosts: "该插件未声明登录主机",
plNoAuthHosts: "该插件未声明额外出站主机",
plAccessTitle: "访问控制",
plAccessHint: "填写允许访问的角色或密钥(@名称)。留空=仅 admin。填 public=任何人。指定 @密钥 时只有该密钥能访问,不受角色规则影响。",
plWholePlugin: "以下端点",
@ -1195,11 +1195,11 @@
plDanger: "Danger",
plSave: "Save",
plClose: "Close",
plAuthHosts: "Login hosts (outbound allowlist)",
plAuthHostsHint: "Login flows reach hosts that are not upstream sources, which the outbound allowlist blocks by default. Tick to approve; only hosts the plugin itself declared can be approved.",
plAuthHosts: "Extra outbound hosts (allowlist)",
plAuthHostsHint: "Hosts a plugin needs that are not upstream sources are blocked by the outbound allowlist by default. Tick to approve; only hosts the plugin itself declared can be approved.",
plHostOk: "approved",
plHostPending: "pending",
plNoAuthHosts: "this plugin declared no login hosts",
plNoAuthHosts: "this plugin declared no extra outbound hosts",
plAccessTitle: "Access control",
plAccessHint: "Roles or keys (@name) allowed to reach each endpoint. Empty = admin only. public = anyone. Listing @keys replaces the role rules entirely.",
plWholePlugin: "endpoints below",
@ -5059,8 +5059,8 @@ function afterChainEdit() {
<td>${tag}</td></tr>`;
})
.join("");
const declaredHosts = j.auth_hosts_declared || [];
const grantedHosts = new Set(j.auth_hosts_granted || []);
const declaredHosts = j.hosts_declared || [];
const grantedHosts = new Set(j.hosts_granted || []);
const hostRows = declaredHosts.length
? declaredHosts
.map(
@ -5090,13 +5090,13 @@ function afterChainEdit() {
const actions = [...document.querySelectorAll("[data-ka]")]
.filter((c) => c.checked)
.map((c) => c.getAttribute("data-ka"));
const auth_hosts = [...document.querySelectorAll("[data-ah]")]
const hosts = [...document.querySelectorAll("[data-ah]")]
.filter((c) => c.checked)
.map((c) => c.getAttribute("data-ah"));
try {
await api("/api/plugins/" + encodeURIComponent(name) + "/kernel", {
method: "PUT",
body: JSON.stringify({ actions, all_read: false, auth_hosts }),
body: JSON.stringify({ actions, all_read: false, hosts }),
});
await refreshKernelSummary();
await openKernelEditor(name);