Compare commits
2 Commits
521455f156
...
79fa7984a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 79fa7984a1 | |||
| 30abecc07d |
@@ -1,20 +1,10 @@
|
|||||||
// /home/Autopartes/pos/static/pwa/sw.js
|
// /home/Autopartes/pos/static/pwa/sw.js
|
||||||
// Nexus POS — Service Worker v5
|
// Nexus POS — Service Worker v6
|
||||||
// Self-contained vanilla JS. No external imports.
|
// Self-contained vanilla JS. No external imports.
|
||||||
|
|
||||||
const CACHE_NAME = 'nexus-pos-v5';
|
const CACHE_NAME = 'nexus-pos-v6';
|
||||||
|
|
||||||
const APP_SHELL = [
|
const APP_SHELL = [
|
||||||
'/pos/login',
|
|
||||||
'/pos/sale',
|
|
||||||
'/pos/catalog',
|
|
||||||
'/pos/inventory',
|
|
||||||
'/pos/customers',
|
|
||||||
'/pos/invoicing',
|
|
||||||
'/pos/accounting',
|
|
||||||
'/pos/dashboard',
|
|
||||||
'/pos/config',
|
|
||||||
'/pos/reports',
|
|
||||||
'/pos/static/css/tokens.css',
|
'/pos/static/css/tokens.css',
|
||||||
'/pos/static/css/common.css',
|
'/pos/static/css/common.css',
|
||||||
'/pos/static/js/app-init.js',
|
'/pos/static/js/app-init.js',
|
||||||
@@ -132,8 +122,8 @@ self.addEventListener('fetch', function (event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't cache login page
|
// HTML pages -> network-first (always fresh)
|
||||||
if (url.pathname === '/pos/login' || url.pathname === '/pos/login/') {
|
if (req.headers.get('accept') && req.headers.get('accept').indexOf('text/html') !== -1) {
|
||||||
event.respondWith(networkFirst(req));
|
event.respondWith(networkFirst(req));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -181,7 +171,7 @@ self.addEventListener('fetch', function (event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything else -> cache-first
|
// Everything else (JS, CSS, images) -> cache-first
|
||||||
event.respondWith(cacheFirst(req));
|
event.respondWith(cacheFirst(req));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,20 @@
|
|||||||
<script src="/pos/static/js/chat.js" defer></script>
|
<script src="/pos/static/js/chat.js" defer></script>
|
||||||
<script src="/pos/static/js/sync-engine.js" defer></script>
|
<script src="/pos/static/js/sync-engine.js" defer></script>
|
||||||
<script src="/pos/static/js/onboarding.js" defer></script>
|
<script src="/pos/static/js/onboarding.js" defer></script>
|
||||||
<script>if('serviceWorker' in navigator){navigator.serviceWorker.register('/pos/sw.js',{scope:'/pos/'});}</script>
|
<script>
|
||||||
|
if('serviceWorker' in navigator){
|
||||||
|
navigator.serviceWorker.register('/pos/sw.js',{scope:'/pos/'}).then(function(reg){
|
||||||
|
reg.addEventListener('updatefound', function(){
|
||||||
|
var newWorker = reg.installing;
|
||||||
|
newWorker.addEventListener('statechange', function(){
|
||||||
|
if(newWorker.state === 'activated'){
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<script src="/pos/static/js/pwa-install.js" defer></script>
|
<script src="/pos/static/js/pwa-install.js" defer></script>
|
||||||
<script src="/pos/static/js/brand-catalog.js?v=3" defer></script>
|
<script src="/pos/static/js/brand-catalog.js?v=3" defer></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user