magiccube-vue3
Version:
vue3-js版组件库
30 lines (28 loc) • 991 B
JavaScript
import Components from './component'
import { toast, message } from './components/message'
import notify from './components/notification'
import Directives from './directive'
import store from './utils/store'
const makeInstaller = (components = [], directives = []) => {
const apps = []
const install = (app, opts) => {
const defaultInstallOpt = {
size: '',
zIndex: 2e3
}
const option = Object.assign(defaultInstallOpt, opts)
if (apps.includes(app)) return
apps.push(app)
components.forEach((c) => {
app.use(c)
})
directives.forEach((d) => {
app.directive(d.name, d.directive)
})
app.config.globalProperties.$ELEMENT = option
if(option.teleportName) store.setState('teleportName', option.teleportName)
}
return install
}
const install = makeInstaller(Components, Directives)
export { toast, message, notify, install, install as default }