Remove PWA support

This commit is contained in:
chao5
2026-01-01 10:58:50 +08:00
parent 2ce9bb8e5d
commit 0aa1b1764d
3 changed files with 0 additions and 125 deletions
-9
View File
@@ -20,7 +20,6 @@
<meta property="twitter:description" content="JustHTMLs 是一个开源的 HTML 工具集平台,汇集各种轻量级的在线工具,无需安装,即开即用。">
<link rel="icon" href="/favicon.svg">
<link rel="manifest" href="/manifest.json">
<!-- Structured Data (JSON-LD) -->
<script type="application/ld+json">
@@ -910,14 +909,6 @@
loadHomeStats();
loadTools();
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker
.register('/service-worker.js', { updateViaCache: 'none' })
.then((registration) => registration.update())
.catch(() => {});
});
}
</script>
<script src="/assets/clicks.js" defer></script>
</body>
-15
View File
@@ -1,15 +0,0 @@
{
"name": "JustHTMLs - 开源 HTML 工具集",
"short_name": "JustHTMLs",
"start_url": "/",
"display": "standalone",
"background_color": "#0f172a",
"theme_color": "#0f172a",
"icons": [
{
"src": "/favicon.svg",
"sizes": "any",
"type": "image/svg+xml"
}
]
}
-101
View File
@@ -1,101 +0,0 @@
const CACHE_NAME = 'justhtmls-v1.1';
const PRECACHE_URLS = [
'/',
'/index.html',
'/index.json',
'/favicon.svg',
'/assets/vendor/fontawesome/css/all.min.css',
];
const NETWORK_FIRST_PATHS = [
'/index.json',
];
const CACHE_FIRST_PATHS = [
'/assets/vendor/',
'/tools/',
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS))
);
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) =>
Promise.all(
keys
.filter((key) => key !== CACHE_NAME)
.map((key) => caches.delete(key))
)
)
);
self.clients.claim();
});
self.addEventListener('fetch', (event) => {
const { request } = event;
if (request.method !== 'GET' || new URL(request.url).origin !== self.location.origin) {
return;
}
if (request.mode === 'navigate') {
event.respondWith(
fetch(request)
.then((response) => {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
return response;
})
.catch(() => caches.match('/index.html'))
);
return;
}
const { pathname } = new URL(request.url);
if (NETWORK_FIRST_PATHS.includes(pathname)) {
event.respondWith(
fetch(request)
.then((response) => {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
return response;
})
.catch(() => caches.match(request))
);
return;
}
if (CACHE_FIRST_PATHS.some((path) => pathname.startsWith(path))) {
event.respondWith(
caches.open(CACHE_NAME).then((cache) =>
cache.match(request).then((cached) => {
const networkFetch = fetch(request)
.then((response) => {
cache.put(request, response.clone());
return response;
})
.catch(() => cached);
return cached || networkFetch;
})
)
);
return;
}
event.respondWith(
caches.match(request).then((cached) => {
if (cached) {
return cached;
}
return fetch(request).then((response) => {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
return response;
});
})
);
});