refactor(confirm): rename api

This commit is contained in:
07akioni 2019-12-13 18:18:47 +08:00
parent 752af2c0eb
commit f37375baf8
3 changed files with 12 additions and 7 deletions

View File

@ -4,9 +4,11 @@ import { install } from '../../utils/installThemeAwarableProperty'
ConfirmPlugin.install = function (Vue) {
ConfirmPlugin.Vue = Vue
install(Vue, ConfirmPlugin, '$NModal')
install(Vue, ConfirmPlugin, '$NConfirm')
Vue.component(Confirm.name, Confirm)
/** deprecated names */
Vue.component('NNimbusConfirmCard', Confirm)
install(Vue, ConfirmPlugin, '$NModal')
}
export default ConfirmPlugin

View File

@ -49,7 +49,7 @@ export default {
onNegativeClick: () => {
this.active = false
},
onCloseClick: () => {
onClose: () => {
this.active = false
},
instances: null
@ -67,7 +67,7 @@ export default {
this.onNegativeClick(this.hide)
},
handleCloseClick () {
this.onCloseClick(this.hide)
this.onClose(this.hide)
},
hide () {
this.active = false

View File

@ -2,7 +2,7 @@ import ConfirmEnvironment from './ConfirmEnvironment.vue'
const instances = new Set()
function setDataOnConfirmInstance (data, instance) {
function updateConfirm (data, instance) {
for (const key of Object.keys(data)) {
if (key in instance.$data) {
instance.$data[key] = data[key]
@ -21,8 +21,11 @@ export default {
return instance
},
confirm (options) {
this.open.bind(this)(options)
},
open (options) {
const instance = this.createInstance()
setDataOnConfirmInstance(
updateConfirm(
{
type: 'confirm',
active: true,
@ -35,7 +38,7 @@ export default {
},
error (options) {
const instance = this.createInstance()
setDataOnConfirmInstance(
updateConfirm(
{
type: 'error',
active: true,
@ -48,7 +51,7 @@ export default {
},
success (options) {
const instance = this.createInstance()
setDataOnConfirmInstance(
updateConfirm(
{
type: 'success',
active: true,