refactor: improve types (#4746)

This commit is contained in:
三咲智子 2021-12-10 17:21:53 +08:00 committed by GitHub
parent db1d9401fe
commit b6c077e2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 13 deletions

View File

@ -95,6 +95,7 @@ import { ElTransfer } from '@element-plus/components/transfer'
import { ElTree } from '@element-plus/components/tree'
import { ElTreeV2 } from '@element-plus/components/tree-v2'
import { ElUpload } from '@element-plus/components/upload'
import type { Plugin } from 'vue'
export default [
ElAffix,
@ -187,4 +188,4 @@ export default [
ElTree,
ElTreeV2,
ElUpload,
]
] as Plugin[]

View File

@ -1,4 +1,4 @@
import makeInstaller from './make-installer'
import { makeInstaller } from './make-installer'
import Components from './component'
import Plugins from './plugin'

View File

@ -4,7 +4,7 @@ export * from '@element-plus/directives'
export * from '@element-plus/hooks'
export * from '@element-plus/tokens'
export { default as makeInstaller } from './make-installer'
export { makeInstaller } from './make-installer'
export { default } from './defaults'
export const install = installer.install

View File

@ -3,15 +3,14 @@ import { localeContextKey, localeProviderMaker } from '@element-plus/hooks'
import { version } from './version'
import type { App, Plugin } from 'vue'
import type { ComponentSize } from '@element-plus/utils/types'
import type { InstallOptions } from '@element-plus/utils/config'
const makeInstaller = (components: Plugin[] = []) => {
export const makeInstaller = (components: Plugin[] = []) => {
const apps: App[] = []
const install = (app: App, opts: InstallOptions) => {
const defaultInstallOpt: InstallOptions = {
size: '' as ComponentSize,
size: '',
zIndex: 2000,
}
@ -19,9 +18,7 @@ const makeInstaller = (components: Plugin[] = []) => {
if (apps.includes(app)) return
apps.push(app)
components.forEach((c) => {
app.use(c)
})
components.forEach((c) => app.use(c))
if (option.locale) {
const localeProvides = localeProviderMaker(opts.locale)
@ -38,5 +35,3 @@ const makeInstaller = (components: Plugin[] = []) => {
install,
}
}
export default makeInstaller

View File

@ -5,6 +5,8 @@ import { ElMessageBox } from '@element-plus/components/message-box'
import { ElNotification } from '@element-plus/components/notification'
import { ElPopoverDirective } from '@element-plus/components/popover'
import type { Plugin } from 'vue'
export default [
ElInfiniteScroll,
ElLoading,
@ -12,4 +14,4 @@ export default [
ElMessageBox,
ElNotification,
ElPopoverDirective,
]
] as Plugin[]

View File

@ -1,7 +1,7 @@
import type { ComponentSize } from './types'
export interface InstallOptions {
size: ComponentSize
size: ComponentSize | ''
zIndex: number
locale?: any
}