naive-ui/packages/common/Confirm/index.js

33 lines
713 B
JavaScript
Raw Normal View History

2019-08-01 13:46:03 +08:00
import Confirm from './src/index.js'
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) {
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-08-01 13:46:03 +08:00
export default Confirm