Browse Source

Add PWA + ServiceWorker with offline support

Daniel Supernault 4 năm trước cách đây
mục cha
commit
78ee44662c
3 tập tin đã thay đổi với 35 bổ sung1 xóa
  1. 28 0
      public/offline.html
  2. BIN
      public/sw.js
  3. 7 1
      resources/assets/js/app.js

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 28 - 0
public/offline.html


BIN
public/sw.js


+ 7 - 1
resources/assets/js/app.js

@@ -34,6 +34,12 @@ window.App.boot = function() {
 	new Vue({ el: '#content'});
 }
 
+window.addEventListener("load", () => {
+  if ("serviceWorker" in navigator) {
+    navigator.serviceWorker.register("/sw.js");
+  }
+});
+
 window.App.util = {
 	compose: {
 		post: (function() {
@@ -230,4 +236,4 @@ window.App.util = {
 			.attr('width', 34).attr('height', 34);
 	})
 
-};
+};

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác