refactor: notification api changed

This commit is contained in:
07akioni 2019-06-26 14:40:36 +08:00
parent b9168b0caf
commit 7f7c27adf8
3 changed files with 23 additions and 19 deletions

View File

@ -44,12 +44,12 @@ In the kind of world where we belong`,
action: 'Mark as read',
avator: null,
duration: 3000,
afterCloseCallback: (notification) => {
this.$NMessage.success('Notification closed successfully!')
afterCloseCallback: (notificationVueInstance) => {
const notification = notificationVueInstance.notification
this.$NMessage.success(notification.title)
},
actionCallback: (notification) => {
console.log('mark read!')
notification.close()
actionCallback: (notificationVueInstance) => {
notificationVueInstance.close()
}
})
},
@ -63,9 +63,10 @@ I cant get no, I cant get no`,
meta: '2019-5-27 15:11',
action: 'Mark as read',
avator: null,
actionCallback: (notification) => {
console.log('mark read!')
notification.close()
actionCallback: (notificationVueInstance) => {
const notification = notificationVueInstance.notification
this.$NMessage.success(notification.title)
notificationVueInstance.close()
}
})
}
@ -96,8 +97,12 @@ In the kind of world where we belong`,
action: 'Mark as read',
avator: null,
duration: 3000,
afterCloseCallback: (notification) => {
afterCloseCallback: (notificationVueInstance) => {
const notification = notificationVueInstance.notification
this.$NMessage.success(notification.title)
},
actionCallback: (notificationVueInstance) => {
notificationVueInstance.close()
}
})
},
@ -111,12 +116,10 @@ I cant get no, I cant get no`,
meta: '2019-5-27 15:11',
action: 'Mark as read',
avator: null,
afterCloseCallback: (notification) => {
actionCallback: (notificationVueInstance) => {
const notification = notificationVueInstance.notification
this.$NMessage.success(notification.title)
},
actionCallback: (notification, closeNotification) => {
this.$NMessage.success(notification.title)
closeNotification()
notificationVueInstance.close()
}
})
}

View File

@ -1,6 +1,6 @@
{
"name": "naive-ui",
"version": "0.1.61",
"version": "0.1.63",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -44,12 +44,13 @@ function mountNotificationEl (container, vm, option) {
el.style['max-height'] = `${30 + vm.$refs.body.getBoundingClientRect().height}px`
}
function removeNotificationEl (container, el, option, notification) {
function removeNotificationEl (container, el, option, notificationVueInstance) {
setTimeout(function () {
if (container.contains(el)) {
container.removeChild(el)
const notification = notificationVueInstance.notification
if (notification.afterCloseCallback) {
notification.afterCloseCallback(notification)
notification.afterCloseCallback(notificationVueInstance)
}
}
}, option.vanishTransitionTimeout)
@ -70,10 +71,10 @@ const NMessage = {
},
methods: {
close () {
removeNotificationEl(notificationContainer, this.$el, option, notification)
removeNotificationEl(notificationContainer, this.$el, option, this)
},
handleActionClick () {
notification.actionCallback(notification, this.close)
notification.actionCallback(this)
}
}
})).$mount()