mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-20 05:29:58 +08:00
feat(core): 事件支持关联数据源自身方法
This commit is contained in:
parent
77da3f9762
commit
4c6118f50f
@ -288,15 +288,15 @@ class App extends EventEmitter {
|
|||||||
|
|
||||||
if (!dataSource) return;
|
if (!dataSource) return;
|
||||||
|
|
||||||
|
try {
|
||||||
const methods = dataSource.methods || [];
|
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 });
|
||||||
|
} else if (typeof dataSource[methodName] === 'function') {
|
||||||
|
await dataSource[methodName]();
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (this.errorHandler) {
|
if (this.errorHandler) {
|
||||||
this.errorHandler(e, dataSource, { type: 'data-source-method', params, eventParams: args, flowState });
|
this.errorHandler(e, dataSource, { type: 'data-source-method', params, eventParams: args, flowState });
|
||||||
@ -305,7 +305,6 @@ class App extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
this.removeAllListeners();
|
this.removeAllListeners();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user