浏览代码

Add PWA + ServiceWorker with offline support

Daniel Supernault 4 年之前
父节点
当前提交
78ee44662c
共有 3 个文件被更改,包括 35 次插入1 次删除
  1. 28 0
      public/offline.html
  2. 二进制
      public/sw.js
  3. 7 1
      resources/assets/js/app.js

文件差异内容过多而无法显示
+ 28 - 0
public/offline.html


二进制
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);
 	})
 
-};
+};

部分文件因为文件数量过多而无法显示