You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

serviceworker_js.tmpl 3.1KB

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