From 6cdeaa0c1bd8b5c379153dd32136e4244c7e2a2b Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 2 Jul 2024 16:16:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20=E6=96=B9=E6=B3=95=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/components/CodeParams.vue | 12 +++++++++++- packages/editor/src/hooks/use-data-source-method.ts | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/CodeParams.vue b/packages/editor/src/components/CodeParams.vue index 7661af71..b48429a5 100644 --- a/packages/editor/src/components/CodeParams.vue +++ b/packages/editor/src/components/CodeParams.vue @@ -44,7 +44,17 @@ const getFormConfig = (items: FormConfig = []) => [ }, ]; -const codeParamsConfig = computed(() => getFormConfig(props.paramsConfig)); +const codeParamsConfig = computed(() => + getFormConfig( + props.paramsConfig.map(({ name, text, extra, ...config }) => ({ + type: 'data-source-field-select', + name, + text, + extra, + fieldConfig: config, + })), + ), +); /** * 参数值修改更新 diff --git a/packages/editor/src/hooks/use-data-source-method.ts b/packages/editor/src/hooks/use-data-source-method.ts index 7020a1fa..444956fe 100644 --- a/packages/editor/src/hooks/use-data-source-method.ts +++ b/packages/editor/src/hooks/use-data-source-method.ts @@ -41,7 +41,7 @@ export const useDataSourceMethod = () => { return; } - let codeContent = method.content; + let codeContent = method.content || `({ params, dataSource, app }) => {\n // place your code here\n}`; if (typeof codeContent !== 'string') { codeContent = codeContent.toString();