forked from hamcha/tghandbook
Move service worker to ts file
This commit is contained in:
parent
44d1ed5de7
commit
9bd586d89c
2 changed files with 12 additions and 16 deletions
16
index.html
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
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…
Reference in a new issue