Files
Meeting_Assistant/scripts/README.md
egg 7d4fc69071 feat: Add build scripts and runtime config support
Backend:
- Add setup-backend.sh/bat for one-click backend setup
- Fix test_auth.py mock settings (JWT_EXPIRE_HOURS)
- Fix test_excel_export.py TEMPLATE_DIR reference

Frontend:
- Add config.json for runtime API URL configuration
- Add init.js and settings.js for config loading
- Update main.js to load config from external file
- Update api.js to use dynamic API_BASE_URL
- Update all pages to initialize config before API calls
- Update package.json with extraResources for config

Build:
- Add build-client.sh/bat for packaging Electron + Sidecar
- Add build-all.ps1 PowerShell script with -ApiUrl parameter
- Add GitHub Actions workflow for Windows builds
- Add scripts/README.md documentation

This allows IT to configure backend URL without rebuilding.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 20:03:16 +08:00

200 lines
3.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Meeting Assistant 建置腳本
本目錄包含後端設置與前端打包的自動化腳本。
## 腳本清單
| 腳本 | 平台 | 說明 |
|------|------|------|
| `setup-backend.sh` | Linux/macOS/WSL | 後端一鍵設置與啟動 |
| `setup-backend.bat` | Windows | 後端一鍵設置與啟動 |
| `build-client.sh` | Linux/macOS/WSL | 前端打包腳本 |
| `build-client.bat` | Windows | 前端打包腳本 |
| `deploy-backend.sh` | Linux | 生產環境部署腳本 |
---
## 後端設置腳本
### 功能
- 自動檢查 Python 環境 (需要 3.10+)
- 自動建立虛擬環境
- 自動安裝依賴
- 自動設置環境變數檔案
- 啟動後端服務
### 使用方式
**Linux/macOS/WSL:**
```bash
# 一鍵設置並啟動
./scripts/setup-backend.sh start
# 僅設置環境
./scripts/setup-backend.sh setup
# 背景執行
./scripts/setup-backend.sh start-bg
# 停止背景服務
./scripts/setup-backend.sh stop
# 使用自訂端口
./scripts/setup-backend.sh start --port 8080
# 不安裝 Sidecar 依賴
./scripts/setup-backend.sh setup --no-sidecar
```
**Windows:**
```batch
REM 一鍵設置並啟動
scripts\setup-backend.bat start
REM 僅設置環境
scripts\setup-backend.bat setup
REM 使用自訂端口
scripts\setup-backend.bat start --port 8080
```
### 環境變數
啟動後請編輯 `backend/.env` 設定:
- 資料庫連線
- API 密鑰
- 服務配置
---
## 前端打包腳本
### 功能
- 將 Python Sidecar 打包成獨立執行檔 (PyInstaller)
- 將 Electron 應用打包成免安裝 exe
- 整合 Sidecar 到最終輸出
### 系統需求
- Node.js 18+
- Python 3.10+
- 磁碟空間 5GB+ (Whisper 模型)
### 使用方式
**Linux/macOS/WSL:**
```bash
# 完整建置 (Sidecar + Electron)
./scripts/build-client.sh build
# 僅打包 Sidecar
./scripts/build-client.sh sidecar
# 僅打包 Electron (需先打包 Sidecar)
./scripts/build-client.sh electron
# 建置前清理
./scripts/build-client.sh build --clean
# 指定目標平台
./scripts/build-client.sh build --platform linux
./scripts/build-client.sh build --platform mac
./scripts/build-client.sh build --platform win
```
**Windows:**
```batch
REM 完整建置
scripts\build-client.bat build
REM 僅打包 Sidecar
scripts\build-client.bat sidecar
REM 僅打包 Electron
scripts\build-client.bat electron
REM 建置前清理
scripts\build-client.bat build --clean
```
### 輸出目錄
- Sidecar: `sidecar/dist/transcriber/`
- Electron: `client/dist/`
- 最終輸出: `build/`
### 注意事項
1. **跨平台打包限制**
- Windows exe 必須在 Windows 環境打包
- macOS dmg 必須在 macOS 環境打包
- Linux AppImage 可在 Linux 或 WSL 打包
2. **首次打包時間**
- Sidecar 首次打包需下載 Whisper 模型
- 根據網路速度可能需要 10-30 分鐘
3. **磁碟空間**
- 完整打包需要約 2-3GB 空間
- 建議預留 5GB 以上
---
## 生產環境部署
使用 `deploy-backend.sh` 在 Linux 伺服器上部署:
```bash
# 安裝後端服務
sudo ./scripts/deploy-backend.sh install
# 更新後端服務
sudo ./scripts/deploy-backend.sh update
# 查看狀態
./scripts/deploy-backend.sh status
# 查看日誌
./scripts/deploy-backend.sh logs
# 移除服務
sudo ./scripts/deploy-backend.sh uninstall
```
### 自訂配置
```bash
# 指定安裝目錄和端口
sudo ./scripts/deploy-backend.sh install --dir /opt/my-meeting --port 8080 --user meeting
```
部署後會建立 systemd 服務 `meeting-assistant-backend`,可使用標準 systemctl 命令管理。
---
## 疑難排解
### Python 版本問題
確保使用 Python 3.10 或更高版本:
```bash
python3 --version
```
### 虛擬環境問題
如果虛擬環境損壞,可刪除後重建:
```bash
rm -rf backend/venv sidecar/venv
./scripts/setup-backend.sh setup
```
### Electron 打包失敗
確保已安裝 node_modules
```bash
cd client
npm install
```
### Sidecar 打包失敗
確保 PyInstaller 已安裝:
```bash
cd sidecar
source venv/bin/activate # Linux/macOS
pip install pyinstaller
```