Commit df1214e 1 parent a4d7c77 commit df1214e Copy full SHA for df1214e
File tree 3 files changed +24
-6
lines changed
3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 184
184
window . frappePushNotification = new FrappePushNotification ( "hrms" )
185
185
document . addEventListener ( "DOMContentLoaded" , ( ) => {
186
186
window . frappePushNotification
187
- . appendConfigToServiceWorkerURL (
188
- "/assets/hrms/frontend/frappe-push-notification-sw.js"
189
- )
187
+ . appendConfigToServiceWorkerURL ( "/assets/hrms/frontend/sw.js" )
190
188
. then ( ( url ) => {
191
189
navigator . serviceWorker
192
190
. register ( url , {
196
194
window . frappePushNotification
197
195
. initialize ( registration )
198
196
. then ( ( ) => {
199
- console . log ( "Frappe Notification Initialized " )
197
+ console . log ( "Frappe Push Notification initialized " )
200
198
} )
201
199
} )
202
200
} )
205
203
} )
206
204
} )
207
205
</ script >
208
- <!-- END ! Import Frappe Notification JS -->
206
+ <!-- END Import Frappe Notification JS -->
209
207
</ head >
210
208
< body class ="antialiased ">
211
209
< div id ="app "> </ div >
215
213
< script >
216
214
window . csrf_token = "{{ csrf_token }}"
217
215
</ script >
216
+
218
217
< script type ="module " src ="/src/main.js "> </ script >
219
218
</ body >
220
219
</ html >
Original file line number Diff line number Diff line change
1
+ import { cleanupOutdatedCaches , precacheAndRoute } from "workbox-precaching"
2
+ import { clientsClaim } from "workbox-core"
3
+
1
4
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js"
2
5
import {
3
6
getMessaging ,
4
7
onBackgroundMessage ,
5
8
} from "https://www.gstatic.com/firebasejs/10.7.1/firebase-messaging-sw.js"
6
9
10
+ // Use the precache manifest generated by Vite
11
+ precacheAndRoute ( self . __WB_MANIFEST )
12
+
13
+ // Clean up old caches
14
+ cleanupOutdatedCaches ( )
15
+
7
16
const jsonConfig = new URL ( location ) . searchParams . get ( "config" )
8
17
const firebaseApp = initializeApp ( JSON . parse ( jsonConfig ) )
9
18
const messaging = getMessaging ( firebaseApp )
19
+
10
20
function isChrome ( ) {
11
21
return navigator . userAgent . toLowerCase ( ) . includes ( "chrome" )
12
22
}
23
+
13
24
onBackgroundMessage ( messaging , ( payload ) => {
14
25
const notificationTitle = payload . data . title
15
26
let notificationOptions = {
@@ -24,7 +35,7 @@ onBackgroundMessage(messaging, (payload) => {
24
35
notificationOptions [ "actions" ] = [
25
36
{
26
37
action : payload . data . click_action ,
27
- title : "View details " ,
38
+ title : "View Details " ,
28
39
} ,
29
40
]
30
41
}
@@ -41,3 +52,6 @@ if (isChrome()) {
41
52
}
42
53
} )
43
54
}
55
+
56
+ self . skipWaiting ( )
57
+ clientsClaim ( )
Original file line number Diff line number Diff line change @@ -14,15 +14,20 @@ export default defineConfig({
14
14
vue ( ) ,
15
15
VitePWA ( {
16
16
registerType : "autoUpdate" ,
17
+ strategies : "injectManifest" ,
18
+ injectRegister : null ,
17
19
devOptions : {
18
20
enabled : true ,
21
+ type : "module" ,
22
+ navigateFallback : "index.html" ,
19
23
} ,
20
24
manifest : {
21
25
display : "standalone" ,
22
26
name : "Frappe HR" ,
23
27
short_name : "Frappe HR" ,
24
28
start_url : "/hrms" ,
25
29
description : "Everyday HR & Payroll operations at your fingertips" ,
30
+ theme_color : "#ffffff" ,
26
31
icons : [
27
32
{
28
33
src : "/assets/hrms/manifest/manifest-icon-192.maskable.png" ,
You can’t perform that action at this time.
0 commit comments