mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-11-30 19:21:36 +08:00
- moejs 迁到 github.com/MoeForge/moejs v0.1.0,Dockerfile、Electron 构建与发布流程的 PGO 路径同步更新;发布附带 THIRD-PARTY-LICENSES.md,并补充 moejs 附带的第三方声明。 - moego 升级到 v0.1.0-alpha.2:宿主 JSON 编解码经 common/kitutil 封装改用 moego/json,根模块和 relaykit 生产代码的 regexp 改用 moego/regexp。 - 内存中的请求体由校验器零拷贝解析;磁盘缓存的请求体经独立文件读取器解码,且只接受一个 JSON 值,尾随内容会被拒绝。 - 模型/分组提取与重复 model 键检测、渠道亲和 JSON 路径、任务协议 stream/background 标志、multipart 解析在磁盘模式下不再把整份请求体读进内存。图片透传直接转发已存储的请求体,并校验最终发往上游的 n。 - 出站请求体各自持有读取位置。此前透传重试共用存储游标,上一次尝试仍在发送时,下一次尝试可能发出残缺的请求体。收到响应头后不再提前关闭请求体,避免中断仍在发送的请求体。 - 表达式计费只在表达式使用 param() 时冻结请求体,其余情况不再读取并保留整份请求体。
New API Electron Desktop App
This directory contains the Electron wrapper for New API, providing a native desktop application with system tray support for Windows, macOS, and Linux.
Prerequisites
1. Go Binary (Required)
The Electron app requires the compiled Go binary to function. You have two options:
Option A: Use existing binary (without Go installed)
# If you have a pre-built binary (e.g., new-api-macos)
cp ../new-api-macos ../new-api
Option B: Build from source (requires Go) TODO
2. Electron Dependencies
cd electron
npm install
Development
Start the backend, the frontend, and Electron in separate terminals:
# Repository root
go run main.go
# Repository root
make dev-web
# electron/
npm run dev-app
This will:
- Use the Go backend on port 3000
- Use the Rsbuild frontend development server on port 5173
- Open an Electron window with DevTools enabled
- Create a system tray icon (menu bar on macOS)
- Store database in
../data/new-api.db
Building for Production
Quick Build
# From electron/, build the frontend, Go binary, and desktop package
./build.sh
# Or package an existing binary for the current platform
npm run build
# Platform-specific builds
npm run build:mac # Creates .dmg and .zip
npm run build:win # Creates .exe installer
npm run build:linux # Creates .AppImage and .deb
Build Output
- Built applications are in
electron/dist/ - macOS:
.dmg(installer) and.zip(portable) - Windows:
.exe(installer) and portable exe - Linux:
.AppImageand.deb
Configuration
Port
Default port is 3000. To change, edit main.js:
const PORT = 3000; // Change to desired port
Database Location
- Development:
../data/new-api.db(project directory) - Production:
- macOS:
~/Library/Application Support/New API/data/ - Windows:
%APPDATA%/New API/data/ - Linux:
~/.config/New API/data/
- macOS: