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

try electron distribution #23

Merged
merged 6 commits into from
Sep 15, 2024
Merged
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
dist*
*.local
build

Expand Down
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
appId: com.skywardai.chat # Change this to your app's unique ID
productName: SkywardaiChat # Name of the application

directories:
output: dist-electron # Where the built files will be stored

files:
- dist/**/* # Include everything in the dist folder generated by Vite
# - node_modules/**/* # Include necessary node modules
# - package.json
- electron.js

win:
target:
- nsis # Windows installer type, you can use zip, nsis, etc.
icon: assets/icon.png

mac:
target:
- dmg # macOS installer type
icon: assets/icon.png

linux:
target:
- AppImage
# - deb # You can also specify 'deb', 'rpm', etc.
icon: assets/icon.png

nsis:
oneClick: true # Whether the installer is one-click
allowElevation: true # Allow requests for elevation (admin privileges)
allowToChangeInstallationDirectory: true # Let the user change the install directory
createDesktopShortcut: true # Create desktop shortcut after installation
createStartMenuShortcut: true # Create start menu shortcut
18 changes: 15 additions & 3 deletions electron.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { app, BrowserWindow } from 'electron';
// eslint-disable-next-line
const { app, Menu, BrowserWindow } = require('electron');
// eslint-disable-next-line
const path = require('path');

app.commandLine.appendSwitch('enable-features','SharedArrayBuffer')

function createWindow() {
const win = new BrowserWindow({
Expand All @@ -7,10 +12,17 @@ function createWindow() {
width: 900,
minWidth: 560,
minHeight: 250,
autoHideMenuBar: true
// autoHideMenuBar: true,
})

win.loadURL("http://localhost:3000");
if(app.isPackaged) {
// eslint-disable-next-line
win.loadFile(path.join(__dirname, 'dist/index.html'))
Menu.setApplicationMenu(null);
} else {
win.loadURL("http://localhost:3000");
}

win.once("ready-to-show", ()=>{
win.show();
})
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "vite-test",
"private": true,
"version": "0.0.0",
"type": "module",
"name": "shibuya",
"author": {
"name": "Bohan Cheng",
"email": "[email protected]"
},
"version": "0.1.0",
"main": "electron.js",
"scripts": {
"dev": "npm run start & npm run electron",
"start": "vite",
"build": "vite build",
"build-electron": "electron-builder -c",
"lint": "eslint .",
"preview": "vite preview",
"electron": "electron ."
Expand All @@ -29,6 +32,7 @@
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"electron": "^32.0.0",
"electron-builder": "^25.0.5",
"eslint": "^9.9.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
Expand Down
Loading
Loading