-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice-worker.js
104 lines (89 loc) · 3.12 KB
/
service-worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var cacheName = 'insighter+-v1.2';
self.addEventListener('install', event => {
self.skipWaiting();
event.waitUntil(
caches.open(cacheName)
.then(cache => cache.addAll([
'./index.html',
'./charts.html',
'./login.html',
'./css/sb-admin-2.min.css',
'./css/sb-admin-2.css',
'./vendor/fontawesome-free/less/_variables.less',
'./vendor/fontawesome-free/css/v4-shims.min.css',
'./vendor/fontawesome-free/css/v4-shims.css',
'./vendor/fontawesome-free/css/fontawesome.min.css',
'./vendor/fontawesome-free/css/fontawesome.css',
'./vendor/fontawesome-free/css/all.min.css',
'./vendor/fontawesome-free/css/all.css',
//pasta JS
'./js/demo/chart-area-demo.js',
'./js/demo/chart-bar-demo.js',
'./js/demo/chart-pie-demo.js',
'./js/demo/datatables-demo.js',
'./js/sb-admin-2.js',
'./js/sb-admin-2.min.js',
//pasta vendor/bootstrap
'./vendor/bootstrap/js/bootstrap.bundle.js',
'./vendor/bootstrap/js/bootstrap.bundle.js.map',
'./vendor/bootstrap/js/bootstrap.bundle.min.js',
'./vendor/bootstrap/js/bootstrap.bundle.min.js.map',
'./vendor/bootstrap/js/bootstrap.js',
'./vendor/bootstrap/js/bootstrap.js.map',
'./vendor/bootstrap/js/bootstrap.min.js',
'./vendor/bootstrap/js/bootstrap.min.js.map',
//pasta vendor/chart
'/vendor/chart.js/Chart.bundle.js',
'/vendor/chart.js/Chart.bundle.min.js',
'/vendor/chart.js/Chart.js',
'/vendor/chart.js/Chart.min.js',
//pasta vendor/fontawesome
//pasta
'./img/logo-white.svg',
'./img/undraw_profile.svg'
// './icon/source/Assets.xcassets/AppIcon.appset/64.png',
// './icon/source/Assets.xcassets/AppIcon.appset/128.png',
// './icon/source/Assets.xcassets/AppIcon.appset/144.png',
// './icon/source/Assets.xcassets/AppIcon.appset/152.png',
// './icon/source/Assets.xcassets/AppIcon.appset/167.png',
// './icon/source/Assets.xcassets/AppIcon.appset/180.png',
// './icon/source/Assets.xcassets/AppIcon.appset/196.png',
// './icon/source/Assets.xcassets/AppIcon.appset/512.png',
// './icon/source/Assets.xcassets/AppIcon.appset/1024.png'
]))
);
});
self.addEventListener('install', function(event) {
// Perform install steps
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('message', function (event) {
if (event.data.action === 'skipWaiting') {
self.skipWaiting();
}
});
self.addEventListener('fetch', function (event) {
//Atualizacao internet
event.respondWith(async function () {
try {
return await fetch(event.request);
} catch (err) {
return caches.match(event.request);
}
}());
//Atualizacao cache
/*event.respondWith(
caches.match(event.request)
.then(function (response) {
if (response) {
return response;
}
return fetch(event.request);
})
);*/
});