修复音乐设备同步

This commit is contained in:
mtvpls
2026-02-02 01:15:08 +08:00
parent 821baff2be
commit e2fe2058e9
2 changed files with 155 additions and 121 deletions

View File

@@ -388,6 +388,16 @@ export async function POST(request: NextRequest) {
);
}
// 添加缓存支持
const qualityKey = quality || '320k';
const idsKey = Array.isArray(ids) ? ids.join(',') : ids;
const cacheKey = `parse-${platform}-${idsKey}-${qualityKey}`;
const cached = serverCache.proxyRequests.get(cacheKey);
if (cached && Date.now() - cached.timestamp < serverCache.CACHE_DURATION) {
return NextResponse.json(cached.data);
}
try {
const response = await proxyRequest(`${baseUrl}/v1/parse`, {
method: 'POST',
@@ -398,7 +408,7 @@ export async function POST(request: NextRequest) {
body: JSON.stringify({
platform,
ids,
quality: quality || '320k',
quality: qualityKey,
}),
});
@@ -414,6 +424,9 @@ export async function POST(request: NextRequest) {
});
}
// 缓存成功的解析结果
serverCache.proxyRequests.set(cacheKey, { data, timestamp: Date.now() });
return NextResponse.json(data);
} catch (error) {
console.error('解析歌曲失败:', error);