element-plus/packages/element-plus/make-installer.ts
2022-03-23 18:30:50 +08:00

23 lines
590 B
TypeScript

import { provideGlobalConfig } from '@element-plus/hooks'
import { version } from './version'
import type { App, Plugin } from 'vue'
import type { ConfigProviderContext } from '@element-plus/tokens'
const INSTALLED_KEY = Symbol('INSTALLED_KEY')
export const makeInstaller = (components: Plugin[] = []) => {
const install = (app: App, options?: ConfigProviderContext) => {
if (app[INSTALLED_KEY]) return
app[INSTALLED_KEY] = true
components.forEach((c) => app.use(c))
if (options) provideGlobalConfig(options, app, true)
}
return {
version,
install,
}
}