feat: type抽离

This commit is contained in:
hongxinzz
2022-10-09 17:12:03 +08:00
parent a62929a8da
commit 8b4fa1aa21
62 changed files with 223 additions and 172 deletions

View File

@@ -1,3 +0,0 @@
declare interface ConfigGlobalTypes {
size?: ElememtPlusSize
}

View File

@@ -1,7 +0,0 @@
declare type contextMenuSchema = {
disabled?: boolean
divided?: boolean
icon?: string
label: string
command?: (item: contextMenuSchema) => viod
}

View File

@@ -1,11 +0,0 @@
declare interface DescriptionsSchema {
span?: number // 占多少分
field: string // 字段名
label?: string // label名
width?: string | number
minWidth?: string | number
align?: 'left' | 'center' | 'right'
labelAlign?: 'left' | 'center' | 'right'
className?: string
labelClassName?: string
}

View File

@@ -1,97 +0,0 @@
import type { CSSProperties } from 'vue'
declare global {
declare type ComponentName =
| 'Radio'
| 'RadioButton'
| 'Checkbox'
| 'CheckboxButton'
| 'Input'
| 'Autocomplete'
| 'InputNumber'
| 'Select'
| 'Cascader'
| 'Switch'
| 'Slider'
| 'TimePicker'
| 'DatePicker'
| 'Rate'
| 'ColorPicker'
| 'Transfer'
| 'Divider'
| 'TimeSelect'
| 'SelectV2'
| 'InputPassword'
| 'Editor'
declare type ColProps = {
span?: number
xs?: number
sm?: number
md?: number
lg?: number
xl?: number
tag?: string
}
declare type FormValueType = string | number | string[] | number[] | boolean | undefined | null
declare type FormItemProps = {
labelWidth?: string | number
required?: boolean
rules?: Recordable
error?: string
showMessage?: boolean
inlineMessage?: boolean
style?: CSSProperties
}
declare type ComponentOptions = {
label?: string
value?: FormValueType
disabled?: boolean
key?: string | number
children?: ComponentOptions[]
options?: ComponentOptions[]
} & Recordable
declare type ComponentOptionsAlias = {
labelField?: string
valueField?: string
}
declare type ComponentProps = {
optionsAlias?: ComponentOptionsAlias
options?: ComponentOptions[]
optionsSlot?: boolean
} & Recordable
declare type FormSchema = {
// 唯一值
field: string
// 标题
label?: string
// 提示
labelMessage?: string
// col组件属性
colProps?: ColProps
// 表单组件属性slots对应的是表单组件的插槽规则${field}-xxx具体可以查看element-plus文档
componentProps?: { slots?: Recordable } & ComponentProps
// formItem组件属性
formItemProps?: FormItemProps
// 渲染的组件
component?: ComponentName
// 初始值
value?: FormValueType
// 是否隐藏
hidden?: boolean
// 远程加载下拉项
api?: <T = any>() => AxiosPromise<T>
}
declare type FormSetPropsType = {
field: string
path: string
value: any
}
}

View File

@@ -1,5 +0,0 @@
declare interface IconTypes {
size?: number
color?: string
icon: string
}

View File

@@ -1,4 +0,0 @@
declare interface TipSchema {
label: string
keys?: string[]
}

View File

@@ -1,10 +0,0 @@
declare interface Language {
el: Recordable
name: string
}
declare interface LocaleDropdownType {
lang: LocaleType
name?: string
elLocale?: Language
}

View File

@@ -1,9 +0,0 @@
declare interface QrcodeLogo {
src?: string
logoSize?: number
bgColor?: string
borderSize?: number
crossOrigin?: string
borderRadius?: number
logoRadius?: number
}

View File

@@ -1,36 +0,0 @@
declare type TableColumn = {
field: string
label?: string
children?: TableColumn[]
} & Recordable
declare type TableSlotDefault = {
row: Recordable
column: TableColumn
$index: number
} & Recordable
declare interface Pagination {
small?: boolean
background?: boolean
pageSize?: number
defaultPageSize?: number
total?: number
pageCount?: number
pagerCount?: number
currentPage?: number
defaultCurrentPage?: number
layout?: string
pageSizes?: number[]
popperClass?: string
prevText?: string
nextText?: string
disabled?: boolean
hideOnSinglePage?: boolean
}
declare interface TableSetPropsType {
field: string
path: string
value: any
}

77
types/global.d.ts vendored
View File

@@ -1,40 +1,39 @@
declare interface Fn<T = any> {
(...arg: T[]): T
}
declare type Nullable<T> = T | null
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
declare type ElememtPlusSize = 'default' | 'small' | 'large'
declare type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
declare type ComponentRef<T> = InstanceType<T>
declare type LocaleType = 'zh-CN' | 'en'
declare type AxiosHeaders =
| 'application/json'
| 'application/x-www-form-urlencoded'
| 'multipart/form-data'
declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
declare interface AxiosConfig {
params?: any
data?: any
url?: string
method?: AxiosMethod
headersType?: string
responseType?: AxiosResponseType
}
declare interface IResponse<T = any> {
code: string
data: T extends any ? T : T & any
import type { CSSProperties } from 'vue'
declare global {
declare interface Fn<T = any> {
(...arg: T[]): T
}
declare type Nullable<T> = T | null
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
declare type ComponentRef<T> = InstanceType<T>
declare type LocaleType = 'zh-CN' | 'en'
declare type AxiosHeaders =
| 'application/json'
| 'application/x-www-form-urlencoded'
| 'multipart/form-data'
declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
declare interface AxiosConfig {
params?: any
data?: any
url?: string
method?: AxiosMethod
headersType?: string
responseType?: AxiosResponseType
}
declare interface IResponse<T = any> {
code: string
data: T extends any ? T : T & any
}
}