Merge pull request #180 from hongxinzz/dev

feat: type抽离
This commit is contained in:
Archer 2022-10-09 17:42:33 +08:00 committed by GitHub
commit 3708c45789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 258 additions and 164 deletions

View File

@ -2,6 +2,33 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [1.6.6](https://github.com/kailong321200875/vue-element-plus-admin/compare/v1.6.5...v1.6.6) (2022-10-09)
### Bug Fixes
* table search params ([a62929a](https://github.com/kailong321200875/vue-element-plus-admin/commit/a62929a8dac21028d3dd1cddf98189492c33b093))
## [1.6.5](https://github.com/kailong321200875/vue-element-plus-admin/compare/v1.6.4...v1.6.5) (2022-10-08)
### Bug Fixes
* The attribute of option does not work ([d946920](https://github.com/kailong321200875/vue-element-plus-admin/commit/d946920e61ed81beacf9f1f8be7ee1f50505f64d))
### Performance Improvements
* perf store ([d416178](https://github.com/kailong321200875/vue-element-plus-admin/commit/d416178d69ca6100be4b635922b1a22d27629f08))
* token test ([b320e65](https://github.com/kailong321200875/vue-element-plus-admin/commit/b320e658d1a559a6eaebdf374d63649c223c2ecd))
## [1.6.4](https://github.com/kailong321200875/vue-element-plus-admin/compare/v1.6.3...v1.6.4) (2022-09-21)
### Bug Fixes
* fix bug ([da39f3b](https://github.com/kailong321200875/vue-element-plus-admin/commit/da39f3bc904ca2d80f432a31709725f9a57deb19))
## [1.6.3](https://github.com/kailong321200875/vue-element-plus-admin/compare/v1.6.2...v1.6.3) (2022-08-20) ## [1.6.3](https://github.com/kailong321200875/vue-element-plus-admin/compare/v1.6.2...v1.6.3) (2022-08-20)

View File

@ -215,6 +215,13 @@ Support modern browsers, not IE
</a> </a>
</td></tr> </td></tr>
<tr> <tr>
<td align="center">
<a href="https://github.com/hongxinzz">
<img src="https://avatars.githubusercontent.com/u/31195324?v=4" width="100;" alt="hongxinzz"/>
<br />
<sub><b>Hongxinzz</b></sub>
</a>
</td>
<td align="center"> <td align="center">
<a href="https://github.com/amifed"> <a href="https://github.com/amifed">
<img src="https://avatars.githubusercontent.com/u/36906371?v=4" width="100;" alt="amifed"/> <img src="https://avatars.githubusercontent.com/u/36906371?v=4" width="100;" alt="amifed"/>

View File

@ -215,6 +215,13 @@ pnpm run build:pro
</a> </a>
</td></tr> </td></tr>
<tr> <tr>
<td align="center">
<a href="https://github.com/hongxinzz">
<img src="https://avatars.githubusercontent.com/u/31195324?v=4" width="100;" alt="hongxinzz"/>
<br />
<sub><b>Hongxinzz</b></sub>
</a>
</td>
<td align="center"> <td align="center">
<a href="https://github.com/amifed"> <a href="https://github.com/amifed">
<img src="https://avatars.githubusercontent.com/u/36906371?v=4" width="100;" alt="amifed"/> <img src="https://avatars.githubusercontent.com/u/36906371?v=4" width="100;" alt="amifed"/>

View File

@ -1,6 +1,6 @@
{ {
"name": "vue-element-plus-admin", "name": "vue-element-plus-admin",
"version": "1.6.3", "version": "1.6.6",
"description": "一套基于vue3、element-plus、typesScript、vite3的后台集成方案。", "description": "一套基于vue3、element-plus、typesScript、vite3的后台集成方案。",
"author": "Archer <502431556@qq.com>", "author": "Archer <502431556@qq.com>",
"private": false, "private": false,

View File

@ -7,13 +7,14 @@ import { useWindowSize } from '@vueuse/core'
import { useAppStore } from '@/store/modules/app' import { useAppStore } from '@/store/modules/app'
import { setCssVar } from '@/utils' import { setCssVar } from '@/utils'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { ElementPlusSize } from '@/types/elementPlus'
const { variables } = useDesign() const { variables } = useDesign()
const appStore = useAppStore() const appStore = useAppStore()
const props = defineProps({ const props = defineProps({
size: propTypes.oneOf<ElememtPlusSize[]>(['default', 'small', 'large']).def('default') size: propTypes.oneOf<ElementPlusSize[]>(['default', 'small', 'large']).def('default')
}) })
provide('configGlobal', props) provide('configGlobal', props)

View File

@ -4,7 +4,7 @@ import { PropType, ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import type { RouteLocationNormalizedLoaded } from 'vue-router' import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { contextMenuSchema } from '../../../types/contextMenu'
const { getPrefixCls } = useDesign() const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('context-menu') const prefixCls = getPrefixCls('context-menu')

View File

@ -4,6 +4,7 @@ import { useDesign } from '@/hooks/web/useDesign'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { ref, unref, PropType, computed, useAttrs } from 'vue' import { ref, unref, PropType, computed, useAttrs } from 'vue'
import { useAppStore } from '@/store/modules/app' import { useAppStore } from '@/store/modules/app'
import { DescriptionsSchema } from '@/types/descriptions'
const appStore = useAppStore() const appStore = useAppStore()

View File

@ -1,5 +1,6 @@
import Form from './src/Form.vue' import Form from './src/Form.vue'
import { ElForm } from 'element-plus' import { ElForm } from 'element-plus'
import { FormSchema, FormSetPropsType } from '@/types/form'
export interface FormExpose { export interface FormExpose {
setValues: (data: Recordable) => void setValues: (data: Recordable) => void

View File

@ -20,6 +20,7 @@ import { findIndex } from '@/utils'
import { set } from 'lodash-es' import { set } from 'lodash-es'
import { FormProps } from './types' import { FormProps } from './types'
import { Icon } from '@/components/Icon' import { Icon } from '@/components/Icon'
import { FormSchema, FormSetPropsType } from '@/types/form'
const { getPrefixCls } = useDesign() const { getPrefixCls } = useDesign()

View File

@ -20,6 +20,7 @@ import {
} from 'element-plus' } from 'element-plus'
import { InputPassword } from '@/components/InputPassword' import { InputPassword } from '@/components/InputPassword'
import { Editor } from '@/components/Editor' import { Editor } from '@/components/Editor'
import { ComponentName } from '@/types/components'
const componentMap: Recordable<Component, ComponentName> = { const componentMap: Recordable<Component, ComponentName> = {
Radio: ElRadioGroup, Radio: ElRadioGroup,

View File

@ -1,3 +1,4 @@
import { FormSchema } from '@/types/form'
import { ElCheckbox, ElCheckboxButton } from 'element-plus' import { ElCheckbox, ElCheckboxButton } from 'element-plus'
import { defineComponent } from 'vue' import { defineComponent } from 'vue'

View File

@ -1,3 +1,4 @@
import { FormSchema } from '@/types/form'
import { ElRadio, ElRadioButton } from 'element-plus' import { ElRadio, ElRadioButton } from 'element-plus'
import { defineComponent } from 'vue' import { defineComponent } from 'vue'

View File

@ -1,6 +1,8 @@
import { ElOption, ElOptionGroup } from 'element-plus' import { ElOption, ElOptionGroup } from 'element-plus'
import { getSlot } from '@/utils/tsxHelper' import { getSlot } from '@/utils/tsxHelper'
import { Slots } from 'vue' import { Slots } from 'vue'
import { FormSchema } from '@/types/form'
import { ComponentOptions } from '@/types/components'
export const useRenderSelect = (slots: Slots) => { export const useRenderSelect = (slots: Slots) => {
// 渲染 select options // 渲染 select options

View File

@ -2,6 +2,7 @@ import { useI18n } from '@/hooks/web/useI18n'
import type { Slots } from 'vue' import type { Slots } from 'vue'
import { getSlot } from '@/utils/tsxHelper' import { getSlot } from '@/utils/tsxHelper'
import { PlaceholderMoel } from './types' import { PlaceholderMoel } from './types'
import { FormSchema } from '@/types/form'
const { t } = useI18n() const { t } = useI18n()

View File

@ -1,3 +1,5 @@
import { FormSchema } from '@/types/form'
export interface PlaceholderMoel { export interface PlaceholderMoel {
placeholder?: string placeholder?: string
startPlaceholder?: string startPlaceholder?: string

View File

@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { PropType } from 'vue' import { PropType } from 'vue'
import { Highlight } from '@//components/Highlight' import { Highlight } from '@/components/Highlight'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { TipSchema } from '@/types/infoTip';
const { getPrefixCls } = useDesign() const { getPrefixCls } = useDesign()

View File

@ -6,6 +6,7 @@ import { cloneDeep } from 'lodash-es'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { isString } from '@/utils/is' import { isString } from '@/utils/is'
import { QrcodeLogo } from '@/types/qrcode'
const props = defineProps({ const props = defineProps({
// img canvas,imglogo // img canvas,imglogo

View File

@ -7,6 +7,7 @@ import { useI18n } from '@/hooks/web/useI18n'
import { useForm } from '@/hooks/web/useForm' import { useForm } from '@/hooks/web/useForm'
import { findIndex } from '@/utils' import { findIndex } from '@/utils'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import { FormSchema } from '@/types/form'
const { t } = useI18n() const { t } = useI18n()

View File

@ -5,6 +5,7 @@ import { useAppStore } from '@/store/modules/app'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { ElementPlusSize } from '@/types/elementPlus'
const { getPrefixCls } = useDesign() const { getPrefixCls } = useDesign()
@ -20,7 +21,7 @@ const appStore = useAppStore()
const sizeMap = computed(() => appStore.sizeMap) const sizeMap = computed(() => appStore.sizeMap)
const setCurrentSize = (size: ElememtPlusSize) => { const setCurrentSize = (size: ElementPlusSize) => {
appStore.setCurrentSize(size) appStore.setCurrentSize(size)
} }
</script> </script>

View File

@ -1,5 +1,6 @@
import Table from './src/Table.vue' import Table from './src/Table.vue'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import { TableSetPropsType } from '@/types/table'
export interface TableExpose { export interface TableExpose {
setProps: (props: Recordable) => void setProps: (props: Recordable) => void

View File

@ -6,6 +6,7 @@ import { setIndex } from './helper'
import { getSlot } from '@/utils/tsxHelper' import { getSlot } from '@/utils/tsxHelper'
import type { TableProps } from './types' import type { TableProps } from './types'
import { set } from 'lodash-es' import { set } from 'lodash-es'
import { TableColumn, TableSlotDefault, Pagination, TableSetPropsType } from '../../../types/table'
export default defineComponent({ export default defineComponent({
name: 'Table', name: 'Table',

View File

@ -1,3 +1,5 @@
import { Pagination, TableColumn } from '@/types/table'
export type TableProps = { export type TableProps = {
pageSize?: number pageSize?: number
currentPage?: number currentPage?: number

View File

@ -1,3 +1,4 @@
import { ConfigGlobalTypes } from '@/types/configGlobal'
import { inject } from 'vue' import { inject } from 'vue'
export const useConfigGlobal = () => { export const useConfigGlobal = () => {

View File

@ -4,6 +4,9 @@ import { findIndex } from '@/utils'
import { useDictStoreWithOut } from '@/store/modules/dict' import { useDictStoreWithOut } from '@/store/modules/dict'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import type { AxiosPromise } from 'axios' import type { AxiosPromise } from 'axios'
import { FormSchema } from '@/types/form'
import { TableColumn } from '@/types/table'
import { DescriptionsSchema } from '@/types/descriptions'
export type CrudSchema = Omit<TableColumn, 'children'> & { export type CrudSchema = Omit<TableColumn, 'children'> & {
search?: CrudSearchParams search?: CrudSearchParams

View File

@ -2,6 +2,7 @@ import type { Form, FormExpose } from '@/components/Form'
import type { ElForm } from 'element-plus' import type { ElForm } from 'element-plus'
import { ref, unref, nextTick } from 'vue' import { ref, unref, nextTick } from 'vue'
import type { FormProps } from '@/components/Form/src/types' import type { FormProps } from '@/components/Form/src/types'
import { FormSchema, FormSetPropsType } from '@/types/form'
export const useForm = (props?: FormProps) => { export const useForm = (props?: FormProps) => {
// From实例 // From实例

View File

@ -1,6 +1,7 @@
import { h } from 'vue' import { h } from 'vue'
import type { VNode } from 'vue' import type { VNode } from 'vue'
import { Icon } from '@/components/Icon' import { Icon } from '@/components/Icon'
import { IconTypes } from '@/types/icon'
export const useIcon = (props: IconTypes): VNode => { export const useIcon = (props: IconTypes): VNode => {
return h(Icon, props) return h(Icon, props)

View File

@ -4,6 +4,7 @@ import { ref, reactive, watch, computed, unref, nextTick } from 'vue'
import { get } from 'lodash-es' import { get } from 'lodash-es'
import type { TableProps } from '@/components/Table/src/types' import type { TableProps } from '@/components/Table/src/types'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { TableSetPropsType } from '@/types/table'
const { t } = useI18n() const { t } = useI18n()

View File

@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { store } from '../index' import { store } from '../index'
import { setCssVar, humpToUnderline } from '@/utils' import { setCssVar, humpToUnderline } from '@/utils'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { ElementPlusSize } from '@/types/elementPlus'
import { useCache } from '@/hooks/web/useCache' import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache() const { wsCache } = useCache()
@ -169,10 +170,10 @@ export const useAppStore = defineStore('app', {
getIsDark(): boolean { getIsDark(): boolean {
return this.isDark return this.isDark
}, },
getCurrentSize(): ElememtPlusSize { getCurrentSize(): ElementPlusSize {
return this.currentSize return this.currentSize
}, },
getSizeMap(): ElememtPlusSize[] { getSizeMap(): ElementPlusSize[] {
return this.sizeMap return this.sizeMap
}, },
getMobile(): boolean { getMobile(): boolean {
@ -254,7 +255,7 @@ export const useAppStore = defineStore('app', {
} }
wsCache.set('isDark', this.isDark) wsCache.set('isDark', this.isDark)
}, },
setCurrentSize(currentSize: ElememtPlusSize) { setCurrentSize(currentSize: ElementPlusSize) {
this.currentSize = currentSize this.currentSize = currentSize
wsCache.set('currentSize', this.currentSize) wsCache.set('currentSize', this.currentSize)
}, },

View File

@ -3,6 +3,7 @@ import { store } from '../index'
import zhCn from 'element-plus/es/locale/lang/zh-cn' import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en' import en from 'element-plus/es/locale/lang/en'
import { useCache } from '@/hooks/web/useCache' import { useCache } from '@/hooks/web/useCache'
import { LocaleDropdownType } from '@/types/localeDropdown'
const { wsCache } = useCache() const { wsCache } = useCache()

52
src/types/components.d.ts vendored Normal file
View File

@ -0,0 +1,52 @@
export type ComponentName =
| 'Radio'
| 'RadioButton'
| 'Checkbox'
| 'CheckboxButton'
| 'Input'
| 'Autocomplete'
| 'InputNumber'
| 'Select'
| 'Cascader'
| 'Switch'
| 'Slider'
| 'TimePicker'
| 'DatePicker'
| 'Rate'
| 'ColorPicker'
| 'Transfer'
| 'Divider'
| 'TimeSelect'
| 'SelectV2'
| 'InputPassword'
| 'Editor'
export type ColProps = {
span?: number
xs?: number
sm?: number
md?: number
lg?: number
xl?: number
tag?: string
}
export type ComponentOptions = {
label?: string
value?: FormValueType
disabled?: boolean
key?: string | number
children?: ComponentOptions[]
options?: ComponentOptions[]
} & Recordable
export type ComponentOptionsAlias = {
labelField?: string
valueField?: string
}
export type ComponentProps = {
optionsAlias?: ComponentOptionsAlias
options?: ComponentOptions[]
optionsSlot?: boolean
} & Recordable

4
src/types/configGlobal.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import { ElementPlusSize } from './elementPlus'
export interface ConfigGlobalTypes {
size?: ElementPlusSize
}

7
src/types/contextMenu.d.ts vendored Normal file
View File

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

View File

@ -1,4 +1,4 @@
declare interface DescriptionsSchema { export interface DescriptionsSchema {
span?: number // 占多少分 span?: number // 占多少分
field: string // 字段名 field: string // 字段名
label?: string // label名 label?: string // label名

3
src/types/elementPlus.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export type ElementPlusSize = 'default' | 'small' | 'large'
export type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'

45
src/types/form.d.ts vendored Normal file
View File

@ -0,0 +1,45 @@
import type { CSSProperties } from 'vue'
import { ColProps, ComponentProps, ComponentName } from '@/types/components'
import { FormValueType, FormValueType } from '@/types/form'
import type { AxiosPromise } from 'axios'
export type FormSetPropsType = {
field: string
path: string
value: any
}
export type FormValueType = string | number | string[] | number[] | boolean | undefined | null
export type FormItemProps = {
labelWidth?: string | number
required?: boolean
rules?: Recordable
error?: string
showMessage?: boolean
inlineMessage?: boolean
style?: CSSProperties
}
export 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>
}

View File

@ -1,4 +1,4 @@
declare interface IconTypes { export interface IconTypes {
size?: number size?: number
color?: string color?: string
icon: string icon: string

View File

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

View File

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

View File

@ -1,4 +1,4 @@
declare interface QrcodeLogo { export interface QrcodeLogo {
src?: string src?: string
logoSize?: number logoSize?: number
bgColor?: string bgColor?: string

View File

@ -1,16 +1,16 @@
declare type TableColumn = { export type TableColumn = {
field: string field: string
label?: string label?: string
children?: TableColumn[] children?: TableColumn[]
} & Recordable } & Recordable
declare type TableSlotDefault = { export type TableSlotDefault = {
row: Recordable row: Recordable
column: TableColumn column: TableColumn
$index: number $index: number
} & Recordable } & Recordable
declare interface Pagination { export interface Pagination {
small?: boolean small?: boolean
background?: boolean background?: boolean
pageSize?: number pageSize?: number
@ -29,7 +29,7 @@ declare interface Pagination {
hideOnSinglePage?: boolean hideOnSinglePage?: boolean
} }
declare interface TableSetPropsType { export interface TableSetPropsType {
field: string field: string
path: string path: string
value: any value: any

View File

@ -6,6 +6,7 @@ import { getUserListApi } from '@/api/login'
import { UserType } from '@/api/login/types' import { UserType } from '@/api/login/types'
import { ref, h } from 'vue' import { ref, h } from 'vue'
import { ElButton } from 'element-plus' import { ElButton } from 'element-plus'
import { TableColumn, TableSlotDefault } from '@/types/table'
interface Params { interface Params {
pageIndex?: number pageIndex?: number

View File

@ -6,6 +6,7 @@ import { getUserListApi } from '@/api/login'
import { UserType } from '@/api/login/types' import { UserType } from '@/api/login/types'
import { ref, h } from 'vue' import { ref, h } from 'vue'
import { ElButton } from 'element-plus' import { ElButton } from 'element-plus'
import { TableColumn, TableSlotDefault } from '@/types/table'
interface Params { interface Params {
pageIndex?: number pageIndex?: number

View File

@ -6,6 +6,7 @@ import { Form } from '@/components/Form'
import { ElFormItem, ElInput, ElButton } from 'element-plus' import { ElFormItem, ElInput, ElButton } from 'element-plus'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { useForm } from '@/hooks/web/useForm' import { useForm } from '@/hooks/web/useForm'
import { DescriptionsSchema } from '@/types/descriptions'
const { required } = useValidator() const { required } = useValidator()

View File

@ -7,6 +7,7 @@ import { ref, reactive, unref } from 'vue'
import { Form, FormExpose } from '@/components/Form' import { Form, FormExpose } from '@/components/Form'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { getDictOneApi } from '@/api/common' import { getDictOneApi } from '@/api/common'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -5,6 +5,8 @@ import { useI18n } from '@/hooks/web/useI18n'
import { useIcon } from '@/hooks/web/useIcon' import { useIcon } from '@/hooks/web/useIcon'
import { ContentWrap } from '@/components/ContentWrap' import { ContentWrap } from '@/components/ContentWrap'
import { useAppStore } from '@/store/modules/app' import { useAppStore } from '@/store/modules/app'
import { FormSchema } from '@/types/form'
import { ComponentOptions } from '@/types/components'
const appStore = useAppStore() const appStore = useAppStore()

View File

@ -6,6 +6,7 @@ import { reactive, unref, ref } from 'vue'
import { ElButton } from 'element-plus' import { ElButton } from 'element-plus'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { getDictOneApi } from '@/api/common' import { getDictOneApi } from '@/api/common'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -7,6 +7,7 @@ import { reactive, unref, ref } from 'vue'
import { ElButton } from 'element-plus' import { ElButton } from 'element-plus'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { getDictOneApi } from '@/api/common' import { getDictOneApi } from '@/api/common'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -6,6 +6,7 @@ import { reactive, ref, unref } from 'vue'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { ElButton } from 'element-plus' import { ElButton } from 'element-plus'
import { getDictOneApi } from '@/api/common' import { getDictOneApi } from '@/api/common'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -6,6 +6,7 @@ import { getTableListApi } from '@/api/table'
import { TableData } from '@/api/table/types' import { TableData } from '@/api/table/types'
import { ref, h } from 'vue' import { ref, h } from 'vue'
import { ElTag, ElButton } from 'element-plus' import { ElTag, ElButton } from 'element-plus'
import { TableColumn, TableSlotDefault } from '@/types/table'
interface Params { interface Params {
pageIndex?: number pageIndex?: number

View File

@ -7,6 +7,7 @@ import { TableData } from '@/api/table/types'
import { ref, h, reactive, unref } from 'vue' import { ref, h, reactive, unref } from 'vue'
import { ElTag, ElButton } from 'element-plus' import { ElTag, ElButton } from 'element-plus'
import { useTable } from '@/hooks/web/useTable' import { useTable } from '@/hooks/web/useTable'
import { Pagination, TableColumn, TableSlotDefault } from '@/types/table'
const { t } = useI18n() const { t } = useI18n()

View File

@ -7,6 +7,7 @@ import { TableData } from '@/api/table/types'
import { ref, h, reactive, unref } from 'vue' import { ref, h, reactive, unref } from 'vue'
import { ElTag, ElButton } from 'element-plus' import { ElTag, ElButton } from 'element-plus'
import { useTable } from '@/hooks/web/useTable' import { useTable } from '@/hooks/web/useTable'
import { Pagination, TableColumn, TableSlotDefault } from '@/types/table'
const { register, tableObject, methods, elTableRef } = useTable<TableData>({ const { register, tableObject, methods, elTableRef } = useTable<TableData>({
getListApi: getTableListApi, getListApi: getTableListApi,

View File

@ -12,6 +12,7 @@ import { h, ref, unref, reactive } from 'vue'
import Write from './components/Write.vue' import Write from './components/Write.vue'
import Detail from './components/Detail.vue' import Detail from './components/Detail.vue'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { TableColumn } from '@/types/table'
const { register, tableObject, methods } = useTable<TableData>({ const { register, tableObject, methods } = useTable<TableData>({
getListApi: getTableListApi, getListApi: getTableListApi,

View File

@ -4,6 +4,7 @@ import type { TableData } from '@/api/table/types'
import { Descriptions } from '@/components/Descriptions' import { Descriptions } from '@/components/Descriptions'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { ElTag } from 'element-plus' import { ElTag } from 'element-plus'
import { DescriptionsSchema } from '@/types/descriptions'
const { t } = useI18n() const { t } = useI18n()

View File

@ -4,6 +4,7 @@ import { useForm } from '@/hooks/web/useForm'
import { PropType, reactive, watch } from 'vue' import { PropType, reactive, watch } from 'vue'
import { TableData } from '@/api/table/types' import { TableData } from '@/api/table/types'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -11,6 +11,7 @@ import { h, reactive, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useEmitt } from '@/hooks/web/useEmitt' import { useEmitt } from '@/hooks/web/useEmitt'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { TableColumn } from '@/types/table'
defineOptions({ defineOptions({
name: 'ExamplePage' name: 'ExamplePage'

View File

@ -4,6 +4,7 @@ import type { TableData } from '@/api/table/types'
import { Descriptions } from '@/components/Descriptions' import { Descriptions } from '@/components/Descriptions'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { ElTag } from 'element-plus' import { ElTag } from 'element-plus'
import { DescriptionsSchema } from '@/types/descriptions'
const { t } = useI18n() const { t } = useI18n()

View File

@ -6,6 +6,7 @@ import { TableData } from '@/api/table/types'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { IDomEditor } from '@wangeditor/editor' import { IDomEditor } from '@wangeditor/editor'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -12,6 +12,7 @@ import { useRouter } from 'vue-router'
import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router' import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
import { UserType } from '@/api/login/types' import { UserType } from '@/api/login/types'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { FormSchema } from '@/types/form'
const { required } = useValidator() const { required } = useValidator()

View File

@ -5,6 +5,7 @@ import { useI18n } from '@/hooks/web/useI18n'
import { useForm } from '@/hooks/web/useForm' import { useForm } from '@/hooks/web/useForm'
import { ElButton, ElInput, FormRules } from 'element-plus' import { ElButton, ElInput, FormRules } from 'element-plus'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { FormSchema } from '@/types/form'
const emit = defineEmits(['to-login']) const emit = defineEmits(['to-login'])

View File

@ -11,6 +11,7 @@ import { h, ref, reactive } from 'vue'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { getDictOneApi } from '@/api/common' import { getDictOneApi } from '@/api/common'
import { TableColumn } from '@/types/table'
const dictStore = useDictStore() const dictStore = useDictStore()

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,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
}
}

77
types/global.d.ts vendored
View File

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