@@ -33,33 +42,33 @@ function lableLayoutChange(e: RadioChangeEvent) {
-
-
+
+
水平
-
-
+
+
垂直
-
-
+
+
行内
-
-
+
+
-
-
+
固定
-
-
+
+
栅格
-
-
+
+
@@ -72,35 +81,35 @@ function lableLayoutChange(e: RadioChangeEvent) {
-
+
-
+
-
-
+
+
靠左
-
-
+
+
靠右
-
-
+
+
-
-
+
+
默认
-
-
+
+
小
-
-
+
+
大
-
-
+
+
diff --git a/src/components/FormDesign/src/components/VFormDesign/modules/CollapseItem.vue b/src/components/FormDesign/src/components/VFormDesign/modules/CollapseItem.vue
index fe96239..144c43d 100644
--- a/src/components/FormDesign/src/components/VFormDesign/modules/CollapseItem.vue
+++ b/src/components/FormDesign/src/components/VFormDesign/modules/CollapseItem.vue
@@ -7,7 +7,7 @@ import { useDesign } from '@/hooks/web/useDesign'
const props = defineProps(
{
list: {
- type: Array as unknown as any[],
+ type: Array as PropType,
default: () => [],
},
handleListPush: {
diff --git a/src/components/FormDesign/src/typings/v-form-component.ts b/src/components/FormDesign/src/typings/v-form-component.ts
index 74c2a5a..4b7a821 100644
--- a/src/components/FormDesign/src/typings/v-form-component.ts
+++ b/src/components/FormDesign/src/typings/v-form-component.ts
@@ -4,12 +4,12 @@ import type { ComponentOptions } from 'vue'
import type { SelectValue } from 'ant-design-vue/lib/select'
import type { validateOptions } from 'ant-design-vue/lib/form/useForm'
import type { RuleError } from 'ant-design-vue/lib/form/interface'
+import type { FormLayout, FormProps } from 'ant-design-vue/lib/form/Form'
import type { IVFormMethods } from '../hooks/useVFormMethods'
import type { IAnyObject } from './base-type'
import type { ColEx } from '@/components/Form/src/types'
import type { FormItem } from '@/components/Form'
-type LayoutType = 'horizontal' | 'vertical' | 'inline'
type labelLayout = 'flex' | 'Grid'
export type PropsTabKey = 1 | 2 | 3
type ColSpanType = number | string
@@ -75,28 +75,25 @@ declare type namesType = string | string[]
/**
* 表单配置
*/
-export interface IFormConfig {
- // 表单项配置列表
- // schemas: IVFormComponent[];
- // 表单配置
- // config: {
- layout?: LayoutType
+export type PickAntFormConfig = Pick<
+ FormProps,
+ | 'layout'
+ | 'size'
+ | 'colon'
+ | 'labelAlign'
+ | 'disabled'
+ | 'labelCol'
+ | 'wrapperCol'
+ | 'hideRequiredMark'
+>
+
+// 使用extends 而不使用 &联结 是为了避免 type:check指令类型重载错误
+export interface IFormConfig extends PickAntFormConfig {
labelLayout?: labelLayout
labelWidth?: number
- labelCol?: Partial
- wrapperCol?: Partial
- hideRequiredMark?: boolean
- // Whether to disable
schemas: IVFormComponent[]
- disabled?: boolean
- labelAlign?: 'left' | 'right'
- // Internal component size of the form
- size?: 'default' | 'small' | 'large'
- // };
- // 当前选中项
currentItem?: IVFormComponent
activeKey?: PropsTabKey
- colon?: boolean
}
export interface AForm {
@@ -118,7 +115,7 @@ export interface AForm {
* @default 'horizontal'
* @type string
*/
- layout: 'horizontal' | 'inline' | 'vertical'
+ layout: FormLayout
/**
* The layout for input controls, same as labelCol
diff --git a/src/components/Icon/src/IconPicker.vue b/src/components/Icon/src/IconPicker.vue
index 6b5f791..0f71acc 100644
--- a/src/components/Icon/src/IconPicker.vue
+++ b/src/components/Icon/src/IconPicker.vue
@@ -9,18 +9,26 @@ import SvgIcon from './SvgIcon.vue'
import { useDesign } from '@/hooks/web/useDesign'
import { ScrollContainer } from '@/components/Container'
-import { propTypes } from '@/utils/propTypes'
import { usePagination } from '@/hooks/web/usePagination'
import { useI18n } from '@/hooks/web/useI18n'
import { copyText } from '@/utils/copyTextToClipboard'
-const props = defineProps({
- value: propTypes.string,
- width: propTypes.string.def('100%'),
- pageSize: propTypes.number.def(140),
- copy: propTypes.bool.def(true),
- mode: propTypes.oneOf(['svg', 'iconify']).def('iconify'),
+export interface Props {
+ value?: string
+ width?: string
+ pageSize?: number
+ copy?: boolean
+ mode?: 'svg' | 'iconify'
+}
+
+const props = withDefaults(defineProps(), {
+ value: '',
+ width: '100%',
+ pageSize: 140,
+ copy: false,
+ mode: 'iconify',
})
+
const emit = defineEmits(['change', 'update:value'])
function getIcons() {
@@ -36,7 +44,7 @@ function getIcons() {
}
function getSvgIcons() {
- return svgIcons.map(icon => icon.replace('icon-', ''))
+ return svgIcons.map((icon: string) => icon.replace('icon-', ''))
}
const isSvgMode = props.mode === 'svg'
@@ -87,7 +95,10 @@ function handleSearchChange(e: ChangeEvent) {
-
+
@@ -101,12 +112,10 @@ function handleSearchChange(e: ChangeEvent) {
-
diff --git a/src/directives/clickOutside.ts b/src/directives/clickOutside.ts
index 783fb5a..4265d15 100644
--- a/src/directives/clickOutside.ts
+++ b/src/directives/clickOutside.ts
@@ -17,10 +17,10 @@ const nodeList: FlushList = new Map()
let startClick: MouseEvent
if (!isServer) {
- on(document, 'mousedown', (e: MouseEvent) => (startClick = e))
- on(document, 'mouseup', (e: MouseEvent) => {
+ on(document, 'mousedown', (e: Event) => (startClick = e as MouseEvent))
+ on(document, 'mouseup', (e: Event) => {
for (const { documentHandler } of nodeList.values())
- documentHandler(e, startClick)
+ documentHandler(e as MouseEvent, startClick)
})
}
diff --git a/src/directives/repeatClick.ts b/src/directives/repeatClick.ts
index 9e9e952..98824f5 100644
--- a/src/directives/repeatClick.ts
+++ b/src/directives/repeatClick.ts
@@ -18,8 +18,8 @@ const repeatDirective: Directive = {
interval = null
}
- on(el, 'mousedown', (e: MouseEvent): void => {
- if ((e as any).button !== 0)
+ on(el, 'mousedown', (e: Event): void => {
+ if ((e as MouseEvent).button !== 0)
return
startTime = Date.now()
once(document as any, 'mouseup', clear)
diff --git a/src/directives/ripple/index.ts b/src/directives/ripple/index.ts
index 0a7deb3..8a5b8c7 100644
--- a/src/directives/ripple/index.ts
+++ b/src/directives/ripple/index.ts
@@ -29,9 +29,9 @@ const RippleDirective: Directive & RippleProto = {
const background = bg || RippleDirective.background
const zIndex = RippleDirective.zIndex
- el.addEventListener(options.event, (event: EventType) => {
+ el.addEventListener(options.event, (event: Event) => {
rippler({
- event,
+ event: event as EventType,
el,
background,
zIndex,
diff --git a/src/utils/propTypes.ts b/src/utils/propTypes.ts
index 2ea6a6a..a17209f 100644
--- a/src/utils/propTypes.ts
+++ b/src/utils/propTypes.ts
@@ -1,6 +1,6 @@
import type { CSSProperties, VNodeChild } from 'vue'
import type { VueTypeValidableDef, VueTypesInterface } from 'vue-types'
-import { createTypes } from 'vue-types'
+import { createTypes, toValidableType } from 'vue-types'
export type VueNode = VNodeChild | JSX.Element
@@ -10,7 +10,7 @@ type PropTypes = VueTypesInterface & {
// readonly trueBool: VueTypeValidableDef;
}
-const propTypes = createTypes({
+const newPropTypes = createTypes({
func: undefined,
bool: undefined,
string: undefined,
@@ -19,17 +19,18 @@ const propTypes = createTypes({
integer: undefined,
}) as PropTypes
-// propTypes.extend([
-// {
-// name: 'style',
-// getter: true,
-// type: [String, Object],
-// default: undefined
-// },
-// {
-// name: 'VNodeChild',
-// getter: true,
-// type: undefined
-// }
-// ])
+class propTypes extends newPropTypes {
+ // a native-like validator that supports the `.validable` method
+ static override get style() {
+ return toValidableType('style', {
+ type: [String, Object],
+ })
+ }
+
+ static override get VNodeChild() {
+ return toValidableType('VNodeChild', {
+ type: undefined,
+ })
+ }
+}
export { propTypes }
diff --git a/src/utils/props.ts b/src/utils/props.ts
index f30966d..71df7be 100644
--- a/src/utils/props.ts
+++ b/src/utils/props.ts
@@ -109,7 +109,7 @@ export function buildProp = never, R
: undefined
return {
- type: typeof type === 'object' && type && Object.getOwnPropertySymbols(type).includes(wrapperKey) ? type[wrapperKey] : type,
+ type: typeof type === 'object' && type && Object.getOwnPropertySymbols(type).includes(wrapperKey) && type ? type[wrapperKey] : type,
required: !!required,
default: defaultValue,
validator: _validator,
@@ -152,7 +152,8 @@ export function buildProps<
export const definePropType = (val: any) => ({ [wrapperKey]: val }) as PropWrapper
-export const keyOf = (arr: T) => Object.keys(arr as any) as Array
+export const keyOf = (arr: T) => Object.keys(arr) as Array
+
export const mutable = >(val: T) => val as Mutable
export const componentSize = ['large', 'medium', 'small', 'mini'] as const
diff --git a/src/views/base/login/useLogin.ts b/src/views/base/login/useLogin.ts
index 200c335..d4143d8 100644
--- a/src/views/base/login/useLogin.ts
+++ b/src/views/base/login/useLogin.ts
@@ -115,12 +115,12 @@ export function useFormRules(formData?: Recordable) {
return { getFormRules }
}
-function createRule(message: string) {
+function createRule(message: string): Rule[] {
return [
{
required: true,
message,
trigger: 'change',
},
- ] as RuleObject[]
+ ]
}