fix(ui): 「系统管理」分区改为仅 admin 注册(普通用户不再看到该栏)
- apply() 先异步判 /api/auth/me 角色,非 admin 不注入该 section(fail-closed)
- 依据:官方 settings 外壳按 ctx.slots.getVersion('settings.section') 重算导航
(dsh-client-ui-settings/lib/client.js:560)⇒ 晚注册会被正确反映
- 验收脚本补「非 admin 只注册 1 个分区」断言 + 等一拍异步注册;npm run verify 全绿
- 版本 0.3.1 → 0.3.2,已铺发
This commit is contained in:
1 parent
4190848c4a
commit
ac67db7702
3 files changed
+39
-13
No files matched your search
@@ -1204,17 +1204,29 @@ window.__ModuleLoader__.load({
|
||||
return jsxRuntime.jsx("div", { style: wrap, children: rows });
|
||||
}
|
||||
|
||||
ctx.slots.inject("settings.section", function () {
|
||||
return ctx.slots.register(
|
||||
{
|
||||
name: "settings.section",
|
||||
id: "platform-admin",
|
||||
order: 102,
|
||||
label: function () { return t("pa.label"); }
|
||||
},
|
||||
PlatformAdminSection
|
||||
);
|
||||
});
|
||||
// ── 「系统管理」分区:**仅 admin 注册**(2026-09-13 用户指出:普通用户不该看到这一栏)
|
||||
// 依据:官方 settings 外壳按 `ctx.slots.getVersion("settings.section")` 失效重算导航
|
||||
// (`dsh-client-ui-settings/lib/client.js:560`)⇒ **晚注册会被正确反映**。
|
||||
// 所以先异步判角色:**非 admin 干脆不注册**(而非注册后显示一行「仅管理员」)。
|
||||
fetch(portalHost() + "/api/auth/me", { credentials: "include" })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
var role = d && d.user && d.user.role;
|
||||
if (role !== "admin") return;
|
||||
ctx.slots.inject("settings.section", function () {
|
||||
return ctx.slots.register(
|
||||
{
|
||||
name: "settings.section",
|
||||
id: "platform-admin",
|
||||
order: 102,
|
||||
label: function () { return t("pa.label"); }
|
||||
},
|
||||
PlatformAdminSection
|
||||
);
|
||||
});
|
||||
})
|
||||
// 判角色失败 = 按非 admin 处理,不注册(fail-closed:宁可少显示,不越权暴露)
|
||||
.catch(function () {});
|
||||
}
|
||||
|
||||
exports.apply = apply;
|
||||
|
||||
Reference in new issue
Block a user