Browse Source

Move service worker to ts file

dev
Hamcha 1 year ago
parent
commit
9bd586d89c
Signed by untrusted user: Hamcha GPG Key ID: 41467804B19A3315
  1. 16
      index.html
  2. 12
      src/index.ts

16
index.html

@ -53,21 +53,5 @@
<h2>JavaScript support is required to run this app.</h2>
</noscript>
<script src="src/index.ts" async></script>
<script>
if ("serviceWorker" in navigator) {
const x = "sw.js";
navigator.serviceWorker
.register(x)
.then(function (registration) {
console.log(
"Registration successful, scope is:",
registration.scope
);
})
.catch(function (error) {
console.log("Service worker registration failed, error:", error);
});
}
</script>
</body>
</html>

12
src/index.ts

@ -12,3 +12,15 @@ const defaultTabs = [
defaultTabs.forEach((tab) => {
manager.openTab(tab.page, tab.active);
});
if ("serviceWorker" in navigator) {
const x = "sw.js";
navigator.serviceWorker
.register(x)
.then((registration) => {
console.log("Registration successful, scope is:", registration.scope);
})
.catch((error) => {
console.log("Service worker registration failed, error:", error);
});
}

Loading…
Cancel
Save