From 13078ae3d6953941fca7af2bd9c52e9ac24baddc Mon Sep 17 00:00:00 2001 From: jinyanyan Date: Wed, 2 Jul 2025 16:09:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3GlobalContext=E4=BC=9A?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=A4=9A=E4=B8=AA=E5=AE=9E=E4=BE=8B=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4app=E5=9C=A8=E5=90=84=E4=B8=AA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2crash=E7=9A=84=E9=97=AE=E9=A2=98=20Signed-off-by:=2020?= =?UTF-8?q?8suo=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/src/main/ets/default/baseUtil/GlobalContext.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/utils/src/main/ets/default/baseUtil/GlobalContext.ts b/common/utils/src/main/ets/default/baseUtil/GlobalContext.ts index f7187b74..a9803f35 100644 --- a/common/utils/src/main/ets/default/baseUtil/GlobalContext.ts +++ b/common/utils/src/main/ets/default/baseUtil/GlobalContext.ts @@ -26,10 +26,12 @@ export class GlobalContext { } public static getContext(): GlobalContext { - if (!GlobalContext.instance) { - GlobalContext.instance = new GlobalContext(); + const sharedDict = globalThis + const key = "globalContextInstanceKey" + if (!sharedDict[key]) { + sharedDict[key] = new GlobalContext(); } - return GlobalContext.instance; + return sharedDict[key]; } getObject(value: string): Object | undefined { -- Gitee