Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notification 可设置为不自动关闭 #38

Merged
merged 1 commit into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ import { Notification } from 'vue-desktop'

- title: Notification 显示的标题。
- message: Notification 显示的内容。
- type: Notification 显示的图标的类型,可选值:success、info、warning、error,默认值为info
- duration: Notification 显示的时长,单位为秒,默认值为5
- type: Notification 显示的图标的类型,可选值:success、info、warning、error,默认值为 info
- duration: Notification 显示的时长,单位为秒,默认值为 5。设置为 0 则会一直显示,直到用户手动关闭
- callback: Notification 关闭后的回调函数,参数 instance 为对应于该 Notification 的 Vue 实例对象,它具有上述四个属性,instance.id 为唯一性标识。
2 changes: 1 addition & 1 deletion examples/service/notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
title: '通知',
message: '通知信息',
type: 'warning',
duration: 2
duration: 0
});
},
notification4() {
Expand Down
22 changes: 13 additions & 9 deletions src/service/notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,25 @@

startTimer() {
var self = this;
if (this.duration > 0) {
this.timer = setTimeout(function() {
if (!self.closed) {
self.handleClose();
}
}, this.duration * 1000);
}
}
},

ready() {
var self = this;
if (this.duration > 0) {
this.timer = setTimeout(function() {
if (!self.closed) {
self.handleClose();
}
}, this.duration * 1000);
}
},

ready() {
var self = this;
this.timer = setTimeout(function() {
if (!self.closed) {
self.handleClose();
}
}, this.duration * 1000);
}
}
</script>