make-installer.ts 708 B

1234567891011121314151617181920212223
  1. import { provideGlobalConfig } from '@kankan-components/hooks'
  2. // import { INSTALLED_KEY } from '@kankan-components/constants'
  3. import { version } from './version'
  4. import type { App, Plugin } from '@vue/runtime-core'
  5. import type { ConfigProviderContext } from '@kankan-components/tokens'
  6. const INSTALLED_KEY = Symbol('INSTALLED_KEY')
  7. export const makeInstaller = (components: Plugin[] = []) => {
  8. const install = (app: App, options?: ConfigProviderContext) => {
  9. if (app[INSTALLED_KEY]) return
  10. app[INSTALLED_KEY] = true
  11. components.forEach(c => app.use(c))
  12. if (options) provideGlobalConfig(options, app, true)
  13. }
  14. return {
  15. version,
  16. install,
  17. }
  18. }