Skip to content

Commit 11953c7

Browse files
committed
💎 add openDevTools, clearCache and simulateOutage settings for Electron
1 parent 3bea50e commit 11953c7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

template/settings/settings.default.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"showBareErrors": false
2121
}
2222
},
23+
"openDevTools": true,
24+
"simulateOutage": false,
25+
"clearCache": false,
2326
"appendSwitch": {
2427
"--disable-pinch": "",
2528
"--disable-touch-adjustment": "",

template/src/main/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ function createWindow () {
2929

3030
{{#isEnabled plugins 'standard-settings'}}
3131
options = require('assignment')(options, global.settings.window)
32+
if (global.settings.simulateOutage) {
33+
mainWindow.webContents.session.enableNetworkEmulation({offline: true})
34+
}
35+
if (global.settings.openDevTools) {
36+
mainWindow.webContents.openDevTools()
37+
}
38+
if (global.settings.clearCache) {
39+
console.warn('⚠️ - Option to clear cache set, cache will be cleared')
40+
store.clear()
41+
mainWindow.webContents.session.clearStorageData({}, () => {
42+
mainWindow.webContents.session.clearCache(() => {
43+
console.log('cache cleared.')
44+
mainWindow.loadURL(winURL)
45+
})
46+
})
47+
}
3248
{{/isEnabled}}
3349
mainWindow = new BrowserWindow(options)
3450

0 commit comments

Comments
 (0)