From 4c6118f50f8e78e8db157f9b32c49f5f068e3e9a Mon Sep 17 00:00:00 2001 From: roymondchen Date: Fri, 15 Aug 2025 12:25:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E4=BA=8B=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE=E6=BA=90=E8=87=AA?= =?UTF-8?q?=E8=BA=AB=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/App.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/core/src/App.ts b/packages/core/src/App.ts index c7ea216f..f7722625 100644 --- a/packages/core/src/App.ts +++ b/packages/core/src/App.ts @@ -288,21 +288,20 @@ class App extends EventEmitter { if (!dataSource) return; - const methods = dataSource.methods || []; + try { + const methods = dataSource.methods || []; - const method = methods.find((item) => item.name === methodName); - - if (!method) return; - - if (typeof method.content === 'function') { - try { + const method = methods.find((item) => item.name === methodName); + if (method && typeof method.content === 'function') { await method.content({ app: this, params, dataSource, eventParams: args, flowState }); - } catch (e: any) { - if (this.errorHandler) { - this.errorHandler(e, dataSource, { type: 'data-source-method', params, eventParams: args, flowState }); - } else { - throw e; - } + } else if (typeof dataSource[methodName] === 'function') { + await dataSource[methodName](); + } + } catch (e: any) { + if (this.errorHandler) { + this.errorHandler(e, dataSource, { type: 'data-source-method', params, eventParams: args, flowState }); + } else { + throw e; } } }