feat(apps): add Fillcode website HelmRelease

这个提交包含在:
2026-08-24 15:57:41 +08:00 未验证
父节点 556d711ec8
当前提交 c2ca34e67e
修改 3 个文件,包含 37 行新增10 行删除
@@ -392,18 +392,23 @@ data:
// 拦截网络请求
self.addEventListener('fetch', e => {
const url = new URL(e.request.url)
const cdnPath = self.location.hostname.replace(/\./g, '-')
const cdnPrefix = `/${cdnPath}`
const missingCdnPrefix = url.origin === new URL(config.cdnUrl).origin
&& url.pathname !== cdnPrefix
&& !url.pathname.startsWith(`${cdnPrefix}/`)
// 如果请求不是GET方法,直接返回
if (e.request.method !== 'GET') return
// 如果请求的域名不是当前页面的域名
if (url.origin !== self.location.origin) return
// 只处理同源资源和缺少当前站点子路径的CDN资源
if (url.origin !== self.location.origin && !missingCdnPrefix) return
// 过滤__static路径下的请求
if (url.pathname.startsWith('/__static/')) return
// 如果请求的路径不匹配静态资源正则表达式,直接返回
if (!config.staticRegex.test(url.pathname)) return
// 同源请求仍按静态资源规则过滤;CDN缺前缀请求直接修复
if (!missingCdnPrefix && !config.staticRegex.test(url.pathname)) return
// 判断是否是强制需要同源请求
const requiresSameOrigin = ['worker', 'sharedworker', 'serviceworker'].includes(e.request.destination)
@@ -412,15 +417,11 @@ data:
if (requiresSameOrigin) return
// 开始处理静态资源请求
e.respondWith(handleStaticResource(e.request, url))
e.respondWith(handleStaticResource(e.request, url, cdnPath))
})
// 处理静态资源请求
async function handleStaticResource(request, url) {
// 生成CDN子路径
const hostname = self.location.hostname
const cdnPath = hostname.replace(/\./g, '-')
async function handleStaticResource(request, url, cdnPath) {
const targetUrl = config.cdnUrl + cdnPath + url.pathname + url.search
if (config.debug) console.log('PWA-CDN:', url.href, '->', targetUrl)