Skip to content

Commit

Permalink
feat: 修复config导致的白屏
Browse files Browse the repository at this point in the history
  • Loading branch information
maotoumao committed Dec 24, 2024
1 parent b341271 commit 56f9e44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/renderer/core/downloader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/shared/app-config/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 56f9e44

Please sign in to comment.