feat: Extensive refactoring and modification to support any number of interfaces

This commit is contained in:
Gabe
2025-09-24 23:24:00 +08:00
parent 779c9fc850
commit 2a46939aa5
65 changed files with 2054 additions and 1947 deletions

View File

@@ -43,7 +43,7 @@ export const getHttpCache = async (input, init) => {
return await parseResponse(res);
}
} catch (err) {
kissLog(err, "get cache");
kissLog("get cache", err);
}
return null;
};
@@ -54,7 +54,12 @@ export const getHttpCache = async (input, init) => {
* @param {*} init
* @param {*} data
*/
export const putHttpCache = async (input, init, data) => {
export const putHttpCache = async (
input,
init,
data,
maxAge = DEFAULT_CACHE_TIMEOUT // todo: 从设置里面读取最大缓存时间
) => {
try {
const req = await newCacheReq(input, init);
const cache = await caches.open(CACHE_NAME);
@@ -62,13 +67,13 @@ export const putHttpCache = async (input, init, data) => {
status: 200,
headers: {
"Content-Type": "application/json",
"Cache-Control": `max-age=${DEFAULT_CACHE_TIMEOUT}`,
"Cache-Control": `max-age=${maxAge}`,
},
});
// res.headers.set("Cache-Control", `max-age=${DEFAULT_CACHE_TIMEOUT}`);
// res.headers.set("Cache-Control", `max-age=${maxAge}`);
await cache.put(req, res);
} catch (err) {
kissLog(err, "put cache");
kissLog("put cache", err);
}
};