✌️
This commit is contained in:
parent
6e8caf7966
commit
5ca4aefff4
|
@ -173,8 +173,10 @@ fetchInstance().then(() => {
|
||||||
// Init service worker
|
// Init service worker
|
||||||
if (instance.swPublickey &&
|
if (instance.swPublickey &&
|
||||||
('serviceWorker' in navigator) &&
|
('serviceWorker' in navigator) &&
|
||||||
('PushManager' in window) && $i && $i.token
|
('PushManager' in window) &&
|
||||||
) {
|
$i && $i.token) {
|
||||||
|
navigator.serviceWorker.register(`/sw.js`);
|
||||||
|
|
||||||
navigator.serviceWorker.ready.then(registration => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
registration.active?.postMessage({
|
registration.active?.postMessage({
|
||||||
msg: 'initialize',
|
msg: 'initialize',
|
||||||
|
|
|
@ -98,6 +98,7 @@ self.addEventListener('message', ev => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof ev.data === 'object') {
|
if (typeof ev.data === 'object') {
|
||||||
|
// E.g. '[object Array]' → 'array'
|
||||||
const otype = Object.prototype.toString.call(ev.data).slice(8, -1).toLowerCase();
|
const otype = Object.prototype.toString.call(ev.data).slice(8, -1).toLowerCase();
|
||||||
|
|
||||||
if (otype === 'object') {
|
if (otype === 'object') {
|
||||||
|
|
|
@ -72,10 +72,6 @@
|
||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Service Worker
|
|
||||||
navigator.serviceWorker.register(`/sw.js`);
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region Theme
|
//#region Theme
|
||||||
const theme = localStorage.getItem('theme');
|
const theme = localStorage.getItem('theme');
|
||||||
if (theme) {
|
if (theme) {
|
||||||
|
|
Loading…
Reference in a new issue