From 075839af864c9d6617dcf69291b7b6956c0703c5 Mon Sep 17 00:00:00 2001 From: Cracer <46320829+cracer4869@users.noreply.github.com> Date: Thu, 1 Oct 2026 16:25:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20permissionPresetsOf=20=E6=9C=AA=20inject?= =?UTF-8?q?=20=E6=97=B6=E4=B8=8D=E5=86=8D=E6=8A=9B=E9=94=99=E3=80=82?= =?UTF-8?q?=EF=BC=88#52=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 直访和 ctx.get 都放进 try。 --- lib/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index f8e4ee0..f153eeb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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; }