shulan-quote 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.html +1497 -1488
- package/manifest.webmanifest +4 -3
- package/package.json +3 -2
- package/sw.js +45 -0
package/manifest.webmanifest
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "树懒智汇家报价系统",
|
|
3
3
|
"short_name": "树懒报价",
|
|
4
4
|
"description": "智能家居配置报价系统 · 480 款产品库 · 一键报价导出",
|
|
5
|
-
"start_url": "
|
|
6
|
-
"scope": "
|
|
5
|
+
"start_url": "/shulan-quote/index.html",
|
|
6
|
+
"scope": "/shulan-quote/",
|
|
7
7
|
"display": "standalone",
|
|
8
8
|
"orientation": "any",
|
|
9
9
|
"background_color": "#f4f6f9",
|
|
@@ -26,5 +26,6 @@
|
|
|
26
26
|
"type": "image/png",
|
|
27
27
|
"purpose": "maskable"
|
|
28
28
|
}
|
|
29
|
-
]
|
|
29
|
+
],
|
|
30
|
+
"id": "/shulan-quote/"
|
|
30
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shulan-quote",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "quote tool",
|
|
5
5
|
"private": false,
|
|
6
6
|
"files": [
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"icon-192.png",
|
|
10
10
|
"icon-512.png",
|
|
11
11
|
"icon-maskable-512.png",
|
|
12
|
-
"apple-touch-icon.png"
|
|
12
|
+
"apple-touch-icon.png",
|
|
13
|
+
"sw.js"
|
|
13
14
|
]
|
|
14
15
|
}
|
package/sw.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* 树懒智汇家报价系统 Service Worker(云端版)
|
|
2
|
+
原则:index.html/manifest 一律网络直连,绝不缓存,确保客户每次打开都是最新版;
|
|
3
|
+
图标类静态资源可缓存。
|
|
4
|
+
*/
|
|
5
|
+
var CACHE = 'slzj-cdn-v1';
|
|
6
|
+
var STATIC = ['./icon-192.png','./icon-512.png','./apple-touch-icon.png'];
|
|
7
|
+
|
|
8
|
+
self.addEventListener('install', function(e){
|
|
9
|
+
self.skipWaiting();
|
|
10
|
+
e.waitUntil(caches.open(CACHE).then(function(c){ return c.addAll(STATIC).catch(function(){}); }));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
self.addEventListener('activate', function(e){
|
|
14
|
+
e.waitUntil(
|
|
15
|
+
caches.keys().then(function(ks){
|
|
16
|
+
return Promise.all(ks.map(function(k){ if(k !== CACHE) return caches.delete(k); }));
|
|
17
|
+
}).then(function(){ return self.clients.claim(); })
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
self.addEventListener('fetch', function(e){
|
|
22
|
+
if(e.request.method !== 'GET') return;
|
|
23
|
+
var u;
|
|
24
|
+
try{ u = new URL(e.request.url); }catch(err){ return; }
|
|
25
|
+
if(u.origin !== self.location.origin) return;
|
|
26
|
+
|
|
27
|
+
/* 页面与清单:网络优先,且不写缓存 —— 防止旧版被缓存挡住自动升级 */
|
|
28
|
+
if(/\.html?$/.test(u.pathname) || /\.webmanifest$/.test(u.pathname) || /\/$/.test(u.pathname)){
|
|
29
|
+
e.respondWith(fetch(e.request, {cache:'no-store'}));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
/* 图标等静态资源:缓存优先 */
|
|
33
|
+
if(/\.(png|jpg|jpeg|svg|ico|woff2?)$/.test(u.pathname)){
|
|
34
|
+
e.respondWith(
|
|
35
|
+
caches.match(e.request).then(function(hit){
|
|
36
|
+
if(hit) return hit;
|
|
37
|
+
return fetch(e.request).then(function(res){
|
|
38
|
+
var copy = res.clone();
|
|
39
|
+
caches.open(CACHE).then(function(c){ c.put(e.request, copy).catch(function(){}); });
|
|
40
|
+
return res;
|
|
41
|
+
}).catch(function(){ return fetch(e.request); });
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
});
|