mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 07:30:22 +08:00
fix: permissionPresetsOf 未 inject 时不再抛错。(#52)
直访和 ctx.get 都放进 try。
This commit is contained in:
1 parent
2929bb783b
commit
7977b38176
1 file changed
+6
-2
+6
-2
@@ -243,12 +243,16 @@ function rewriteLiveAssembly(config, assembled, context) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Cordis 的 ctx 是 Proxy:未声明 inject 时点属性会抛 "cannot get property ... without inject",所以两段都要包 try。 */
|
||||
function permissionPresetsOf(ctx) {
|
||||
if (ctx?.permissionPresets && typeof ctx.permissionPresets.set === "function") return ctx.permissionPresets;
|
||||
try {
|
||||
const direct = ctx?.permissionPresets;
|
||||
if (direct && typeof direct.set === "function") return direct;
|
||||
} catch { /* without inject */ }
|
||||
try {
|
||||
const svc = ctx?.get?.("permissionPresets");
|
||||
if (svc && typeof svc.set === "function") return svc;
|
||||
} catch {}
|
||||
} catch { /* missing */ }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user