feat: core代码执行兼容老的数据格式

This commit is contained in:
parisma 2022-11-10 20:10:21 +08:00
parent c2b000ac5f
commit a03ac7c78b

View File

@ -85,6 +85,11 @@ class Node extends EventEmitter {
} }
private async runCodeBlock(hook: string) { private async runCodeBlock(hook: string) {
if (typeof this.data[hook] === 'function') {
// 兼容旧的数据格式
await this.data[hook](this);
return;
}
if (this.data[hook]?.hookType !== HookType.CODE || !this.app.codeDsl || isEmpty(this.app?.codeDsl)) return; if (this.data[hook]?.hookType !== HookType.CODE || !this.app.codeDsl || isEmpty(this.app?.codeDsl)) return;
for (const item of this.data[hook].hookData) { for (const item of this.data[hook].hookData) {
const { codeId, params = {} } = item; const { codeId, params = {} } = item;