support Notice
support Notice
This commit is contained in:
parent
6cadeba44f
commit
833501a4fa
7 changed files with 32 additions and 25 deletions
|
@ -85,7 +85,7 @@
|
|||
this.$parent.close(this.name);
|
||||
}
|
||||
},
|
||||
created () {
|
||||
mounted () {
|
||||
this.clearCloseTimer();
|
||||
|
||||
if (this.duration !== 0) {
|
||||
|
|
|
@ -7,7 +7,7 @@ const prefixKey = 'ivu_notice_key_';
|
|||
let top = 24;
|
||||
let defaultDuration = 4.5;
|
||||
let noticeInstance;
|
||||
let key = 1;
|
||||
let name = 1;
|
||||
|
||||
const iconTypes = {
|
||||
'info': 'information-circled',
|
||||
|
@ -19,7 +19,7 @@ const iconTypes = {
|
|||
function getNoticeInstance () {
|
||||
noticeInstance = noticeInstance || Notification.newInstance({
|
||||
prefixCls: prefixCls,
|
||||
style: {
|
||||
styles: {
|
||||
top: `${top}px`,
|
||||
right: 0
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ function getNoticeInstance () {
|
|||
function notice (type, options) {
|
||||
const title = options.title || '';
|
||||
const desc = options.desc || '';
|
||||
const noticeKey = options.key || `${prefixKey}${key}`;
|
||||
const noticeKey = options.name || `${prefixKey}${name}`;
|
||||
const onClose = options.onClose || function () {};
|
||||
// todo const btn = options.btn || null;
|
||||
const duration = (options.duration === 0) ? 0 : options.duration || defaultDuration;
|
||||
|
||||
key++;
|
||||
name++;
|
||||
|
||||
let instance = getNoticeInstance();
|
||||
|
||||
|
@ -65,9 +65,9 @@ function notice (type, options) {
|
|||
}
|
||||
|
||||
instance.notice({
|
||||
key: noticeKey.toString(),
|
||||
name: noticeKey.toString(),
|
||||
duration: duration,
|
||||
style: {},
|
||||
styles: {},
|
||||
transitionName: 'move-notice',
|
||||
content: content,
|
||||
onClose: onClose,
|
||||
|
@ -99,11 +99,11 @@ export default {
|
|||
defaultDuration = options.duration;
|
||||
}
|
||||
},
|
||||
close (key) {
|
||||
if (key) {
|
||||
key = key.toString();
|
||||
close (name) {
|
||||
if (name) {
|
||||
name = name.toString();
|
||||
if (noticeInstance) {
|
||||
noticeInstance.remove(key);
|
||||
noticeInstance.remove(name);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue