From 68352860591d5bc92bdc2b870921218efad220b3 Mon Sep 17 00:00:00 2001 From: subframe7536 <1667077010@qq.com> Date: Sat, 19 Oct 2024 11:22:28 +0800 Subject: [PATCH] fix: change electron window option entry #1 --- src/manager/main.ts | 8 +++----- src/path.ts | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/manager/main.ts b/src/manager/main.ts index 53463b7..f090788 100644 --- a/src/manager/main.ts +++ b/src/manager/main.ts @@ -3,8 +3,7 @@ import { config } from '../config' import { mainBakPath, mainPath } from '../path' import { BaseFileManager } from './base' -const defaultBackgroundColor = 'r.getBackgroundColor()' -const entry = `backgroundColor:${defaultBackgroundColor}` +const entry = 'experimentalDarkMode' export class MainFileManager extends BaseFileManager { constructor() { @@ -12,10 +11,9 @@ export class MainFileManager extends BaseFileManager { } patch(_fontChanged: boolean, content: () => string): Promisable { - const backgroundColor = config.electron.backgroundColor || defaultBackgroundColor return content().replace( - entry, - `${JSON.stringify(config.electron).slice(1, -1)},backgroundColor:${backgroundColor}`, + new RegExp(entry, 'g'), + `${JSON.stringify(config.electron).slice(1, -1)},${entry}`, ) } } diff --git a/src/path.ts b/src/path.ts index fc4578a..ec769ed 100644 --- a/src/path.ts +++ b/src/path.ts @@ -61,14 +61,13 @@ export const rendererBakPath = getRendererPath('js', bakExt) function getMainPath(baseExt: string, backupExt?: string) { const ext = backupExt ? `${backupExt}.${baseExt}` : baseExt - const defaultPath = path.join( + return path.join( baseDir, 'vs', 'code', 'electron-main', `main.${ext}`, ) - return fs.existsSync(defaultPath) ? defaultPath : path.join(baseDir, `main.${baseExt}`) } export const mainPath = getMainPath('js')