sw.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. importScripts("/dist/precache-manifest.bc544114b650b56c350c6ee44b252be7.js");
  2. /**
  3. * Welcome to your Workbox-powered service worker!
  4. *
  5. * You'll need to register this file in your web app and you should
  6. * disable HTTP caching for this file too.
  7. * See https://goo.gl/nhQhGp
  8. *
  9. * The rest of the code is auto-generated. Please don't update this file
  10. * directly; instead, make changes to your Workbox build configuration
  11. * and re-run your build process.
  12. * See https://goo.gl/2aRDsh
  13. */
  14. importScripts('/dist/workbox-sw.js')
  15. workbox.core.setCacheNameDetails({ prefix: 'eos-chat' })
  16. /**
  17. * The workboxSW.precacheAndRoute() method efficiently caches and responds to
  18. * requests for URLs in the manifest.
  19. * See https://goo.gl/S9QRab
  20. */
  21. self.__precacheManifest = [].concat(self.__precacheManifest || [])
  22. workbox.precaching.suppressWarnings()
  23. workbox.precaching.precacheAndRoute(self.__precacheManifest, {})
  24. // // const CACHE_NAME = 'mySiteCache';
  25. // // let urlsToCache = [
  26. // // '/',
  27. // // ];
  28. // self.addEventListener('install', function (event) {
  29. // console.log('[ServiceWorker] install')
  30. // // event.waitUntil(
  31. // // caches.open(CACHE_NAME).then(function(caches){
  32. // // console.log('open cache');
  33. // // return caches.addAll(urlsToCache);
  34. // // })
  35. // // )
  36. // })
  37. // self.addEventListener('activate', function (event) {
  38. // console.log('[ServiceWorker] activate')
  39. // // const cacheWhitelist = ['pagesCache', 'blogPostsCache'];
  40. // // event.waitUntil(
  41. // // caches.keys().then(function(cacheNames) {
  42. // // return Promise.all(
  43. // // cacheNames.map(function(cacheName) {
  44. // // if (cacheWhitelist.indexOf(cacheName) === -1) {
  45. // // return caches.delete(cacheName);
  46. // // }
  47. // // })
  48. // // );
  49. // // })
  50. // // );
  51. // })
  52. // self.addEventListener('fetch', function (event) {
  53. // console.log('[ServiceWorker] Fetch', event.request.url)
  54. // })
  55. // self.addEventListener('error', function (event) {
  56. // console.log('[ServiceWorker] error', event)
  57. // })
  58. // self.addEventListener('push', function (event) {
  59. // // console.log('[Service Worker] 收到通知',event);
  60. // console.log(`[Service Worker] 收到的通知数据为: "${event.data.text()}"`)
  61. // function decodeUnicode (str) {
  62. // str = str.replace(/\\/g, '%')
  63. // str = unescape(str)
  64. // str = str.replace(/%/g, '\\')
  65. // str = str.replace(/\\/g, '')
  66. // return str
  67. // }
  68. // let data = JSON.parse(event.data.text())
  69. // const title = decodeUnicode(data.title)
  70. // const options = {
  71. // body: decodeUnicode(data.content),
  72. // icon: 'dice-logo.png'
  73. // }
  74. // event.waitUntil(self.registration.showNotification(title, options))
  75. // })
  76. // // 点击跳转
  77. // self.addEventListener('notificationclick', function (event) {
  78. // event.notification.close()
  79. // // event.waitUntil(
  80. // // clients.openWindow('https://dice.eosget.io/')
  81. // // )
  82. // })