registerServiceWorker.js 772 B

12345678910111213141516171819202122
  1. import { register } from 'register-service-worker';
  2. import { EventBus } from 'base-core-lib';
  3. if (process.env.NODE_ENV === 'production') {
  4. register(`${process.env.BASE_URL}service-worker.js`, {
  5. ready () {
  6. // EventBus.$emit('info', 'ready')
  7. },
  8. cached () {
  9. // EventBus.$emit('info', 'Content has been cached for offline use.')
  10. },
  11. updated () {
  12. EventBus.$emit('updatedSystem', '系统版本已变更,CTRL+F5刷新体验吧~', '更新提醒', 0)
  13. // EventBus.$emit('updatedSystem')
  14. },
  15. offline () {
  16. // EventBus.$emit('info', 'No internet connection found. App is running in offline mode.')
  17. },
  18. error (error) {
  19. // EventBus.$emit('info', 'Error during service worker registration:' + error)
  20. },
  21. });
  22. }