forked from b3log/pipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.min.js
1 lines (1 loc) · 2.44 KB
/
sw.min.js
1
!function(){return function e(t,r,n){function i(u,c){if(!r[u]){if(!t[u]){var s="function"==typeof require&&require;if(!c&&s)return s(u,!0);if(o)return o(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var p=r[u]={exports:{}};t[u][0].call(p.exports,function(e){return i(t[u][1][e]||e)},p,p.exports,e,t,r,n)}return r[u].exports}for(var o="function"==typeof require&&require,u=0;u<n.length;u++)i(n[u]);return i}}()({1:[function(e,t,r){t.exports={Server:"http://localhost:5897",StaticServer:"",StaticResourceVersion:"1539735964497",OpenRegister:!0,RuntimeMode:"dev",LogLevel:"debug",ShowSQL:!1,SessionSecret:"BEYOND",SessionMaxAge:86400,SQLite:"${home}/pipe.db",MySQL:"user:password@(localhost:3306)/pipe?charset=utf8mb4&parseTime=True&loc=Local",StaticRoot:"",Port:"5897",AxiosBaseURL:"/api",MockServer:"http://localhost:8888"}},{}],2:[function(e,t,r){"use strict";var n,i=e("../pipe.json"),o=(n=i)&&n.__esModule?n:{default:n};var u=o.default.StaticResourceVersion,c=o.default.StaticServer||o.default.Server,s=o.default.Server;self.addEventListener("activate",function(e){e.waitUntil(caches.keys().then(function(e){return Promise.all(e.map(async function(e){var t=await navigator.storage.estimate();return"pipe-html"!==e&&"pipe-image"!==e&&e!=="pipe-static-"+u?caches.delete(e):t.usage/t.quota>.8&&("pipe-html"===e||"pipe-image"===e)?(console.log("clear "+e+" cache"),caches.delete(e)):void 0}))}))}),self.addEventListener("fetch",function(e){0===e.request.headers.get("accept").indexOf("text/html")||"*/*"===e.request.headers.get("accept")&&-1===e.request.url.indexOf("/js/")&&!e.request.url.endsWith(".js")||0===e.request.headers.get("accept").indexOf("application/json")&&0===e.request.url.indexOf(s+"/api")?e.respondWith(fetch(e.request).then(function(t){return-1===e.request.url.indexOf(s)?t:caches.open("pipe-html").then(function(r){return"POST"!==e.request.method&&"DELETE"!==e.request.method&&"PUT"!==e.request.method&&r.put(e.request,t.clone()),t})}).catch(function(){return caches.match(e.request)})):e.respondWith(caches.match(e.request).then(function(t){return t||fetch(e.request).then(function(t){return e.request.url.indexOf("https://img.hacpai.com/")>-1?caches.open("pipe-image").then(function(r){return r.put(e.request,t.clone()),t}):e.request.url.indexOf(c)>-1?caches.open("pipe-static-"+u).then(function(r){return r.put(e.request,t.clone()),t}):t}).catch(function(){console.log("fetch "+e.request.url+" error")})}))})},{"../pipe.json":1}]},{},[2]);