修复.cahce缓存不适配云部署的问题

This commit is contained in:
huangxd- committed 2025-11-15 10:36:11 +08:00
1 parent 9c2d881069
commit 5081eaff6a
1 file changed
+4 -3
+4 -3
View File
@@ -312,11 +312,12 @@ export function cleanupExpiredIPs(currentTime) {
// 获取当前文件目录的兼容方式
function getDirname() {
if (typeof __dirname !== 'undefined') {
// CommonJS 环境 (Vercel 编译后)
// CommonJS 环境 (Vercel)
return __dirname;
}
// ES Module 环境
return path.dirname(fileURLToPath(import.meta.url));
// ES Module 环境 (本地)
// 假设 cache-util.js 在 danmu_api/utils/ 目录下
return path.join(process.cwd(), 'danmu_api', 'utils');
}
// 从本地缓存目录读取缓存数据