Skip to content

Commit

Permalink
fix: change electron window option entry #1
Browse files Browse the repository at this point in the history
  • Loading branch information
subframe7536 committed Oct 19, 2024
1 parent 8d9a86a commit 6835286
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/manager/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ 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() {
super(mainPath, mainBakPath)
}

patch(_fontChanged: boolean, content: () => string): Promisable<string | undefined> {
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}`,
)
}
}
3 changes: 1 addition & 2 deletions src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 6835286

Please sign in to comment.