|
| 1 | +var STATIC_CACHE = 'static-cache-v1'; |
| 2 | +var urlsToCache = [ |
| 3 | + // js |
| 4 | + '{{AppSubUrl}}/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js', |
| 5 | + '{{AppSubUrl}}/vendor/plugins/jquery/jquery.min.js', |
| 6 | + '{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.js', |
| 7 | + '{{AppSubUrl}}/js/index.js?v={{MD5 AppVer}}', |
| 8 | + '{{AppSubUrl}}/js/draw.js', |
| 9 | + '{{AppSubUrl}}/vendor/plugins/clipboard/clipboard.min.js', |
| 10 | + '{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.js', |
| 11 | + '{{AppSubUrl}}/vendor/plugins/vue/vue.min.js', |
| 12 | + '{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js', |
| 13 | + '{{AppSubUrl}}/vendor/plugins/cssrelpreload/loadCSS.min.js', |
| 14 | + '{{AppSubUrl}}/vendor/plugins/cssrelpreload/cssrelpreload.min.js', |
| 15 | + '{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.js', |
| 16 | + '{{AppSubUrl}}/vendor/plugins/highlight/highlight.pack.js', |
| 17 | + '{{AppSubUrl}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js', |
| 18 | + '{{AppSubUrl}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js', |
| 19 | + '{{AppSubUrl}}/vendor/plugins/codemirror/addon/mode/loadmode.js', |
| 20 | + '{{AppSubUrl}}/vendor/plugins/codemirror/mode/meta.js', |
| 21 | + '{{AppSubUrl}}/vendor/plugins/simplemde/simplemde.min.js', |
| 22 | + |
| 23 | + // css |
| 24 | + '{{AppSubUrl}}/vendor/assets/font-awesome/css/font-awesome.min.css', |
| 25 | + '{{AppSubUrl}}/vendor/assets/octicons/octicons.min.css', |
| 26 | + '{{AppSubUrl}}/vendor/plugins/simplemde/simplemde.min.css', |
| 27 | + '{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.css', |
| 28 | + '{{AppSubUrl}}/vendor/plugins/tribute/tribute.css', |
| 29 | + '{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.css', |
| 30 | + '{{AppSubUrl}}/css/index.css?v={{MD5 AppVer}}', |
| 31 | + '{{AppSubUrl}}/vendor/plugins/highlight/github.css', |
| 32 | + '{{AppSubUrl}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css', |
| 33 | + '{{AppSubUrl}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css', |
| 34 | + '{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.css', |
| 35 | +{{if ne DefaultTheme "gitea"}} |
| 36 | + '{{AppSubUrl}}/css/theme-{{DefaultTheme}}.css', |
| 37 | +{{end}} |
| 38 | + |
| 39 | + // img |
| 40 | + '{{AppSubUrl}}/img/gitea-sm.png', |
| 41 | + '{{AppSubUrl}}/img/gitea-lg.png', |
| 42 | + |
| 43 | + // fonts |
| 44 | + '{{AppSubUrl}}/vendor/plugins/semantic/themes/default/assets/fonts/icons.woff2', |
| 45 | + '{{AppSubUrl}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6', |
| 46 | + '{{AppSubUrl}}/vendor/assets/lato-fonts/lato-v14-latin-regular.woff2', |
| 47 | + '{{AppSubUrl}}/vendor/assets/lato-fonts/lato-v14-latin-700.woff2' |
| 48 | +]; |
| 49 | + |
| 50 | +self.addEventListener('install', function (event) { |
| 51 | + // Perform install steps |
| 52 | + event.waitUntil( |
| 53 | + caches.open(STATIC_CACHE) |
| 54 | + .then(function (cache) { |
| 55 | + return cache.addAll(urlsToCache); |
| 56 | + }) |
| 57 | + ); |
| 58 | +}); |
| 59 | + |
| 60 | +self.addEventListener('fetch', function (event) { |
| 61 | + event.respondWith( |
| 62 | + caches.match(event.request) |
| 63 | + .then(function (response) { |
| 64 | + // Cache hit - return response |
| 65 | + if (response) { |
| 66 | + return response; |
| 67 | + } |
| 68 | + return fetch(event.request); |
| 69 | + } |
| 70 | + ) |
| 71 | + ); |
| 72 | +}); |
0 commit comments