Skip to content

Commit 0d9e68e

Browse files
authored
Merge pull request #61 from stanleyowen/desktop-app
feat: add desktop application support
2 parents 91de541 + 35dc275 commit 0d9e68e

File tree

4 files changed

+1260
-34
lines changed

4 files changed

+1260
-34
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ debug.log
1212
.env.development
1313
.env.development.local
1414
.env.test.local
15+
.env.production
1516
.env.production.local
1617

1718
**/img/*[.png][.jpg]
1819
docs
19-
node_modules
20+
node_modules
21+
dist

package.json

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "lofi-player",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"private": true,
5+
"author": "Stanley Owen <stanleyowen06@gmail.com>",
56
"dependencies": {
67
"@material-ui/core": "^4.12.3",
78
"@material-ui/lab": "^4.0.0-alpha.60",
@@ -13,6 +14,8 @@
1314
"@types/react-dom": "^17.0.9",
1415
"@types/react-router-dom": "^5.1.8",
1516
"algoliasearch": "^4.10.5",
17+
"cross-env": "^7.0.3",
18+
"electron-is-dev": "^2.0.0",
1619
"firebase": "^9.0.0",
1720
"react": "^17.0.2",
1821
"react-dom": "^17.0.2",
@@ -21,11 +24,35 @@
2124
"typescript": "^4.4.2",
2225
"web-vitals": "^2.1.0"
2326
},
27+
"main": "public/electron.js",
28+
"homepage": "./",
2429
"scripts": {
2530
"start": "react-scripts start",
2631
"build": "react-scripts build",
2732
"test": "react-scripts test",
28-
"eject": "react-scripts eject"
33+
"eject": "react-scripts eject",
34+
"release": "yarn build && electron-builder --publish=always",
35+
"build:electron": "yarn build && electron-builder",
36+
"start:electron": "concurrently \"cross-env BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\""
37+
},
38+
"build": {
39+
"win": {
40+
"target": [
41+
{
42+
"target": "nsis",
43+
"arch": [
44+
"ia32",
45+
"x64"
46+
]
47+
}
48+
]
49+
},
50+
"linux": {
51+
"target": [
52+
"AppImage",
53+
"deb"
54+
]
55+
}
2956
},
3057
"eslintConfig": {
3158
"extends": [
@@ -46,6 +73,10 @@
4673
]
4774
},
4875
"devDependencies": {
49-
"dotenv": "^10.0.0"
76+
"concurrently": "^6.2.1",
77+
"dotenv": "^10.0.0",
78+
"electron": "^14.0.0",
79+
"electron-builder": "^22.11.7",
80+
"wait-on": "^6.0.0"
5081
}
5182
}

public/electron.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const electron = require("electron");
2+
const app = electron.app;
3+
const BrowserWindow = electron.BrowserWindow;
4+
const path = require("path");
5+
const isDev = require("electron-is-dev");
6+
7+
let mainWindow;
8+
9+
function createWindow() {
10+
mainWindow = new BrowserWindow({ width: 900, height: 680 , webPreferences: {nodeIntegration: true}});
11+
mainWindow.loadURL(isDev ? "http://localhost:3000" : `file://${path.join(__dirname, "../build/index.html")}`);
12+
mainWindow.setMenuBarVisibility(false)
13+
mainWindow.on("closed", () => (mainWindow = null));
14+
}
15+
app.on("ready", createWindow);
16+
app.on("window-all-closed", () => {
17+
if (process.platform !== "darwin") { app.quit(); }
18+
});
19+
app.on("activate", () => {
20+
if (mainWindow === null) { createWindow(); }
21+
});

0 commit comments

Comments
 (0)