mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-18 13:14:39 +03:00
Progressive Web App (#1678)
* pwa support * Create go.yml * Delete .github/workflows/go.yml
This commit is contained in:
39
web/assets/js/sw.js
Normal file
39
web/assets/js/sw.js
Normal file
@@ -0,0 +1,39 @@
|
||||
var self = this;
|
||||
|
||||
var filesToCache = [
|
||||
'/'
|
||||
];
|
||||
|
||||
self.addEventListener('install', function (e) {
|
||||
e.waitUntil(
|
||||
caches.open('3xPanel').then(function (cache) {
|
||||
return cache.addAll(filesToCache);
|
||||
})
|
||||
);
|
||||
});
|
||||
self.addEventListener('activate', function (event) {
|
||||
event.waitUntil(
|
||||
caches.keys().then(function (cacheNames) {
|
||||
return Promise.all(
|
||||
cacheNames.filter(function (cacheName) {
|
||||
}).map(function (cacheName) {
|
||||
return caches.delete(cacheName);
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
self.addEventListener('fetch', function (event) {
|
||||
event.respondWith(
|
||||
caches.open('mysite-dynamic').then(function (cache) {
|
||||
return cache.match(event.request).then(function (response) {
|
||||
return response || fetch(event.request).then(function (response) {
|
||||
cache.put(event.request, response.clone());
|
||||
return response;
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
console.clear();
|
||||
Reference in New Issue
Block a user