mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
refactor: improve types (#4746)
This commit is contained in:
parent
db1d9401fe
commit
b6c077e2c1
@ -95,6 +95,7 @@ import { ElTransfer } from '@element-plus/components/transfer'
|
|||||||
import { ElTree } from '@element-plus/components/tree'
|
import { ElTree } from '@element-plus/components/tree'
|
||||||
import { ElTreeV2 } from '@element-plus/components/tree-v2'
|
import { ElTreeV2 } from '@element-plus/components/tree-v2'
|
||||||
import { ElUpload } from '@element-plus/components/upload'
|
import { ElUpload } from '@element-plus/components/upload'
|
||||||
|
import type { Plugin } from 'vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
ElAffix,
|
ElAffix,
|
||||||
@ -187,4 +188,4 @@ export default [
|
|||||||
ElTree,
|
ElTree,
|
||||||
ElTreeV2,
|
ElTreeV2,
|
||||||
ElUpload,
|
ElUpload,
|
||||||
]
|
] as Plugin[]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import makeInstaller from './make-installer'
|
import { makeInstaller } from './make-installer'
|
||||||
import Components from './component'
|
import Components from './component'
|
||||||
import Plugins from './plugin'
|
import Plugins from './plugin'
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ export * from '@element-plus/directives'
|
|||||||
export * from '@element-plus/hooks'
|
export * from '@element-plus/hooks'
|
||||||
export * from '@element-plus/tokens'
|
export * from '@element-plus/tokens'
|
||||||
|
|
||||||
export { default as makeInstaller } from './make-installer'
|
export { makeInstaller } from './make-installer'
|
||||||
export { default } from './defaults'
|
export { default } from './defaults'
|
||||||
|
|
||||||
export const install = installer.install
|
export const install = installer.install
|
||||||
|
@ -3,15 +3,14 @@ import { localeContextKey, localeProviderMaker } from '@element-plus/hooks'
|
|||||||
import { version } from './version'
|
import { version } from './version'
|
||||||
|
|
||||||
import type { App, Plugin } from 'vue'
|
import type { App, Plugin } from 'vue'
|
||||||
import type { ComponentSize } from '@element-plus/utils/types'
|
|
||||||
import type { InstallOptions } from '@element-plus/utils/config'
|
import type { InstallOptions } from '@element-plus/utils/config'
|
||||||
|
|
||||||
const makeInstaller = (components: Plugin[] = []) => {
|
export const makeInstaller = (components: Plugin[] = []) => {
|
||||||
const apps: App[] = []
|
const apps: App[] = []
|
||||||
|
|
||||||
const install = (app: App, opts: InstallOptions) => {
|
const install = (app: App, opts: InstallOptions) => {
|
||||||
const defaultInstallOpt: InstallOptions = {
|
const defaultInstallOpt: InstallOptions = {
|
||||||
size: '' as ComponentSize,
|
size: '',
|
||||||
zIndex: 2000,
|
zIndex: 2000,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,9 +18,7 @@ const makeInstaller = (components: Plugin[] = []) => {
|
|||||||
if (apps.includes(app)) return
|
if (apps.includes(app)) return
|
||||||
apps.push(app)
|
apps.push(app)
|
||||||
|
|
||||||
components.forEach((c) => {
|
components.forEach((c) => app.use(c))
|
||||||
app.use(c)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (option.locale) {
|
if (option.locale) {
|
||||||
const localeProvides = localeProviderMaker(opts.locale)
|
const localeProvides = localeProviderMaker(opts.locale)
|
||||||
@ -38,5 +35,3 @@ const makeInstaller = (components: Plugin[] = []) => {
|
|||||||
install,
|
install,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default makeInstaller
|
|
||||||
|
@ -5,6 +5,8 @@ import { ElMessageBox } from '@element-plus/components/message-box'
|
|||||||
import { ElNotification } from '@element-plus/components/notification'
|
import { ElNotification } from '@element-plus/components/notification'
|
||||||
import { ElPopoverDirective } from '@element-plus/components/popover'
|
import { ElPopoverDirective } from '@element-plus/components/popover'
|
||||||
|
|
||||||
|
import type { Plugin } from 'vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
ElInfiniteScroll,
|
ElInfiniteScroll,
|
||||||
ElLoading,
|
ElLoading,
|
||||||
@ -12,4 +14,4 @@ export default [
|
|||||||
ElMessageBox,
|
ElMessageBox,
|
||||||
ElNotification,
|
ElNotification,
|
||||||
ElPopoverDirective,
|
ElPopoverDirective,
|
||||||
]
|
] as Plugin[]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { ComponentSize } from './types'
|
import type { ComponentSize } from './types'
|
||||||
|
|
||||||
export interface InstallOptions {
|
export interface InstallOptions {
|
||||||
size: ComponentSize
|
size: ComponentSize | ''
|
||||||
zIndex: number
|
zIndex: number
|
||||||
locale?: any
|
locale?: any
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user