|
6 | 6 | <meta http-equiv="x-ua-compatible" content="ie=edge">
|
7 | 7 | <title>{{if .Title}}{{.Title}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}</title>
|
8 | 8 | <link rel="manifest" href="{{AppSubUrl}}/manifest.json" crossorigin="use-credentials">
|
9 |
| - |
| 9 | + {{if UseServiceWorker}} |
10 | 10 | <script>
|
11 | 11 | if ('serviceWorker' in navigator) {
|
12 |
| - window.addEventListener('load', function() { |
13 |
| - navigator.serviceWorker.register('{{AppSubUrl}}/serviceworker.js').then(function(registration) { |
14 |
| - // Registration was successful |
15 |
| - console.log('ServiceWorker registration successful with scope: ', registration.scope); |
16 |
| - }, function(err) { |
17 |
| - // registration failed :( |
18 |
| - console.log('ServiceWorker registration failed: ', err); |
19 |
| - }); |
20 |
| - }); |
| 12 | + navigator.serviceWorker.register('{{AppSubUrl}}/serviceworker.js').then(function(registration) { |
| 13 | + // Registration was successful |
| 14 | + console.info('ServiceWorker registration successful with scope: ', registration.scope); |
| 15 | + }, function(err) { |
| 16 | + // registration failed :( |
| 17 | + console.info('ServiceWorker registration failed: ', err); |
| 18 | + }); |
21 | 19 | }
|
22 |
| - |
23 | 20 | </script>
|
24 |
| - |
| 21 | + {{else}} |
| 22 | + <script> |
| 23 | + if ('serviceWorker' in navigator) { |
| 24 | + navigator.serviceWorker.getRegistrations().then(function(registrations) { |
| 25 | + registrations.forEach(function(registration) { |
| 26 | + registration.unregister(); |
| 27 | + console.info('ServiceWorker unregistered'); |
| 28 | + }); |
| 29 | + }); |
| 30 | + } |
| 31 | + </script> |
| 32 | + {{end}} |
25 | 33 | <meta name="theme-color" content="{{ThemeColorMetaTag}}">
|
26 | 34 | <meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}" />
|
27 | 35 | <meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}" />
|
|
0 commit comments