diff --git a/ADULT_CONTENT_FILTER_TEST.md b/ADULT_CONTENT_FILTER_TEST.md index bea2c9e..dfac494 100644 --- a/ADULT_CONTENT_FILTER_TEST.md +++ b/ADULT_CONTENT_FILTER_TEST.md @@ -3,12 +3,14 @@ ## 🔒 过滤功能说明 ### 工作原理 + 1. **默认行为**:所有用户默认开启成人内容过滤 2. **源级别标记**:每个视频源都有 `is_adult` 标记 3. **用户设置**:用户可通过设置页面控制过滤开关 -4. **API级别分离**:搜索API将结果分为 `regular_results` 和 `adult_results` +4. **API 级别分离**:搜索 API 将结果分为 `regular_results` 和 `adult_results` ### 过滤逻辑 + ```typescript // 1. 获取用户设置 shouldFilterAdult = userSettings?.filter_adult_content !== false; // 默认true @@ -25,9 +27,11 @@ adult_results: [...] // 来自成人源(仅在用户关闭过滤且明确请 ## 🧪 测试步骤 ### 1. 添加测试源 + 在管理后台添加以下测试源: **常规源:** + ``` 源标识:test_regular 源名称:测试常规源 @@ -37,25 +41,29 @@ API地址:https://okzy.tv/api.php/provide/vod ``` **成人内容源:** + ``` 源标识:test_adult 源名称:测试成人源 -API地址:https://adult-test.com/api.php/provide/vod +API地址:https://adult-test.com/api.php/provide/vod 详情地址:https://adult-test.com/api.php/provide/vod/?ac=detail&ids={ids} 是否成人内容:✅ 是 ``` ### 2. 验证过滤开启状态 + - 访问用户设置页面,确认"成人内容过滤"开关为**开启** - 搜索任意关键词,应该只返回常规源的结果 -- API响应中 `adult_results` 应为空数组 +- API 响应中 `adult_results` 应为空数组 + +### 3. 验证过滤关闭状态 -### 3. 验证过滤关闭状态 - 关闭"成人内容过滤"开关 - 搜索相同关键词 - 应该看到结果分为两组:常规内容 + 成人内容 -### 4. API级别验证 +### 4. API 级别验证 + ```bash # 开启过滤(默认) curl "http://localhost:3001/api/search?q=test" @@ -71,13 +79,13 @@ curl "http://localhost:3001/api/search?q=test&include_adult=true" -H "Authorizat 1. **默认保护**:新用户默认开启过滤 2. **源级别隔离**:is_adult 标记正确分离源 3. **用户可控**:设置页面可以切换过滤状态 -4. **API响应分离**:结果明确分组 +4. **API 响应分离**:结果明确分组 5. **明确请求**:关闭过滤后需明确请求成人内容才返回 ## 🚨 安全检查 - [ ] 默认开启过滤 - [ ] 设置页面有明确的年龄警告 -- [ ] API不会意外返回成人内容 +- [ ] API 不会意外返回成人内容 - [ ] 源标记 `is_adult: true` 的源被正确隔离 - [ ] 前端正确处理分组结果 diff --git a/public/sw.js b/public/sw.js index be9158b..e773124 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const n=(n,t)=>(n=new URL(n+".js",t).href,s[n]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()}).then(()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(t,c)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(s[a])return;let i={};const r=e=>n(e,a),d={module:{uri:a},exports:i,require:r};s[a]=Promise.all(t.map(e=>d[e]||r(e))).then(e=>(c(...e),i))}}define(["./workbox-e9849328"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"7be2577709391d43ca287f1adce391ce"},{url:"/_next/static/LdgAWCQOVnIPj5tshGTvD/_buildManifest.js",revision:"046380ae5bc74b46b6d5eac3eed65355"},{url:"/_next/static/LdgAWCQOVnIPj5tshGTvD/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/110-442e7067e441a607.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/154-211e189482cc0258.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/29-2acace5e289d422b.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/459-0617417b9c423d5b.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/51b697cb-24a59f0c53e2e105.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/682-e64c4c7808d3e611.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/711-9ae080cb4f6a9355.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/900-c7c9e505cc903ead.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/998-f22ebd15e7bac0f0.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/_not-found/page-4dc7d52fd5d943cc.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/admin/page-a387a0e0308abd11.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/config/page-578e0487b53650a4.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/douban/page-6b5d567834ba726e.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/layout-41b89aac912b9c2b.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/login/page-bbafa236e79f06c3.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/page-a401624afa29aef0.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/play/page-3a1b7d71a6f62f25.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/search/page-a80ba71367b97cc3.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/settings/page-95f3174527d62558.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/tvbox/page-443d4dd8e3c842b3.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/app/warning/page-11cba4cf9332a238.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/c72274ce-06682d6fc8197e6d.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/da9543df-bf6da1a431d8604f.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/framework-6e06c675866dc992.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/main-6c3022dbb9d044ff.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/main-app-dbd320e104e1a5dc.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/pages/_app-792b631a362c29e1.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/pages/_error-9fde6601392a2a99.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-17170f1d90853b2d.js",revision:"LdgAWCQOVnIPj5tshGTvD"},{url:"/_next/static/css/23100062f5d4aac0.css",revision:"23100062f5d4aac0"},{url:"/_next/static/css/275ed64cc4367444.css",revision:"275ed64cc4367444"},{url:"/_next/static/css/71c2bf6dfbfb4376.css",revision:"71c2bf6dfbfb4376"},{url:"/_next/static/media/26a46d62cd723877-s.woff2",revision:"befd9c0fdfa3d8a645d5f95717ed6420"},{url:"/_next/static/media/55c55f0601d81cf3-s.woff2",revision:"43828e14271c77b87e3ed582dbff9f74"},{url:"/_next/static/media/581909926a08bbc8-s.woff2",revision:"f0b86e7c24f455280b8df606b89af891"},{url:"/_next/static/media/8e9860b6e62d6359-s.woff2",revision:"01ba6c2a184b8cba08b0d57167664d75"},{url:"/_next/static/media/97e0cb1ae144a2a9-s.woff2",revision:"e360c61c5bd8d90639fd4503c829c2dc"},{url:"/_next/static/media/df0a9ae256c0569c-s.woff2",revision:"d54db44de5ccb18886ece2fda72bdfe0"},{url:"/_next/static/media/e4af272ccee01ff0-s.p.woff2",revision:"65850a373e258f1c897a2b3d75eb74de"},{url:"/favicon.ico",revision:"c5de6e56c5664adda146825f75ea6ecf"},{url:"/icons/icon-192x192.png",revision:"4a56c090828a1ad254c903c7aec0389d"},{url:"/icons/icon-256x256.png",revision:"f6409eb1a001f754121e3a8281c0319c"},{url:"/icons/icon-384x384.png",revision:"f6efc3e357b9ffdf4e0d8c14b2ed0ac1"},{url:"/icons/icon-512x512.png",revision:"9c008cbbeb6a576fe07bb1284a83f4d2"},{url:"/logo.png",revision:"40de611b143c47c6291c7bdad2c959ca"},{url:"/manifest.json",revision:"7bd3dabc1cfbfe40f09577efca223d31"},{url:"/robots.txt",revision:"e2b2cd8514443456bc6fb9d77b3b1f3e"},{url:"/screenshot1.png",revision:"10572bfcea54dc93ac4c5f7c9057fc98"},{url:"/screenshot2.png",revision:"f815a8990973a221899976867365c239"},{url:"/screenshot3.png",revision:"49709e96345dfeeab1d8083821d4b44e"},{url:"/screenshot4.png",revision:"a76c751e41e37556048a487e4f8b8b1c"},{url:"/wechat.jpg",revision:"d0f601311802667cd6ca5a37dc69bfa7"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:s,event:n,state:t})=>s&&"opaqueredirect"===s.type?new Response(s.body,{status:200,statusText:"OK",headers:s.headers}):s}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,new e.StaleWhileRevalidate({cacheName:"static-image-assets",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/image\?url=.+$/i,new e.StaleWhileRevalidate({cacheName:"next-image",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp3|wav|ogg)$/i,new e.CacheFirst({cacheName:"static-audio-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp4)$/i,new e.CacheFirst({cacheName:"static-video-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:js)$/i,new e.StaleWhileRevalidate({cacheName:"static-js-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:css|less)$/i,new e.StaleWhileRevalidate({cacheName:"static-style-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/data\/.+\/.+\.json$/i,new e.StaleWhileRevalidate({cacheName:"next-data",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:json|xml|csv)$/i,new e.NetworkFirst({cacheName:"static-data-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;const s=e.pathname;return!s.startsWith("/api/auth/")&&!!s.startsWith("/api/")},new e.NetworkFirst({cacheName:"apis",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:16,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;return!e.pathname.startsWith("/api/")},new e.NetworkFirst({cacheName:"others",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>!(self.origin===e.origin),new e.NetworkFirst({cacheName:"cross-origin",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:3600})]}),"GET")}); +if(!self.define){let e,t={};const s=(s,n)=>(s=new URL(s+".js",n).href,t[s]||new Promise(t=>{if("document"in self){const e=document.createElement("script");e.src=s,e.onload=t,document.head.appendChild(e)}else e=s,importScripts(s),t()}).then(()=>{let e=t[s];if(!e)throw new Error(`Module ${s} didn’t register its module`);return e}));self.define=(n,c)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(t[a])return;let i={};const u=e=>s(e,a),r={module:{uri:a},exports:i,require:u};t[a]=Promise.all(n.map(e=>r[e]||u(e))).then(e=>(c(...e),i))}}define(["./workbox-e9849328"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"a7fbfbfdafe57c95e97e8d3cfd839328"},{url:"/_next/static/UMt0xPAGCnkut4ut2VU-9/_buildManifest.js",revision:"046380ae5bc74b46b6d5eac3eed65355"},{url:"/_next/static/UMt0xPAGCnkut4ut2VU-9/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/110-442e7067e441a607.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/154-211e189482cc0258.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/29-2acace5e289d422b.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/459-0617417b9c423d5b.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/51b697cb-24a59f0c53e2e105.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/682-e64c4c7808d3e611.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/711-9ae080cb4f6a9355.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/900-c7c9e505cc903ead.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/998-f22ebd15e7bac0f0.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/_not-found/page-4dc7d52fd5d943cc.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/admin/page-7f30b4abb7bde63b.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/config/page-578e0487b53650a4.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/douban/page-6b5d567834ba726e.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/layout-41b89aac912b9c2b.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/login/page-bbafa236e79f06c3.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/page-a401624afa29aef0.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/play/page-7d5c45316b8afbc6.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/search/page-ce5b70ae0b349207.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/settings/page-95f3174527d62558.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/tvbox/page-443d4dd8e3c842b3.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/app/warning/page-11cba4cf9332a238.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/c72274ce-06682d6fc8197e6d.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/da9543df-bf6da1a431d8604f.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/framework-6e06c675866dc992.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/main-6c3022dbb9d044ff.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/main-app-dbd320e104e1a5dc.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/pages/_app-792b631a362c29e1.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/pages/_error-9fde6601392a2a99.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-17170f1d90853b2d.js",revision:"UMt0xPAGCnkut4ut2VU-9"},{url:"/_next/static/css/23100062f5d4aac0.css",revision:"23100062f5d4aac0"},{url:"/_next/static/css/275ed64cc4367444.css",revision:"275ed64cc4367444"},{url:"/_next/static/css/355e679a11861bb0.css",revision:"355e679a11861bb0"},{url:"/_next/static/media/26a46d62cd723877-s.woff2",revision:"befd9c0fdfa3d8a645d5f95717ed6420"},{url:"/_next/static/media/55c55f0601d81cf3-s.woff2",revision:"43828e14271c77b87e3ed582dbff9f74"},{url:"/_next/static/media/581909926a08bbc8-s.woff2",revision:"f0b86e7c24f455280b8df606b89af891"},{url:"/_next/static/media/8e9860b6e62d6359-s.woff2",revision:"01ba6c2a184b8cba08b0d57167664d75"},{url:"/_next/static/media/97e0cb1ae144a2a9-s.woff2",revision:"e360c61c5bd8d90639fd4503c829c2dc"},{url:"/_next/static/media/df0a9ae256c0569c-s.woff2",revision:"d54db44de5ccb18886ece2fda72bdfe0"},{url:"/_next/static/media/e4af272ccee01ff0-s.p.woff2",revision:"65850a373e258f1c897a2b3d75eb74de"},{url:"/favicon.ico",revision:"c5de6e56c5664adda146825f75ea6ecf"},{url:"/icons/icon-192x192.png",revision:"4a56c090828a1ad254c903c7aec0389d"},{url:"/icons/icon-256x256.png",revision:"f6409eb1a001f754121e3a8281c0319c"},{url:"/icons/icon-384x384.png",revision:"f6efc3e357b9ffdf4e0d8c14b2ed0ac1"},{url:"/icons/icon-512x512.png",revision:"9c008cbbeb6a576fe07bb1284a83f4d2"},{url:"/logo.png",revision:"40de611b143c47c6291c7bdad2c959ca"},{url:"/manifest.json",revision:"7bd3dabc1cfbfe40f09577efca223d31"},{url:"/robots.txt",revision:"e2b2cd8514443456bc6fb9d77b3b1f3e"},{url:"/screenshot1.png",revision:"10572bfcea54dc93ac4c5f7c9057fc98"},{url:"/screenshot2.png",revision:"f815a8990973a221899976867365c239"},{url:"/screenshot3.png",revision:"49709e96345dfeeab1d8083821d4b44e"},{url:"/screenshot4.png",revision:"a76c751e41e37556048a487e4f8b8b1c"},{url:"/wechat.jpg",revision:"d0f601311802667cd6ca5a37dc69bfa7"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:t,event:s,state:n})=>t&&"opaqueredirect"===t.type?new Response(t.body,{status:200,statusText:"OK",headers:t.headers}):t}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,new e.StaleWhileRevalidate({cacheName:"static-image-assets",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/image\?url=.+$/i,new e.StaleWhileRevalidate({cacheName:"next-image",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp3|wav|ogg)$/i,new e.CacheFirst({cacheName:"static-audio-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp4)$/i,new e.CacheFirst({cacheName:"static-video-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:js)$/i,new e.StaleWhileRevalidate({cacheName:"static-js-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:css|less)$/i,new e.StaleWhileRevalidate({cacheName:"static-style-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/data\/.+\/.+\.json$/i,new e.StaleWhileRevalidate({cacheName:"next-data",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:json|xml|csv)$/i,new e.NetworkFirst({cacheName:"static-data-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;const t=e.pathname;return!t.startsWith("/api/auth/")&&!!t.startsWith("/api/")},new e.NetworkFirst({cacheName:"apis",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:16,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;return!e.pathname.startsWith("/api/")},new e.NetworkFirst({cacheName:"others",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>!(self.origin===e.origin),new e.NetworkFirst({cacheName:"cross-origin",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:3600})]}),"GET")}); diff --git a/src/app/api/search/route.ts b/src/app/api/search/route.ts index f813864..d5b725d 100644 --- a/src/app/api/search/route.ts +++ b/src/app/api/search/route.ts @@ -50,10 +50,18 @@ export async function GET(request: Request) { const regularSites = await getAvailableApiSites(); if (!regularSites || regularSites.length === 0) { - return Response.json({ + const cacheTime = await getCacheTime(); + const response = NextResponse.json({ regular_results: [], adult_results: [] + }, { + headers: { + 'Cache-Control': `public, max-age=${cacheTime}, s-maxage=${cacheTime}`, + 'CDN-Cache-Control': `public, s-maxage=${cacheTime}`, + 'Vercel-CDN-Cache-Control': `public, s-maxage=${cacheTime}`, + }, }); + return addCorsHeaders(response); } // 搜索常规(非成人)内容