mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-04-12 14:40:47 +08:00
refactor: notification api changed
This commit is contained in:
parent
b9168b0caf
commit
7f7c27adf8
@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "naive-ui",
|
||||
"version": "0.1.61",
|
||||
"version": "0.1.63",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user