fix: history parent container get (#150)

This commit is contained in:
chenjiawei.inizio 2025-04-18 10:58:54 +08:00 committed by GitHub
parent 4bb3270f2d
commit 7275dcb6d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,8 +22,13 @@ export const HistoryContainerModule = new ContainerModule(
bind(HistoryConfig).toSelf().inSingletonScope();
onActivation(HistoryService, (ctx, historyService) => {
const historyManager =
ctx.container?.parent?.get(HistoryManager) || ctx.container.get(HistoryManager);
let historyManager;
if (ctx.container?.parent?.isBound(HistoryManager)) {
historyManager = ctx.container?.parent?.get(HistoryManager);
} else {
historyManager = ctx.container.get(HistoryManager);
}
if (!historyManager) {
return historyService;
@ -33,5 +38,5 @@ export const HistoryContainerModule = new ContainerModule(
historyManager.registerHistoryService(historyService);
return historyService;
});
},
}
);