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.

76 lines
2.9 KiB

  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. // css
  23. '{{AppSubUrl}}/vendor/assets/font-awesome/css/font-awesome.min.css',
  24. '{{AppSubUrl}}/vendor/assets/octicons/octicons.min.css',
  25. '{{AppSubUrl}}/vendor/plugins/simplemde/simplemde.min.css',
  26. '{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.css',
  27. '{{AppSubUrl}}/vendor/plugins/tribute/tribute.css',
  28. '{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.css',
  29. '{{AppSubUrl}}/css/index.css?v={{MD5 AppVer}}',
  30. '{{AppSubUrl}}/vendor/plugins/highlight/github.css',
  31. '{{AppSubUrl}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
  32. '{{AppSubUrl}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
  33. '{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.css',
  34. {{if .IsSigned }}
  35. {{ if ne .SignedUser.Theme "gitea" }}
  36. '{{AppSubUrl}}/css/theme-{{.SignedUser.Theme}}.css'
  37. {{end}}
  38. {{else if ne DefaultTheme "gitea"}}
  39. '{{AppSubUrl}}/css/theme-{{DefaultTheme}}.css'
  40. {{end}}
  41. // img
  42. '{{AppSubUrl}}/img/gitea-sm.png',
  43. '{{AppSubUrl}}/img/gitea-lg.png',
  44. // fonts
  45. '{{AppSubUrl}}/vendor/plugins/semantic/themes/default/assets/fonts/icons.woff2',
  46. '{{AppSubUrl}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6',
  47. '{{AppSubUrl}}/vendor/assets/lato-fonts/lato-v14-latin-regular.woff2',
  48. '{{AppSubUrl}}/vendor/assets/lato-fonts/lato-v14-latin-700.woff2'
  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. self.addEventListener('fetch', function (event) {
  60. event.respondWith(
  61. caches.match(event.request)
  62. .then(function (response) {
  63. // Cache hit - return response
  64. if (response) {
  65. return response;
  66. }
  67. return fetch(event.request);
  68. }
  69. )
  70. );
  71. });