feat: support builtin AI

This commit is contained in:
Gabe
2025-10-04 21:25:54 +08:00
parent c353c88db8
commit 7b2b48f0d1
23 changed files with 558 additions and 243 deletions

View File

@@ -45,7 +45,7 @@ const newCacheReq = async (input, init) => {
* @param {*} init
* @returns
*/
export const getHttpCache = async (input, init) => {
export const getHttpCache = async ({ input, init }) => {
try {
const req = await newCacheReq(input, init);
const cache = await caches.open(CACHE_NAME);
@@ -65,12 +65,12 @@ export const getHttpCache = async (input, init) => {
* @param {*} init
* @param {*} data
*/
export const putHttpCache = async (
export const putHttpCache = async ({
input,
init,
data,
maxAge = DEFAULT_CACHE_TIMEOUT // todo: 从设置里面读取最大缓存时间
) => {
maxAge = DEFAULT_CACHE_TIMEOUT, // todo: 从设置里面读取最大缓存时间
}) => {
try {
const req = await newCacheReq(input, init);
const cache = await caches.open(CACHE_NAME);
@@ -132,7 +132,7 @@ export const getHttpCachePolyfill = (input, init) => {
}
// 油猴/网页/BackgroundPage
return getHttpCache(input, init);
return getHttpCache({ input, init });
};
/**
@@ -149,5 +149,5 @@ export const putHttpCachePolyfill = (input, init, data) => {
}
// 油猴/网页/BackgroundPage
return putHttpCache(input, init, data);
return putHttpCache({ input, init, data });
};