2020-11-30 07:48:39 +00:00
|
|
|
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron')
|
2021-05-19 01:02:12 +00:00
|
|
|
const path = require('path')
|
2020-11-30 07:48:39 +00:00
|
|
|
|
|
|
|
function createWindow () {
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
width: 800,
|
|
|
|
height: 600,
|
|
|
|
webPreferences: {
|
2021-05-19 01:02:12 +00:00
|
|
|
preload: path.join(__dirname, 'preload.js')
|
2020-11-30 07:48:39 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
win.loadFile('index.html')
|
|
|
|
|
|
|
|
ipcMain.handle('dark-mode:toggle', () => {
|
|
|
|
if (nativeTheme.shouldUseDarkColors) {
|
|
|
|
nativeTheme.themeSource = 'light'
|
|
|
|
} else {
|
|
|
|
nativeTheme.themeSource = 'dark'
|
|
|
|
}
|
|
|
|
return nativeTheme.shouldUseDarkColors
|
|
|
|
})
|
|
|
|
|
|
|
|
ipcMain.handle('dark-mode:system', () => {
|
|
|
|
nativeTheme.themeSouce = 'system'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-05-19 01:02:12 +00:00
|
|
|
app.whenReady().then(() => {
|
|
|
|
createWindow()
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2020-11-30 07:48:39 +00:00
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|