mirror of
https://github.com/imdap/ruoyi-plus-vben5.git
synced 2026-05-12 06:02:12 +08:00
refactor: 简化 componentProps 回调的类型写法
This commit is contained in:
@@ -27,26 +27,16 @@ import type { Component } from 'vue';
|
|||||||
import type {
|
import type {
|
||||||
ApiComponentSharedProps,
|
ApiComponentSharedProps,
|
||||||
VbenFormSchema as CoreFormSchema,
|
VbenFormSchema as CoreFormSchema,
|
||||||
|
FormActions,
|
||||||
IconPickerProps,
|
IconPickerProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import type { ComponentType } from './component';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
type ComponentPropsFnArgs = Parameters<
|
|
||||||
Extract<
|
|
||||||
NonNullable<CoreFormSchema<ComponentType>['componentProps']>,
|
|
||||||
(...args: any) => any
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用适配器里为各 `component` 声明的 Props 类型 `P`;
|
|
||||||
* 与 `Record<string, any>` 相交以兼容核心库 `MaybeComponentProps` 的索引签名。
|
|
||||||
*/
|
|
||||||
type ComponentProps<P> =
|
type ComponentProps<P> =
|
||||||
| ((
|
| ((
|
||||||
value: ComponentPropsFnArgs[0],
|
value: Partial<Record<string, any>>,
|
||||||
actions: ComponentPropsFnArgs[1],
|
actions: FormActions,
|
||||||
) => P & Record<string, any>)
|
) => P & Record<string, any>)
|
||||||
| (P & Record<string, any>);
|
| (P & Record<string, any>);
|
||||||
|
|
||||||
|
|||||||
@@ -27,26 +27,16 @@ import type { Component } from 'vue';
|
|||||||
import type {
|
import type {
|
||||||
ApiComponentSharedProps,
|
ApiComponentSharedProps,
|
||||||
VbenFormSchema as CoreFormSchema,
|
VbenFormSchema as CoreFormSchema,
|
||||||
|
FormActions,
|
||||||
IconPickerProps,
|
IconPickerProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import type { ComponentType } from './component';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
type ComponentPropsFnArgs = Parameters<
|
|
||||||
Extract<
|
|
||||||
NonNullable<CoreFormSchema<ComponentType>['componentProps']>,
|
|
||||||
(...args: any) => any
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用适配器里为各 `component` 声明的 Props 类型 `P`;
|
|
||||||
* 与 `Record<string, any>` 相交以兼容核心库 `MaybeComponentProps` 的索引签名。
|
|
||||||
*/
|
|
||||||
type ComponentProps<P> =
|
type ComponentProps<P> =
|
||||||
| ((
|
| ((
|
||||||
value: ComponentPropsFnArgs[0],
|
value: Partial<Record<string, any>>,
|
||||||
actions: ComponentPropsFnArgs[1],
|
actions: FormActions,
|
||||||
) => P & Record<string, any>)
|
) => P & Record<string, any>)
|
||||||
| (P & Record<string, any>);
|
| (P & Record<string, any>);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import type { Component } from 'vue';
|
|||||||
import type {
|
import type {
|
||||||
ApiComponentSharedProps,
|
ApiComponentSharedProps,
|
||||||
VbenFormSchema as CoreFormSchema,
|
VbenFormSchema as CoreFormSchema,
|
||||||
|
FormActions,
|
||||||
IconPickerProps,
|
IconPickerProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
@@ -27,21 +28,10 @@ import type { ComponentType } from './component';
|
|||||||
type ElTreeSelectSchemaProps = InstanceType<typeof ElTreeSelect>['$props'];
|
type ElTreeSelectSchemaProps = InstanceType<typeof ElTreeSelect>['$props'];
|
||||||
type ElTimePickerSchemaProps = InstanceType<typeof ElTimePicker>['$props'];
|
type ElTimePickerSchemaProps = InstanceType<typeof ElTimePicker>['$props'];
|
||||||
|
|
||||||
type ComponentPropsFnArgs = Parameters<
|
|
||||||
Extract<
|
|
||||||
NonNullable<CoreFormSchema<ComponentType>['componentProps']>,
|
|
||||||
(...args: any) => any
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用适配器里为各 `component` 声明的 Props 类型 `P`;
|
|
||||||
* 与 `Record<string, any>` 相交以兼容核心库 `MaybeComponentProps` 的索引签名。
|
|
||||||
*/
|
|
||||||
type ComponentProps<P> =
|
type ComponentProps<P> =
|
||||||
| ((
|
| ((
|
||||||
value: ComponentPropsFnArgs[0],
|
value: Partial<Record<string, any>>,
|
||||||
actions: ComponentPropsFnArgs[1],
|
actions: FormActions,
|
||||||
) => P & Record<string, any>)
|
) => P & Record<string, any>)
|
||||||
| (P & Record<string, any>);
|
| (P & Record<string, any>);
|
||||||
|
|
||||||
|
|||||||
@@ -19,26 +19,16 @@ import type { Component } from 'vue';
|
|||||||
import type {
|
import type {
|
||||||
ApiComponentSharedProps,
|
ApiComponentSharedProps,
|
||||||
VbenFormSchema as CoreFormSchema,
|
VbenFormSchema as CoreFormSchema,
|
||||||
|
FormActions,
|
||||||
IconPickerProps,
|
IconPickerProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import type { ComponentType } from './component';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
type ComponentPropsFnArgs = Parameters<
|
|
||||||
Extract<
|
|
||||||
NonNullable<CoreFormSchema<ComponentType>['componentProps']>,
|
|
||||||
(...args: any) => any
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用适配器里为各 `component` 声明的 Props 类型 `P`;
|
|
||||||
* 与 `Record<string, any>` 相交以兼容核心库 `MaybeComponentProps` 的索引签名。
|
|
||||||
*/
|
|
||||||
type ComponentProps<P> =
|
type ComponentProps<P> =
|
||||||
| ((
|
| ((
|
||||||
value: ComponentPropsFnArgs[0],
|
value: Partial<Record<string, any>>,
|
||||||
actions: ComponentPropsFnArgs[1],
|
actions: FormActions,
|
||||||
) => P & Record<string, any>)
|
) => P & Record<string, any>)
|
||||||
| (P & Record<string, any>);
|
| (P & Record<string, any>);
|
||||||
|
|
||||||
|
|||||||
@@ -25,26 +25,16 @@ import type { Component } from 'vue';
|
|||||||
import type {
|
import type {
|
||||||
ApiComponentSharedProps,
|
ApiComponentSharedProps,
|
||||||
VbenFormSchema as CoreFormSchema,
|
VbenFormSchema as CoreFormSchema,
|
||||||
|
FormActions,
|
||||||
IconPickerProps,
|
IconPickerProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import type { ComponentType } from './component';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
type ComponentPropsFnArgs = Parameters<
|
|
||||||
Extract<
|
|
||||||
NonNullable<CoreFormSchema<ComponentType>['componentProps']>,
|
|
||||||
(...args: any) => any
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用适配器里为各 `component` 声明的 Props 类型 `P`;
|
|
||||||
* 与 `Record<string, any>` 相交以兼容核心库 `MaybeComponentProps` 的索引签名。
|
|
||||||
*/
|
|
||||||
type ComponentProps<P> =
|
type ComponentProps<P> =
|
||||||
| ((
|
| ((
|
||||||
value: ComponentPropsFnArgs[0],
|
value: Partial<Record<string, any>>,
|
||||||
actions: ComponentPropsFnArgs[1],
|
actions: FormActions,
|
||||||
) => P & Record<string, any>)
|
) => P & Record<string, any>)
|
||||||
| (P & Record<string, any>);
|
| (P & Record<string, any>);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export { setupVbenForm } from './config';
|
|||||||
export type {
|
export type {
|
||||||
BaseFormComponentType,
|
BaseFormComponentType,
|
||||||
ExtendedFormApi,
|
ExtendedFormApi,
|
||||||
|
FormActions,
|
||||||
VbenFormProps,
|
VbenFormProps,
|
||||||
FormSchema as VbenFormSchema,
|
FormSchema as VbenFormSchema,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|||||||
@@ -27,26 +27,16 @@ import type { Component } from 'vue';
|
|||||||
import type {
|
import type {
|
||||||
ApiComponentSharedProps,
|
ApiComponentSharedProps,
|
||||||
VbenFormSchema as CoreFormSchema,
|
VbenFormSchema as CoreFormSchema,
|
||||||
|
FormActions,
|
||||||
IconPickerProps,
|
IconPickerProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import type { ComponentType } from './component';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
type ComponentPropsFnArgs = Parameters<
|
|
||||||
Extract<
|
|
||||||
NonNullable<CoreFormSchema<ComponentType>['componentProps']>,
|
|
||||||
(...args: any) => any
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用适配器里为各 `component` 声明的 Props 类型 `P`;
|
|
||||||
* 与 `Record<string, any>` 相交以兼容核心库 `MaybeComponentProps` 的索引签名。
|
|
||||||
*/
|
|
||||||
type ComponentProps<P> =
|
type ComponentProps<P> =
|
||||||
| ((
|
| ((
|
||||||
value: ComponentPropsFnArgs[0],
|
value: Partial<Record<string, any>>,
|
||||||
actions: ComponentPropsFnArgs[1],
|
actions: FormActions,
|
||||||
) => P & Record<string, any>)
|
) => P & Record<string, any>)
|
||||||
| (P & Record<string, any>);
|
| (P & Record<string, any>);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user