bug fixed
This commit is contained in:
parent
cb61da113d
commit
d6787baad8
|
@ -90,7 +90,7 @@ export interface Notification {
|
|||
'width'
|
||||
>;
|
||||
displayTime?: number;
|
||||
template: Template;
|
||||
template?: Template;
|
||||
data?: any;
|
||||
onShow?: OnShow4NotificationWindow;
|
||||
onClose?: OnClose4NotificationWindow;
|
||||
|
@ -151,6 +151,9 @@ class WindowPooler {
|
|||
interface Activated {
|
||||
notification: Notification;
|
||||
browserWindow: Electron.BrowserWindow;
|
||||
callbacks: {
|
||||
onCloseFunc: (reason?: any) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export class NotificationService {
|
||||
|
@ -201,13 +204,19 @@ export class NotificationService {
|
|||
});
|
||||
}
|
||||
|
||||
close(id: number): void {
|
||||
const activated = this.__findActivatedByNotificationId(id);
|
||||
if (!activated) {
|
||||
return;
|
||||
}
|
||||
activated.callbacks.onCloseFunc();
|
||||
}
|
||||
|
||||
closeAll(): void {
|
||||
this.__animationQueue.clear();
|
||||
this.__activated.forEach(a => {
|
||||
a.browserWindow.close();
|
||||
});
|
||||
this.__activated = [];
|
||||
this.__delayQueue = [];
|
||||
this.__activated.forEach(a => {
|
||||
a.callbacks.onCloseFunc();
|
||||
});
|
||||
this.__closed.clear();
|
||||
this.__windowPooler.closeAll();
|
||||
}
|
||||
|
@ -224,11 +233,6 @@ export class NotificationService {
|
|||
.__getWindow(notification)
|
||||
.then(browserWindow => {
|
||||
browserWindow.setPosition(nextPosition.x, nextPosition.y);
|
||||
__this.__activated.push({
|
||||
notification,
|
||||
browserWindow,
|
||||
});
|
||||
|
||||
const displayTime = !!notification.displayTime
|
||||
? notification.displayTime
|
||||
: !!__this.__defaultOptions.displayTime
|
||||
|
@ -243,6 +247,14 @@ export class NotificationService {
|
|||
const onCloseFncGraceful = __this.__onCloseFnc4Graceful(
|
||||
onCloseFnc
|
||||
);
|
||||
__this.__activated.push({
|
||||
notification,
|
||||
browserWindow,
|
||||
callbacks: {
|
||||
onCloseFunc: onCloseFncGraceful,
|
||||
},
|
||||
});
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
if (browserWindow.isDestroyed()) {
|
||||
return;
|
||||
|
@ -352,7 +364,7 @@ export class NotificationService {
|
|||
|
||||
private __onCloseFnc4Graceful(onClose: OnClose4NotificationWindow) {
|
||||
const __this = this;
|
||||
return (reason: any): void => {
|
||||
return (reason?: any): void => {
|
||||
if (!reason) {
|
||||
reason = 'closedGracefully';
|
||||
}
|
||||
|
@ -505,12 +517,12 @@ export class NotificationService {
|
|||
return 'data:text/html,' + encodeURIComponent(html);
|
||||
};
|
||||
|
||||
if (!!notification.template.filePath) {
|
||||
return filePath2Url(notification.template.filePath);
|
||||
if (!!notification.template?.filePath) {
|
||||
return filePath2Url(notification.template?.filePath);
|
||||
}
|
||||
|
||||
if (!!notification.template.html) {
|
||||
return html2Url(notification.template.html);
|
||||
if (!!notification.template?.html) {
|
||||
return html2Url(notification.template?.html);
|
||||
}
|
||||
|
||||
if (!!this.__defaultOptions.template.filePath) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user