mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-07-17 16:37:29 +08:00
fix(main): 修复下载过期无法恢复、配置写放大、主进程 i18n 崩溃
- downloadManager: axios 放行 403/410,让直链过期能触发重新解析(修复重启恢复队列时下载失效) - cache: getCacheConfig 纯读不再落盘 config.json,消除播放/下载热路径的写放大与文件争用 - i18n/main: 未知/非法 locale 回退默认语言并加空值防护,避免托盘/登录窗构建时崩溃 - lxMusicHttp: 超时定时器在 fetch 出错路径也清理 - loginWindow: 标题改为打开窗口时求值,跟随当前语言
This commit is contained in:
@@ -42,6 +42,8 @@ export const initLxMusicHttp = () => {
|
||||
// 保存取消控制器
|
||||
abortControllers.set(requestId, controller);
|
||||
|
||||
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
try {
|
||||
console.log(`[LxMusicHttp] 请求: ${options.method || 'GET'} ${url}`);
|
||||
|
||||
@@ -77,13 +79,14 @@ export const initLxMusicHttp = () => {
|
||||
|
||||
// 设置超时
|
||||
const timeout = options.timeout || 30000;
|
||||
const timeoutId = setTimeout(() => {
|
||||
timeoutId = setTimeout(() => {
|
||||
console.warn(`[LxMusicHttp] 请求超时: ${url}`);
|
||||
controller.abort();
|
||||
}, timeout);
|
||||
|
||||
const response = await fetch(url, fetchOptions);
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
|
||||
console.log(`[LxMusicHttp] 响应: ${response.status} ${url}`);
|
||||
|
||||
@@ -122,7 +125,10 @@ export const initLxMusicHttp = () => {
|
||||
console.error(`[LxMusicHttp] 请求失败: ${url}`, error.message);
|
||||
throw error;
|
||||
} finally {
|
||||
// 清理取消控制器
|
||||
// 清理超时定时器(fetch 出错时前面来不及 clear)与取消控制器
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
abortControllers.delete(requestId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user