forked from euvl/vue-js-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.js
42 lines (35 loc) · 954 Bytes
/
Plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Modal from './components/Modal.vue'
import Dialog from './components/Dialog.vue'
import PluginCore from './PluginCore'
const Plugin = {
install(app, options = {}) {
if (app.config.globalProperties.$modal) {
return
}
const plugin = PluginCore(options)
app.config.globalProperties.$modal = plugin
app.provide('$modal', plugin)
app.mixin({
mounted() {
if (this.$root === this) {
if (!plugin.context.root) {
plugin.context.root = this;
// plugin.setDynamicModalContainer(this)
}
}
}
})
/**
* Sets custom component name (if provided)
*/
app.component(plugin.context.componentName, Modal)
/**
* Registration of <Dialog/> component
*/
if (options.dialog) {
const componentName = options.dialogComponentName || 'VDialog'
app.component(componentName, Dialog)
}
}
}
export default Plugin