2019-08-01 13:46:03 +08:00
|
|
|
import Confirm from './src/index.js'
|
2019-09-28 18:50:56 +08:00
|
|
|
|
|
|
|
function getTheme (component) {
|
|
|
|
let cursor = component
|
|
|
|
while (cursor.$parent) {
|
|
|
|
const name = cursor.$options.name
|
|
|
|
if (cursor.synthesizedTheme) {
|
|
|
|
return cursor.synthesizedTheme
|
|
|
|
}
|
|
|
|
if (name === 'NApp') {
|
|
|
|
return cursor.theme || null
|
|
|
|
}
|
|
|
|
cursor = cursor.$parent
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
2019-08-01 13:46:03 +08:00
|
|
|
|
|
|
|
Confirm.install = function (Vue) {
|
2019-09-28 18:50:56 +08:00
|
|
|
Confirm.Vue = Vue
|
|
|
|
Object.defineProperty(Vue.prototype, '$NModal', {
|
|
|
|
get: new Proxy(function () {
|
|
|
|
return Confirm
|
|
|
|
}, {
|
|
|
|
apply (target, thisArg, argumentsList) {
|
|
|
|
Confirm.theme = getTheme(thisArg)
|
|
|
|
return target.bind(thisArg)(...argumentsList)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2019-08-01 13:46:03 +08:00
|
|
|
}
|
2019-09-28 18:50:56 +08:00
|
|
|
|
2019-08-01 13:46:03 +08:00
|
|
|
export default Confirm
|