|
|
5 ماه پیش | |
|---|---|---|
| .. | ||
| README.md | 5 ماه پیش | |
| build.sh | 5 ماه پیش | |
| main.js | 5 ماه پیش | |
| package.json | 5 ماه پیش | |
| preload.js | 5 ماه پیش | |
This directory contains the Electron wrapper for New API, allowing it to run as a native desktop application on Windows, macOS, and Linux.
The Electron app consists of:
Build the Go backend first:
cd ..
go build -o new-api
bash
cd electron
npm install
npm start
This will:
http://localhost:3000Use the provided build script:
./build.sh
This will:
Build frontend:
cd ../web
DISABLE_ESLINT_PLUGIN='true' bun run build
Build backend: ```bash cd ..
go build -ldflags="-s -w" -o new-api
go build -ldflags="-s -w" -o new-api.exe ```
Build Electron app: ```bash cd electron npm install
npm run build
npm run build:mac # macOS (DMG, ZIP) npm run build:win # Windows (NSIS installer, Portable) npm run build:linux # Linux (AppImage, DEB)
### Output
Built apps are located in `electron/dist/`:
- **macOS**: `.dmg` and `.zip`
- **Windows**: `.exe` installer and portable `.exe`
- **Linux**: `.AppImage` and `.deb`
## Cross-Platform Building
To build for other platforms:
```bash
# From macOS, build Windows app
npm run build:win
# From macOS, build Linux app
npm run build:linux
Note: Building macOS apps requires macOS. Building Windows apps with code signing requires Windows.
The app uses port 3000 by default. To change:
Edit electron/main.js:
const PORT = 3000; // Change to your desired port
data/ in the project rootuserData directory:
~/Library/Application Support/New API/data/%APPDATA%/New API/data/~/.config/New API/data/Edit electron/main.js in the createWindow() function:
mainWindow = new BrowserWindow({
width: 1400, // Change width
height: 900, // Change height
// ...
});
Check the console logs in DevTools (Cmd/Ctrl+Shift+I). Common issues:
Ensure the Go binary is built before running electron-builder:
go build -o new-api # macOS/Linux
go build -o new-api.exe # Windows
The binary must be in the project root, not inside electron/.
If you encounter database errors, delete the data directory and restart:
rm -rf data/To add a custom icon:
electron/icon.pngnpm run build