diff --git a/src/components/notification-group/notification-group.ts b/src/components/notification-group/notification-group.ts index 597fc05..4904122 100644 --- a/src/components/notification-group/notification-group.ts +++ b/src/components/notification-group/notification-group.ts @@ -34,7 +34,7 @@ export class StarNotificationGroup extends LitElement { let id = (event as any).detail.id ;(this.slotElements as StarNotification[]).forEach( (el: StarNotification) => { - if (el.noclear != true) { + if (!el.noclear) { if (this.getAttribute('show') == 'false') { if (el.id == id) { // 删除某个notification-group diff --git a/src/components/notification/notification.ts b/src/components/notification/notification.ts index ff784df..25065ad 100644 --- a/src/components/notification/notification.ts +++ b/src/components/notification/notification.ts @@ -248,12 +248,12 @@ export class StarNotification extends LitElement { return nothing } - if (!this.secondText) { - console.error( - '【star-notification】【more-notification-first】缺少 secondText 参数' - ) - return nothing - } + // if (!this.secondText) { + // console.error( + // '【star-notification】【more-notification-first】缺少 secondText 参数' + // ) + // return nothing + // } if (!this.radiusType) { console.error( @@ -319,6 +319,7 @@ export class StarNotification extends LitElement { @eventOptions({passive: false}) handleEvent(event: TouchEvent) { + let self = this if (!this.isToast) { switch (event.type) { case 'touchstart': @@ -441,7 +442,6 @@ export class StarNotification extends LitElement { break case 'click': event.stopPropagation() - let self = this let target = event.target as HTMLElement this.notification.style.transform = '' switch (target.dataset.icon) { @@ -450,7 +450,7 @@ export class StarNotification extends LitElement { target.addEventListener('transitionend', function tranEnd() { target.removeEventListener('transitionend', tranEnd) target.removeAttribute('clicked') - if (self.noclear != true) { + if (!self.noclear) { self.dispatchEvent( new CustomEvent('notification-delete', { detail: { @@ -503,6 +503,29 @@ export class StarNotification extends LitElement { } break } + } else { + switch (event.type) { + case 'click': + this.notification.setAttribute('clicked', 'true') + this.notification.addEventListener( + 'transitionend', + function tranEnd() { + self.notification.removeEventListener('transitionend', tranEnd) + self.notification.removeAttribute('clicked') + self.dispatchEvent( + new CustomEvent('notification-click', { + detail: { + id: self.id, + notification: self, + }, + bubbles: true, + composed: true, + }) + ) + } + ) + break + } } }