feat(core): 事件支持关联数据源自身方法

This commit is contained in:
roymondchen 2025-08-15 12:25:00 +08:00
parent 77da3f9762
commit 4c6118f50f

View File

@ -288,21 +288,20 @@ class App extends EventEmitter {
if (!dataSource) return; if (!dataSource) return;
const methods = dataSource.methods || []; try {
const methods = dataSource.methods || [];
const method = methods.find((item) => item.name === methodName); const method = methods.find((item) => item.name === methodName);
if (method && typeof method.content === 'function') {
if (!method) return;
if (typeof method.content === 'function') {
try {
await method.content({ app: this, params, dataSource, eventParams: args, flowState }); await method.content({ app: this, params, dataSource, eventParams: args, flowState });
} catch (e: any) { } else if (typeof dataSource[methodName] === 'function') {
if (this.errorHandler) { await dataSource[methodName]();
this.errorHandler(e, dataSource, { type: 'data-source-method', params, eventParams: args, flowState }); }
} else { } catch (e: any) {
throw e; if (this.errorHandler) {
} this.errorHandler(e, dataSource, { type: 'data-source-method', params, eventParams: args, flowState });
} else {
throw e;
} }
} }
} }