From 0494dc298180336e430ae12df34f1957c3469307 Mon Sep 17 00:00:00 2001 From: fuyuking <101615404+fuyuking@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:58:36 +0900 Subject: [PATCH 1/6] Add files via upload --- .../src/plugin/plugins/mapping/config.json | 31 ++++++++++++++++ .../plugins/mapping/configure/index.tsx | 29 +++++++++++++++ apps/web/src/plugin/plugins/mapping/icon.svg | 12 ++++++ .../src/plugin/plugins/mapping/view/index.tsx | 37 +++++++++++++++++++ .../plugin/plugins/mapping/view/style.less | 28 ++++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 apps/web/src/plugin/plugins/mapping/config.json create mode 100644 apps/web/src/plugin/plugins/mapping/configure/index.tsx create mode 100644 apps/web/src/plugin/plugins/mapping/icon.svg create mode 100644 apps/web/src/plugin/plugins/mapping/view/index.tsx create mode 100644 apps/web/src/plugin/plugins/mapping/view/style.less diff --git a/apps/web/src/plugin/plugins/mapping/config.json b/apps/web/src/plugin/plugins/mapping/config.json new file mode 100644 index 000000000..1edcac2d6 --- /dev/null +++ b/apps/web/src/plugin/plugins/mapping/config.json @@ -0,0 +1,31 @@ +{ + "$schema": "../../schema.json", + "type": "mapping", + "name": "Mapping", + "class": "data_card", + "icon": "./icon.svg", + "defaultRow": 2, + "defaultCol": 3, + "minRow": 1, + "minCol": 2, + "configProps": [ + { + "style": "width: 100%", + "components": [ + { + "type": "input", + "title": "URL", + "key": "src", + "style": "width: 100%", + "defaultValue": "https://example.com", + "componentProps": { + "inputProps": { + "maxLength": 512 + } + } + } + ] + } + ], + "view": [] +} diff --git a/apps/web/src/plugin/plugins/mapping/configure/index.tsx b/apps/web/src/plugin/plugins/mapping/configure/index.tsx new file mode 100644 index 000000000..6a3d92ae1 --- /dev/null +++ b/apps/web/src/plugin/plugins/mapping/configure/index.tsx @@ -0,0 +1,29 @@ +import { forwardRef } from 'react'; +import { RenderConfig } from '../../../render'; + +interface ConfigPluginProps { + config: CustomComponentProps; + value: any; + onOk: (data: any) => void; + onChange: (data: any) => void; +} + +const Plugin = forwardRef((props: ConfigPluginProps, ref: any) => { + const { onOk, onChange, value, config } = props; + + const handleSubmit = (data: any) => { + onOk(data); + }; + + return ( + + ); +}); + +export default Plugin; diff --git a/apps/web/src/plugin/plugins/mapping/icon.svg b/apps/web/src/plugin/plugins/mapping/icon.svg new file mode 100644 index 000000000..34b3f3cfb --- /dev/null +++ b/apps/web/src/plugin/plugins/mapping/icon.svg @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/apps/web/src/plugin/plugins/mapping/view/index.tsx b/apps/web/src/plugin/plugins/mapping/view/index.tsx new file mode 100644 index 000000000..d37985ebb --- /dev/null +++ b/apps/web/src/plugin/plugins/mapping/view/index.tsx @@ -0,0 +1,37 @@ +import { memo, useEffect, useState } from 'react'; +import './style.less'; + +export interface ViewProps { + config: { + src?: string; + }; + configJson: { + isPreview?: boolean; + }; +} + +const View = (props: ViewProps) => { + const { config } = props; + const { src='https://example.com' } = config || {}; + + const [key, setKey] = useState(0); + + // 当src变化时更新key值 + useEffect(() => { + setKey(prevKey => prevKey + 1); + }, [src]); + + return ( +