From 040d679b7f6a2dc105e6d5857078479ede39e069 Mon Sep 17 00:00:00 2001 From: parisma Date: Wed, 28 Sep 2022 16:04:35 +0800 Subject: [PATCH] =?UTF-8?q?chore(core):=20ts=E6=8A=A5=E9=94=99=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/App.ts | 2 +- packages/core/src/Node.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/App.ts b/packages/core/src/App.ts index c82bff35..705c8510 100644 --- a/packages/core/src/App.ts +++ b/packages/core/src/App.ts @@ -44,7 +44,7 @@ interface EventCache { class App extends EventEmitter { public env; - public codeDsl: CodeBlockDSL; + public codeDsl: CodeBlockDSL | undefined; public pages = new Map(); public page: Page | undefined; diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index 622cfb4b..ad61527c 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -85,9 +85,9 @@ class Node extends EventEmitter { } private async runCodeBlock(hook: string) { - if (!Array.isArray(this.data[hook]) || isEmpty(this.app?.codeDsl)) return; + if (!Array.isArray(this.data[hook]) || !this.app.codeDsl || isEmpty(this.app?.codeDsl)) return; for (const codeId of this.data[hook]) { - if (this.app?.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') { + if (this.app.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') { await this.app.codeDsl[codeId].content(this); } }