forked from miao-moe/QZMusic_PC
feat: 支持不自动将网络资源(音频)缓存到本地
This commit is contained in:
@@ -397,7 +397,24 @@ async function proxyAndCache(
|
||||
});
|
||||
}
|
||||
|
||||
export function startProxyServer() {
|
||||
let persistCacheEnabled = true;
|
||||
|
||||
export function cleanupCache() {
|
||||
if (!persistCacheEnabled && CACHE_DIR && fs.existsSync(CACHE_DIR)) {
|
||||
console.log(`[Proxy] Cleaning up cache directory: ${CACHE_DIR}`);
|
||||
try {
|
||||
fs.rmSync(CACHE_DIR, { recursive: true, force: true });
|
||||
console.log('[Proxy] Cache cleanup complete');
|
||||
} catch (e) {
|
||||
console.error('[Proxy] Failed to cleanup cache:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function startProxyServer(persistCache: boolean = true) {
|
||||
persistCacheEnabled = persistCache;
|
||||
console.log(`[Proxy] Persist cache: ${persistCache}`);
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET, HEAD, OPTIONS');
|
||||
|
||||
Reference in New Issue
Block a user