add shenyan-app RN project + PWA push/noise updates

This commit is contained in:
2026-05-13 17:38:35 +08:00
parent 66f94f0fcf
commit 4d7110c58d
82 changed files with 14677 additions and 124 deletions

26
PWA/public/sw-push.js Normal file
View File

@@ -0,0 +1,26 @@
self.addEventListener('push', function (event) {
var data = {};
try { data = event.data.json(); } catch (e) { data = { title: '沈晏', body: event.data ? event.data.text() : '' }; }
event.waitUntil(
self.registration.showNotification(data.title || '沈晏', {
body: data.body || '',
icon: '/icon-192.png',
badge: '/icon-192.png',
vibrate: [200, 100, 200],
tag: 'shenyan-push',
renotify: true,
})
);
});
self.addEventListener('notificationclick', function (event) {
event.notification.close();
event.waitUntil(
clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (list) {
for (var i = 0; i < list.length; i++) {
if (list[i].url && 'focus' in list[i]) return list[i].focus();
}
if (clients.openWindow) return clients.openWindow('/');
})
);
});