fixed service worker
This commit is contained in:
@@ -303,7 +303,7 @@ $additionalHead = [
|
||||
<script>
|
||||
$(function() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/assets/pwa/patching-sw.js')
|
||||
navigator.serviceWorker.register('/Patching/sw', { scope: '/' })
|
||||
.then(registration => {
|
||||
console.log('Patching PWA Service Worker registered with scope:', registration.scope);
|
||||
})
|
||||
|
||||
@@ -240,6 +240,27 @@ class PatchingController extends mfBaseController {
|
||||
$this->redirect("Patching","Index", $qs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function swAction() {
|
||||
$javascript = "self.addEventListener('install', event => {
|
||||
console.log('Patching PWA Service Worker: Installing...');
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
console.log('Patching PWA Service Worker: Activating...');
|
||||
});
|
||||
|
||||
console.log('Patching PWA Service Worker: Script loaded.');";
|
||||
|
||||
header("Content-Type: application/javascript");
|
||||
header("Service-Worker-Allowed: /");
|
||||
header("Cache-Control: no-cache");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
|
||||
echo $javascript;
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
self.addEventListener('install', event => {
|
||||
console.log('Patching PWA Service Worker: Installing...');
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
console.log('Patching PWA Service Worker: Activating...');
|
||||
});
|
||||
|
||||
console.log('Patching PWA Service Worker: Script loaded.');
|
||||
Reference in New Issue
Block a user