Skip to content

Commit 304f8f8

Browse files
authored
Merge pull request #23 from SkywardAI/distribution
try electron distribution
2 parents b749c04 + 56d41f3 commit 304f8f8

File tree

10 files changed

+2092
-52
lines changed

10 files changed

+2092
-52
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ pnpm-debug.log*
88
lerna-debug.log*
99

1010
node_modules
11-
dist
12-
dist-ssr
11+
dist*
1312
*.local
1413
build
1514

assets/icon.png

31.7 KB
Loading

electron-builder.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
appId: com.skywardai.chat # Change this to your app's unique ID
2+
productName: SkywardaiChat # Name of the application
3+
4+
directories:
5+
output: dist-electron # Where the built files will be stored
6+
7+
files:
8+
- dist/**/* # Include everything in the dist folder generated by Vite
9+
# - node_modules/**/* # Include necessary node modules
10+
# - package.json
11+
- electron.js
12+
13+
win:
14+
target:
15+
- nsis # Windows installer type, you can use zip, nsis, etc.
16+
icon: assets/icon.png
17+
18+
mac:
19+
target:
20+
- dmg # macOS installer type
21+
icon: assets/icon.png
22+
23+
linux:
24+
target:
25+
- AppImage
26+
# - deb # You can also specify 'deb', 'rpm', etc.
27+
icon: assets/icon.png
28+
29+
nsis:
30+
oneClick: true # Whether the installer is one-click
31+
allowElevation: true # Allow requests for elevation (admin privileges)
32+
allowToChangeInstallationDirectory: true # Let the user change the install directory
33+
createDesktopShortcut: true # Create desktop shortcut after installation
34+
createStartMenuShortcut: true # Create start menu shortcut

electron.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { app, BrowserWindow } from 'electron';
1+
// eslint-disable-next-line
2+
const { app, Menu, BrowserWindow } = require('electron');
3+
// eslint-disable-next-line
4+
const path = require('path');
5+
6+
app.commandLine.appendSwitch('enable-features','SharedArrayBuffer')
27

38
function createWindow() {
49
const win = new BrowserWindow({
@@ -7,10 +12,17 @@ function createWindow() {
712
width: 900,
813
minWidth: 560,
914
minHeight: 250,
10-
autoHideMenuBar: true
15+
// autoHideMenuBar: true,
1116
})
1217

13-
win.loadURL("http://localhost:3000");
18+
if(app.isPackaged) {
19+
// eslint-disable-next-line
20+
win.loadFile(path.join(__dirname, 'dist/index.html'))
21+
Menu.setApplicationMenu(null);
22+
} else {
23+
win.loadURL("http://localhost:3000");
24+
}
25+
1426
win.once("ready-to-show", ()=>{
1527
win.show();
1628
})

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
2-
"name": "vite-test",
3-
"private": true,
4-
"version": "0.0.0",
5-
"type": "module",
2+
"name": "shibuya",
3+
"author": {
4+
"name": "Bohan Cheng",
5+
"email": "[email protected]"
6+
},
7+
"version": "0.1.0",
68
"main": "electron.js",
79
"scripts": {
810
"dev": "npm run start & npm run electron",
911
"start": "vite",
1012
"build": "vite build",
13+
"build-electron": "electron-builder -c",
1114
"lint": "eslint .",
1215
"preview": "vite preview",
1316
"electron": "electron ."
@@ -29,6 +32,7 @@
2932
"@types/react-dom": "^18.3.0",
3033
"@vitejs/plugin-react": "^4.3.1",
3134
"electron": "^32.0.0",
35+
"electron-builder": "^25.0.5",
3236
"eslint": "^9.9.0",
3337
"eslint-plugin-react": "^7.35.0",
3438
"eslint-plugin-react-hooks": "^5.1.0-rc.0",

0 commit comments

Comments
 (0)