From fa38e61b271d309785bb185a6a3ac600e59c70ff Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:55:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=B9=E6=A1=86=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=AE=A1=E7=90=86=E9=85=8D=E7=BD=AE=20(#1126?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/plugin/Dialog.tsx | 2 ++ packages/amis-editor/src/plugin/Drawer.tsx | 1 + packages/amis-editor/src/tpl/common.tsx | 38 +++++++++++++++++++++- packages/amis/src/renderers/Action.tsx | 4 +-- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor/src/plugin/Dialog.tsx b/packages/amis-editor/src/plugin/Dialog.tsx index 53655e237..1237cd8f6 100644 --- a/packages/amis-editor/src/plugin/Dialog.tsx +++ b/packages/amis-editor/src/plugin/Dialog.tsx @@ -298,6 +298,8 @@ export class DialogPlugin extends BasePlugin { name: 'title' }, + getSchemaTpl('button-manager'), + getSchemaTpl('switch', { label: '展示关闭按钮', name: 'showCloseButton', diff --git a/packages/amis-editor/src/plugin/Drawer.tsx b/packages/amis-editor/src/plugin/Drawer.tsx index d3d15da64..97a69d1e4 100644 --- a/packages/amis-editor/src/plugin/Drawer.tsx +++ b/packages/amis-editor/src/plugin/Drawer.tsx @@ -171,6 +171,7 @@ export class DrawerPlugin extends BasePlugin { label: '显示蒙层', pipeIn: defaultValue(true) }), + getSchemaTpl('button-manager'), getSchemaTpl('switch', { name: 'showCloseButton', label: '展示关闭按钮', diff --git a/packages/amis-editor/src/tpl/common.tsx b/packages/amis-editor/src/tpl/common.tsx index 60965cf05..f92f4ed91 100644 --- a/packages/amis-editor/src/tpl/common.tsx +++ b/packages/amis-editor/src/tpl/common.tsx @@ -6,7 +6,7 @@ import { tipedLabel, EditorManager } from 'amis-editor-core'; -import type {SchemaObject} from 'amis'; +import {render, type SchemaObject} from 'amis'; import flatten from 'lodash/flatten'; import {InputComponentName} from '../component/InputComponentName'; import {FormulaDateType} from '../renderer/FormulaControl'; @@ -1851,3 +1851,39 @@ setSchemaTpl('inputForbid', { name: 'inputForbid', inputClassName: 'is-inline' }); + +setSchemaTpl('button-manager', () => { + return getSchemaTpl('combo-container', { + type: 'combo', + label: '按钮管理', + name: 'actions', + mode: 'normal', + multiple: true, + addable: true, + draggable: true, + editable: false, + items: [ + { + component: (props: any) => { + return render({ + ...props.data, + onEvent: {}, + actionType: '', + onClick: (e: any, props: any) => { + const editorStore = (window as any).editorStore; + const subEditorStore = editorStore.getSubEditorRef()?.store; + (subEditorStore || editorStore).setActiveIdByComponentId( + props.id + ); + } + }); + } + } + ], + addButtonText: '新增按钮', + scaffold: { + type: 'button', + label: '按钮' + } + }); +}); diff --git a/packages/amis/src/renderers/Action.tsx b/packages/amis/src/renderers/Action.tsx index a6f28f941..720a9ed7b 100644 --- a/packages/amis/src/renderers/Action.tsx +++ b/packages/amis/src/renderers/Action.tsx @@ -707,9 +707,7 @@ export class Action extends React.Component { render() { const { type, - icon, iconClassName, - rightIcon, rightIconClassName, loadingClassName, primary, @@ -791,6 +789,8 @@ export class Action extends React.Component { }) as string; disabled = true; } + const icon = filter(this.props.icon, data); + const rightIcon = filter(this.props.rightIcon, data); const iconElement = (