feat: add cache control

This commit is contained in:
shinya
2025-06-19 12:45:46 +08:00
parent da46031ae6
commit 660b51d9bd
5 changed files with 48 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ export interface ApiSite {
}
export interface Config {
cache_time?: number;
api_site: {
[key: string]: ApiSite;
};
@@ -49,6 +50,11 @@ export function getConfig(): Config {
return parsedConfig;
}
export function getCacheTime(): number {
const config = getConfig();
return config.cache_time || 300; // 默认5分钟缓存
}
export function getApiSites(): ApiSite[] {
const config = getConfig();
return Object.entries(config.api_site).map(([key, site]) => ({