perf: 优化notify插件代码

pull/64/head
moonrailgun 2 years ago
parent 8c30282d0b
commit 1f537816c2

@ -37,21 +37,18 @@ export function initNotify() {
const registration: ServiceWorkerRegistration | null = const registration: ServiceWorkerRegistration | null =
getServiceWorkerRegistration(); getServiceWorkerRegistration();
const title = `${Translate.from} ${nickname}`;
const options: NotificationOptions = {
body: content,
icon,
tag: 'tailchat-message',
renotify: true,
};
if (registration) { if (registration) {
registration.showNotification(`${Translate.from} ${nickname}`, { registration.showNotification(title, options);
body: content,
icon,
tag: 'tailchat-message',
renotify: true,
});
} else { } else {
// fallback // fallback
new Notification(`${Translate.from} ${nickname}`, { new Notification(title, options);
body: content,
icon,
tag: 'tailchat-message',
renotify: true,
});
} }
} }
); );

Loading…
Cancel
Save