fix(main): 修复下载过期无法恢复、配置写放大、主进程 i18n 崩溃

- downloadManager: axios 放行 403/410,让直链过期能触发重新解析(修复重启恢复队列时下载失效)
- cache: getCacheConfig 纯读不再落盘 config.json,消除播放/下载热路径的写放大与文件争用
- i18n/main: 未知/非法 locale 回退默认语言并加空值防护,避免托盘/登录窗构建时崩溃
- lxMusicHttp: 超时定时器在 fetch 出错路径也清理
- loginWindow: 标题改为打开窗口时求值,跟随当前语言
This commit is contained in:
alger
2026-07-05 19:53:12 +08:00
parent f17bc62310
commit 2073caf383
5 changed files with 26 additions and 8 deletions
+8 -2
View File
@@ -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);
}
}