Skip to content

Commit c7777d7

Browse files
committed
deploy: 7e65309
1 parent 2686027 commit c7777d7

8 files changed

Lines changed: 98 additions & 2 deletions

File tree

icons/apple-touch-icon.png

3.22 KB
Loading

icons/icon-192.png

3.54 KB
Loading

icons/icon-512.png

11.9 KB
Loading

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width" />
66
<title>Pushy 管理后台</title>
7-
<link rel="icon" href="/favicon.svg" type="image/svg+xml"><script defer src="/static/js/lib-react.3536f15cb1.js"></script><script defer src="/static/js/lib-router.758b39b1be.js"></script><script defer src="/static/js/881.1c8902cd9a.js"></script><script defer src="/static/js/index.7add8d378a.js"></script><link href="/static/css/index.b942ae8b1e.css" rel="stylesheet"></head>
7+
<meta name="theme-color" content="#4483ED" />
8+
<meta name="description" content="Pushy 热更新管理后台" />
9+
<link rel="manifest" href="/manifest.json" />
10+
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png" />
11+
<link rel="icon" href="/favicon.svg" type="image/svg+xml"><script defer src="/static/js/lib-react.3536f15cb1.js"></script><script defer src="/static/js/lib-router.758b39b1be.js"></script><script defer src="/static/js/881.1c8902cd9a.js"></script><script defer src="/static/js/index.0a52b7e005.js"></script><link href="/static/css/index.b942ae8b1e.css" rel="stylesheet"></head>
812
<body>
913
<main id="main"></main>
1014
</body>

manifest.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "Pushy 管理后台",
3+
"short_name": "Pushy",
4+
"description": "Pushy 热更新管理后台",
5+
"start_url": "/",
6+
"display": "standalone",
7+
"background_color": "#ffffff",
8+
"theme_color": "#4483ED",
9+
"orientation": "any",
10+
"icons": [
11+
{
12+
"src": "/icons/icon-192.png",
13+
"sizes": "192x192",
14+
"type": "image/png"
15+
},
16+
{
17+
"src": "/icons/icon-512.png",
18+
"sizes": "512x512",
19+
"type": "image/png"
20+
},
21+
{
22+
"src": "/icons/icon-512.png",
23+
"sizes": "512x512",
24+
"type": "image/png",
25+
"purpose": "maskable"
26+
}
27+
]
28+
}

static/js/index.0a52b7e005.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/js/index.7add8d378a.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

sw.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const CACHE_NAME = 'pushy-admin-v1';
2+
const STATIC_ASSETS = [
3+
'/',
4+
'/index.html',
5+
];
6+
7+
// Install: precache app shell
8+
self.addEventListener('install', (event) => {
9+
event.waitUntil(
10+
caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
11+
);
12+
self.skipWaiting();
13+
});
14+
15+
// Activate: clean old caches
16+
self.addEventListener('activate', (event) => {
17+
event.waitUntil(
18+
caches.keys().then((keys) =>
19+
Promise.all(
20+
keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))
21+
)
22+
)
23+
);
24+
self.clients.claim();
25+
});
26+
27+
// Fetch: network-first for API, cache-first for static assets
28+
self.addEventListener('fetch', (event) => {
29+
const { request } = event;
30+
const url = new URL(request.url);
31+
32+
// Skip non-GET requests
33+
if (request.method !== 'GET') return;
34+
35+
// Network-first for API calls
36+
if (url.pathname.startsWith('/api')) {
37+
event.respondWith(
38+
fetch(request)
39+
.then((response) => {
40+
if (response.ok) {
41+
const clone = response.clone();
42+
caches.open(CACHE_NAME).then((cache) => cache.put(request, clone));
43+
}
44+
return response;
45+
})
46+
.catch(() => caches.match(request))
47+
);
48+
return;
49+
}
50+
51+
// Cache-first for static assets
52+
event.respondWith(
53+
caches.match(request).then((cached) => {
54+
if (cached) return cached;
55+
return fetch(request).then((response) => {
56+
if (response.ok && url.origin === self.location.origin) {
57+
const clone = response.clone();
58+
caches.open(CACHE_NAME).then((cache) => cache.put(request, clone));
59+
}
60+
return response;
61+
});
62+
})
63+
);
64+
});

0 commit comments

Comments
 (0)