- 分享按钮:系统分享 + 二维码卡片(qr.png),移动端移入播放行不再遮挡标题 - og 分享卡片元数据 + og.png 封面;beforeinstallprompt 安装提示 - robots.txt / sitemap.xml / poster.png 传播物料 - .sutra-paper 宣纸底纹:桌面 bg.jpg,移动端竖版 bg-m.jpg,夜间模式罩层适配 - 移动端设置区重排为双列标签网格 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
/**
|
|
* Service Worker:仅做最小化的安装支持与静态壳缓存。
|
|
* - 静态资源(HTML/CSS/JS/图标)走"网络优先、失败回缓存",保证新版本及时生效
|
|
* - /api/tts 不拦截,直接透传网络
|
|
*/
|
|
const CACHE = "fj-shell-v1";
|
|
const SHELL = ["/", "/index.html", "/style.css?v=17", "/app.js?v=15", "/icon.svg", "/icon-180.png", "/icon-192.png", "/icon-512.png", "/manifest.json"];
|
|
|
|
self.addEventListener("install", (e) => {
|
|
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(SHELL)).then(() => self.skipWaiting()));
|
|
});
|
|
|
|
self.addEventListener("activate", (e) => {
|
|
e.waitUntil(
|
|
caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))).then(() => self.clients.claim())
|
|
);
|
|
});
|
|
|
|
self.addEventListener("fetch", (e) => {
|
|
const url = new URL(e.request.url);
|
|
if (e.request.method !== "GET" || url.pathname.startsWith("/api/")) return;
|
|
e.respondWith(
|
|
fetch(e.request)
|
|
.then((resp) => {
|
|
if (resp.ok) {
|
|
const clone = resp.clone();
|
|
caches.open(CACHE).then((c) => c.put(e.request, clone));
|
|
}
|
|
return resp;
|
|
})
|
|
.catch(() => caches.match(e.request))
|
|
);
|
|
});
|