Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Electron for Desktop Application Deployment #310

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lerna-debug.log*

node_modules
dist
install
dist-ssr
*.local

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ npm install
npm run dev
```

### Local Development Electron
Make sure you have the local environment (`Local Development`) enabled before running Electron:

```bash
npm run electron
```

### Build

```bash
Expand Down
44 changes: 44 additions & 0 deletions main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { app, BrowserWindow, Menu } = require('electron');
const path = require('path');

process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';

function createWindow() {

const isDev = !app.isPackaged;
const win = new BrowserWindow({
width: 800,
height: 600,
icon: path.join(__dirname, 'public', 'icon.ico') ,
webPreferences: {
contextIsolation: true,
enableRemoteModule: false,
},
});

win.maximize();

if (isDev) {
win.loadURL('http://localhost:5173');
win.webContents.openDevTools();
} else {
win.loadURL(`file://${path.join(__dirname, 'dist/index.html')}`);
Menu.setApplicationMenu(null);
}
}

app.whenReady().then(() => {
createWindow();

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
Loading
Loading