diff --git a/src/control/context-menu/context-menu.scss b/src/control/context-menu/context-menu.scss index e962393fd037a45ffef32eec073b4d466b00b281..6c07c346fd55f5114e8487bbf9c1e36242160da5 100644 --- a/src/control/context-menu/context-menu.scss +++ b/src/control/context-menu/context-menu.scss @@ -69,10 +69,25 @@ popover-button-hover-bg: getCssVar(color, bg, 0), .#{bem('context-menu','action-content-icon')} { margin-right: 6px; } + + .#{bem('context-menu','action-content-group-caption')} { + margin-right: getCssVar('spacing', 'base-loose'); + } + + .#{bem('context-menu','action-content-group-icon')} { + position: absolute; + right: getCssVar('spacing', 'base-loose'); + font-size: getCssVar('font-size', 'header-6'); + } } @include e(separator) { margin: 0; + + &.el-divider--horizontal { + width: calc(100% - 2 * getCssVar('spacing', 'base-loose')); + margin: getCssVar('spacing', 'extra-tight') getCssVar('spacing', 'base-loose'); + } } } diff --git a/src/control/context-menu/context-menu.tsx b/src/control/context-menu/context-menu.tsx index 623b2d1b04010f338c5c4947161e15fe14c63a84..9163a181fc2c49f1a61306c68f62f45e6a4cc8db 100644 --- a/src/control/context-menu/context-menu.tsx +++ b/src/control/context-menu/context-menu.tsx @@ -62,9 +62,12 @@ export const ContextMenuControl = defineComponent({ const popoverVisible = ref(false); - if (actionDetails) { - // 转换多语言 - actionDetails?.forEach(detail => { + // 转换多语言 + const transformLanguage = (items?: IDETBUIActionItem[]) => { + if (!Array.isArray(items)) { + return; + } + items.forEach(detail => { if (detail.capLanguageRes && detail.capLanguageRes.lanResTag) { detail.caption = ibiz.i18n.t( detail.capLanguageRes.lanResTag, @@ -77,11 +80,18 @@ export const ContextMenuControl = defineComponent({ detail.tooltip, ); } + transformLanguage(detail.detoolbarItems); }); + }; + + if (actionDetails) { + // 转换多语言 + transformLanguage(actionDetails); // 根据level分组 actionDetails.forEach(detail => { if ( + !detail.actionLevel || props.groupLevelKeys.findIndex( item => item === detail.actionLevel, ) !== -1 @@ -133,6 +143,7 @@ export const ContextMenuControl = defineComponent({ dropdownRef.value.handleClose(); } e.stopPropagation(); + popoverVisible.value = false; emit('action-click', detail, e); }; @@ -164,7 +175,16 @@ export const ContextMenuControl = defineComponent({ const renderActions = (items: IDETBUIActionItem[], isExpand = true) => { return items.map(detail => { - if (this.c.state.buttonsState[detail.id!]?.visible) { + if (!this.c.state.buttonsState[detail.id!]?.visible) { + return null; + } + if (detail.itemType === 'SEPERATOR') { + return renderDivider(isExpand); + } + if ( + detail.itemType === 'DEUIACTION' || + (detail.itemType === 'ITEMS' && !detail.detoolbarItems?.length) + ) { return [ (detail as IAppDEUIActionGroupDetail).addSeparator && renderDivider(isExpand), @@ -196,6 +216,62 @@ export const ContextMenuControl = defineComponent({ , ]; } + if (detail.itemType === 'ITEMS') { + return ( + + {{ + reference: () => { + return [ + (detail as IAppDEUIActionGroupDetail).addSeparator && + renderDivider(isExpand), + => + this.handleClick(detail, e) + } + title={detail.tooltip} + disabled={this.c.state.buttonsState[detail.id!].disabled} + class={this.calcActionItemClass(detail)} + > +
+ {detail.showIcon && detail.sysImage && ( +
+ +
+ )} + + {detail.showCaption ? ( +
+ {detail.caption} +
+ ) : ( + '' + )} + +
+
, + ]; + }, + default: () => { + return renderActions(detail.detoolbarItems || [], isExpand); + }, + }} +
+ ); + } return null; }); }; @@ -234,6 +310,7 @@ export const ContextMenuControl = defineComponent({ v-model:visible={this.popoverVisible} popper-class={this.ns.e('popover')} virtual-triggering + transition='none' > {renderActions(this.groupDetails, false)} ,