fix(notification): not support in mobile browser (#1588)

Co-authored-by: sealday <sealday@gmail.com>
Reviewed-on: daoyoucloud/tachybase#1588
This commit is contained in:
sealday 2024-10-11 12:47:02 +08:00
parent 7b59aeb73d
commit b4a11fdc8e

View File

@ -3,10 +3,12 @@ import { Plugin } from '@tachybase/client';
import PluginMessagesClient from '..';
import { lang } from '../locale';
const isSupported = () => 'Notification' in window && 'serviceWorker' in navigator && 'PushManager' in window;
export class PluginWebNotification extends Plugin {
async afterLoad() {
// ‌请求用户授予权限
if (Notification.permission !== 'denied') {
if (isSupported() && Notification.permission !== 'denied') {
await Notification.requestPermission();
}
}