diff --git a/src/renderer/core/downloader/index.ts b/src/renderer/core/downloader/index.ts index ace73f8f..afcedced 100644 --- a/src/renderer/core/downloader/index.ts +++ b/src/renderer/core/downloader/index.ts @@ -69,6 +69,9 @@ const downloadingQueue = new PQueue({ }); function setDownloadingConcurrency(concurrency: number) { + if (isNaN(concurrency)) { + return; + } downloadingQueue.concurrency = Math.min( concurrency < 1 ? 1 : concurrency, concurrencyLimit diff --git a/src/shared/app-config/main.ts b/src/shared/app-config/main.ts index 83934fe4..b64f528b 100644 --- a/src/shared/app-config/main.ts +++ b/src/shared/app-config/main.ts @@ -87,7 +87,7 @@ class AppConfig { // 1. 升级到v1 try { const oldConfig = this.config as any; - const newConfig = { + const newConfig: any = { "normal.closeBehavior": oldConfig.normal?.closeBehavior === "exit" ? "exit_app" : oldConfig.normal?.closeBehavior, "normal.maxHistoryLength": oldConfig.normal?.maxHistoryLength, "normal.checkUpdate": oldConfig.normal?.checkUpdate, @@ -146,6 +146,12 @@ class AppConfig { "private.minimode": oldConfig.private?.minimode, } this.config = newConfig; + for (const k in _defaultAppConfig) { + if (newConfig[k] === null || newConfig[k] === undefined) { + // @ts-ignore + newConfig[k] = _defaultAppConfig[k]; + } + } const rawConfig = JSON.stringify(newConfig, undefined, 4); originalFs.writeFileSync(this.configPath, rawConfig, "utf-8"); } catch (e) {