增加主题及企微

This commit is contained in:
super committed 2026-03-29 00:55:01 +08:00
1 parent 42e29fd747
commit 20271ada61
35 files changed
+2424 -523

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
const CACHE_NAME = 'hxops-shell-v2';
const OFFLINE_ASSETS = ['/', '/workspace', '/manifest.webmanifest', '/vite.svg'];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => cache.addAll(OFFLINE_ASSETS)).catch(() => null)
);
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.request;
if (request.method !== 'GET') return;
const url = new URL(request.url);
if (url.origin !== self.location.origin) return;
if (url.pathname.startsWith('/api/')) return;
if (url.pathname.startsWith('/@vite/')) return;
if (url.pathname.includes('/__vite_ping')) return;
if (request.mode === 'navigate') {
event.respondWith(
fetch(request).catch(() => caches.match('/workspace').then((res) => res || caches.match('/')))
);
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)).catch(() => null);
return response;
})
.catch(() => caches.match('/vite.svg'));
})
);
});