Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some element-plus components doesn't has props 'options' #5082

Closed
wants to merge 5 commits into from
35 changes: 30 additions & 5 deletions apps/web-ele/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ import { globalShareState } from '@vben/common-ui';
import { $t } from '@vben/locales';

import {
type CheckboxProps,
ElButton,
ElCheckbox,
ElCheckboxGroup,
ElDivider,
ElInput,
ElInputNumber,
ElNotification,
ElRadio,
ElRadioGroup,
ElSelect,
ElSelectV2,
ElSpace,
ElSwitch,
ElTimePicker,
ElTreeSelect,
ElUpload,
type RadioProps,
} from 'element-plus';

const withDefaultPlaceholder = <T extends Component>(
Expand Down Expand Up @@ -62,9 +65,20 @@ async function initComponentAdapter() {
// import('xxx').then((res) => res.Button),

Checkbox: ElCheckbox,
CheckboxGroup: ElCheckboxGroup,
CheckboxGroup: (props, { attrs, slots }) => {
return h(
ElCheckboxGroup,
{ ...props, attrs },
props.options
? () =>
props.options?.map((option: CheckboxProps) => {
return h(ElCheckbox, { ...option });
})
: slots,
);
},
// 自定义默认按钮
DefaulButton: (props, { attrs, slots }) => {
DefaultButton: (props, { attrs, slots }) => {
return h(ElButton, { ...props, attrs, type: 'info' }, slots);
},
// 自定义主要按钮
Expand All @@ -74,8 +88,19 @@ async function initComponentAdapter() {
Divider: ElDivider,
Input: withDefaultPlaceholder(ElInput, 'input'),
InputNumber: withDefaultPlaceholder(ElInputNumber, 'input'),
RadioGroup: ElRadioGroup,
Select: withDefaultPlaceholder(ElSelect, 'select'),
RadioGroup: (props, { attrs, slots }) => {
return h(
ElRadioGroup,
{ ...props, attrs },
props.options
? () =>
props.options?.map((option: RadioProps) => {
return h(ElRadio, { ...option });
})
: slots,
);
},
Select: withDefaultPlaceholder(ElSelectV2, 'select'),
Space: ElSpace,
Switch: ElSwitch,
TimePicker: ElTimePicker,
Expand Down
Loading