feat(P21PWA2-1,P21PWA2-2,P21PWA2-3): 深链路由守卫/离线审批队列/SW缓存策略升级

这个提交包含在:
2026-03-12 12:34:56 +08:00
父节点 102d3dcc2b
当前提交 9112383d23
共修改 10 个文件,包含 975 行新增和 163 行删除
+40 -2
查看文件
@@ -38,11 +38,49 @@ export default defineConfig({
},
workbox: {
navigateFallback: "/index.html",
navigateFallbackDenylist: [/^\/api\//],
globPatterns: ["**/*.{js,css,html,ico,png,svg,webmanifest}"],
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.startsWith("/api/"),
handler: "NetworkOnly",
urlPattern: ({ request, url }) =>
["script", "style", "font", "image"].includes(request.destination) || url.pathname.endsWith(".webmanifest"),
handler: "StaleWhileRevalidate",
options: {
cacheName: "app-static-runtime",
cacheableResponse: {
statuses: [0, 200],
},
expiration: {
maxEntries: 120,
maxAgeSeconds: 7 * 24 * 60 * 60,
},
},
},
{
urlPattern: ({ request, url }) => {
if (request.method !== "GET") {
return false;
}
return (
url.pathname === "/api/me" ||
url.pathname.startsWith("/api/workflow/tasks") ||
url.pathname.startsWith("/api/workflow/approvers") ||
url.pathname.startsWith("/api/notifications")
);
},
handler: "NetworkFirst",
options: {
cacheName: "app-api-runtime",
networkTimeoutSeconds: 3,
cacheableResponse: {
statuses: [200],
},
expiration: {
maxEntries: 80,
maxAgeSeconds: 30 * 60,
},
},
},
],
},