|
|
@ -2,6 +2,7 @@ import {
|
|
|
|
regSocketEventListener,
|
|
|
|
regSocketEventListener,
|
|
|
|
getGlobalState,
|
|
|
|
getGlobalState,
|
|
|
|
getCachedUserInfo,
|
|
|
|
getCachedUserInfo,
|
|
|
|
|
|
|
|
getServiceWorkerRegistration,
|
|
|
|
} from '@capital/common';
|
|
|
|
} from '@capital/common';
|
|
|
|
|
|
|
|
|
|
|
|
export function initNotify() {
|
|
|
|
export function initNotify() {
|
|
|
@ -24,6 +25,18 @@ export function initNotify() {
|
|
|
|
const icon = userInfo?.avatar ?? undefined;
|
|
|
|
const icon = userInfo?.avatar ?? undefined;
|
|
|
|
const content = message.content;
|
|
|
|
const content = message.content;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const registration: ServiceWorkerRegistration | null =
|
|
|
|
|
|
|
|
getServiceWorkerRegistration();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (registration) {
|
|
|
|
|
|
|
|
registration.showNotification(`来自 ${nickname}`, {
|
|
|
|
|
|
|
|
body: content,
|
|
|
|
|
|
|
|
icon,
|
|
|
|
|
|
|
|
tag: 'tailchat-message',
|
|
|
|
|
|
|
|
renotify: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// fallback
|
|
|
|
new Notification(`来自 ${nickname}`, {
|
|
|
|
new Notification(`来自 ${nickname}`, {
|
|
|
|
body: content,
|
|
|
|
body: content,
|
|
|
|
icon,
|
|
|
|
icon,
|
|
|
@ -31,6 +44,7 @@ export function initNotify() {
|
|
|
|
renotify: true,
|
|
|
|
renotify: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|