diff --git a/apps/web-antd/src/adapter/component/index.ts b/apps/web-antd/src/adapter/component/index.ts index 52154db69..3f46d0031 100644 --- a/apps/web-antd/src/adapter/component/index.ts +++ b/apps/web-antd/src/adapter/component/index.ts @@ -23,6 +23,7 @@ import type { SwitchProps, TextAreaProps, TimePickerProps, + TimeRangePickerProps, TreeSelectProps, UploadProps, } from 'antdv-next'; @@ -36,6 +37,9 @@ import type { } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; +import type { TinymceProps } from '#/components/tinymce/src/type'; +import type { BaseUploadProps } from '#/components/upload/src/props'; + import { computed, defineAsyncComponent, defineComponent, h, ref } from 'vue'; import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; @@ -201,9 +205,9 @@ type StrictComponentType = export type ComponentType = BaseFormComponentType | StrictComponentType; /** - * 与 {@link ComponentType} 中注册的组件名一一对应,便于 Schema 上 `component` + `componentProps` 联动提示 + * 组件 Props 定义 */ -export interface ComponentPropsMap { +interface ComponentPropsMapDef { ApiCascader: ApiComponentSharedProps & CascaderProps; ApiSelect: ApiComponentSharedProps & SelectProps; ApiTreeSelect: ApiComponentSharedProps & TreeSelectProps; @@ -214,7 +218,9 @@ export interface ComponentPropsMap { DatePicker: DatePickerProps; DefaultButton: ButtonProps; Divider: DividerProps; + FileUpload: BaseUploadProps; IconPicker: IconPickerProps; + ImageUpload: BaseUploadProps; Input: InputProps; InputNumber: InputNumberProps; InputPassword: InputProps; @@ -224,15 +230,25 @@ export interface ComponentPropsMap { RadioGroup: RadioGroupProps; RangePicker: RangePickerProps; Rate: RateProps; + RichTextarea: TinymceProps; Select: SelectProps; Space: SpaceProps; Switch: SwitchProps; Textarea: TextAreaProps; TimePicker: TimePickerProps; + TimeRangePicker: TimeRangePickerProps; TreeSelect: TreeSelectProps; Upload: UploadProps; } +/** + * 与 {@link StrictComponentType} 一一对应,便于 Schema 上 `component` + `componentProps` 联动提示 + * 通过 mapped type 约束: StrictComponentType 新增成员但 ComponentPropsMapDef 未添加对应键时会编译报错 + */ +export type ComponentPropsMap = { + [K in StrictComponentType]: ComponentPropsMapDef[K]; +}; + async function initComponentAdapter() { const components: Record = { // 如果你的组件体积比较大,可以使用异步加载 diff --git a/apps/web-antd/src/components/tinymce/src/editor.vue b/apps/web-antd/src/components/tinymce/src/editor.vue index 9965fb610..d9273c8c7 100644 --- a/apps/web-antd/src/components/tinymce/src/editor.vue +++ b/apps/web-antd/src/components/tinymce/src/editor.vue @@ -2,6 +2,8 @@ import type { IPropTypes } from '@tinymce/tinymce-vue/lib/cjs/main/ts/components/EditorPropTypes'; import type { Editor as EditorType } from 'tinymce/tinymce'; +import type { TinymceProps } from './type'; + import type { AxiosProgressEvent, UploadResult } from '#/api'; import { computed, nextTick, ref, shallowRef, useAttrs, watch } from 'vue'; @@ -20,20 +22,12 @@ import { type InitOptions = IPropTypes['init']; -interface Props { - height?: number | string; - options?: Partial; - plugins?: string; - toolbar?: string; - disabled?: boolean; -} - defineOptions({ name: 'Tinymce', inheritAttrs: false, }); -const props = withDefaults(defineProps(), { +const props = withDefaults(defineProps(), { height: 400, options: () => ({}), plugins: defaultPlugins, @@ -165,7 +159,7 @@ const initOptions = computed((): InitOptions => { }) .catch((error) => { console.error('tinymce上传图片失败:', error); - // eslint-disable-next-line prefer-promise-reject-errors + reject({ message: error.message, remove: true }); }); }); diff --git a/apps/web-antd/src/components/tinymce/src/type.d.ts b/apps/web-antd/src/components/tinymce/src/type.d.ts new file mode 100644 index 000000000..a4e517fb4 --- /dev/null +++ b/apps/web-antd/src/components/tinymce/src/type.d.ts @@ -0,0 +1,7 @@ +export interface TinymceProps { + height?: number | string; + options?: Partial; + plugins?: string; + toolbar?: string; + disabled?: boolean; +}