Skip to content

Commit 3d303ff

Browse files
committed
add electron and electron-forge
1 parent dc860e6 commit 3d303ff

6 files changed

Lines changed: 5365 additions & 507 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
out
23
.DS_Store
34
node_modules
45
/build

forge.config.cjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
packagerConfig: {
3+
asar: true,
4+
},
5+
rebuildConfig: {},
6+
makers: [
7+
{
8+
name: '@electron-forge/maker-squirrel',
9+
config: {},
10+
},
11+
{
12+
name: '@electron-forge/maker-zip',
13+
platforms: ['darwin'],
14+
},
15+
{
16+
name: '@electron-forge/maker-deb',
17+
config: {},
18+
},
19+
{
20+
name: '@electron-forge/maker-rpm',
21+
config: {},
22+
},
23+
],
24+
plugins: [
25+
{
26+
name: '@electron-forge/plugin-auto-unpack-natives',
27+
config: {},
28+
},
29+
],
30+
};

main.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require('dotenv').config()
2+
const {app, BrowserWindow} = require('electron')
3+
const PROTOCOL = process.env.PROTOCOL || 'http'
4+
const HOST = process.env.HOST || 'localhost'
5+
const PORT = process.env.PORT || 3000
6+
7+
function start() {
8+
const createWindow = () => {
9+
const mainWindow = new BrowserWindow({
10+
width: 800,
11+
height: 600
12+
})
13+
mainWindow.loadURL(`${PROTOCOL}://${HOST}:${PORT}`)
14+
}
15+
app.whenReady().then(() => {
16+
createWindow()
17+
app.on('activate', () => {
18+
if (BrowserWindow.getAllWindows().length === 0) createWindow()
19+
})
20+
})
21+
app.on('window-all-closed', () => {
22+
if (process.platform !== 'darwin') app.quit()
23+
})
24+
}
25+
26+
if (!app.isPackaged) {
27+
start();
28+
}
29+
30+
if (app.isPackaged) {
31+
// Load server and run
32+
import('alloctrl/build/index.js').then(start)
33+
}

0 commit comments

Comments
 (0)