Skip to content

Commit

Permalink
refactor: cache css
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch committed Jun 14, 2020
1 parent b0e949e commit f2d4a6c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ electronContextMenu();
let mainWindow: BrowserWindow = null;
let isQuitting = false;

const cssPath = path.resolve(__dirname, '../browser.css');
const browserCSS = fs.readFileSync(cssPath, 'utf8');

app.on('second-instance', () => {
if (mainWindow?.isMinimized()) {
mainWindow?.restore();
Expand Down Expand Up @@ -85,9 +88,7 @@ app.on('ready', async () => {
tray.create(mainWindow);

mainWindow.webContents.on('dom-ready', async () => {
const browserCSS = path.resolve(__dirname, '../browser.css');
const css = await fs.promises.readFile(browserCSS, 'utf8');
await mainWindow.webContents.insertCSS(css);
await mainWindow.webContents.insertCSS(browserCSS);
mainWindow.show();
});

Expand Down

0 comments on commit f2d4a6c

Please sign in to comment.