Skip to content

Commit

Permalink
feat: override setBackgroundColor #20
Browse files Browse the repository at this point in the history
  • Loading branch information
subframe7536 committed Jan 10, 2025
1 parent d0e304e commit cfa266c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/manager/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ import { mainBakPath, mainPath } from '../path'
import { BaseFileManager } from './base'

const entry = 'experimentalDarkMode:!0'
const setBgColorRegex = /setBackgroundColor\([\w.]+\);/g

export class MainFileManager extends BaseFileManager {
constructor() {
super(mainPath, mainBakPath)
}

patch(content: string): string {
return content.replaceAll(
let patched = content.replaceAll(
entry,
`${entry},${JSON.stringify(config.electron).slice(1, -1)}`,
)
if ('backgroundColor' in config.electron) {
patched = patched.replace(
setBgColorRegex,
`setBackgroundColor("${config.electron.backgroundColor}");`,
)
}
return patched
}
}

0 comments on commit cfa266c

Please sign in to comment.