Skip to content

Commit

Permalink
feat: update component adapter to use CheckboxProps and RadioProps fo…
Browse files Browse the repository at this point in the history
…r better type safety
  • Loading branch information
ArthurDarkstone committed Dec 9, 2024
1 parent 2d321bd commit afa0408
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions apps/web-ele/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { globalShareState } from '@vben/common-ui';
import { $t } from '@vben/locales';

import {
type CheckboxProps,
ElButton,
ElCheckbox,
ElCheckboxGroup,
Expand All @@ -27,6 +28,7 @@ import {
ElTimePicker,
ElTreeSelect,
ElUpload,
type RadioProps,
} from 'element-plus';

const withDefaultPlaceholder = <T extends Component>(
Expand All @@ -39,12 +41,6 @@ const withDefaultPlaceholder = <T extends Component>(
};
};

type TKV = {
[key: string]: any;
label: string;
value: any;
};

// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
export type ComponentType =
| 'Checkbox'
Expand Down Expand Up @@ -75,11 +71,8 @@ async function initComponentAdapter() {
{ ...props, attrs },
props.options
? () =>
props.options?.map((option: TKV) => {
return h(ElCheckbox, {
label: option.label,
value: option.value,
});
props.options?.map((option: CheckboxProps) => {
return h(ElCheckbox, { ...option });
})
: slots,
);
Expand All @@ -101,11 +94,8 @@ async function initComponentAdapter() {
{ ...props, attrs },
props.options
? () =>
props.options?.map((option: TKV) => {
return h(ElRadio, {
label: option.label,
value: option.value,
});
props.options?.map((option: RadioProps) => {
return h(ElRadio, { ...option });
})
: slots,
);
Expand Down

0 comments on commit afa0408

Please sign in to comment.