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>
This commit is contained in:
egg
2025-12-16 20:03:16 +08:00
parent 01aee1fd0d
commit 7d4fc69071
20 changed files with 2454 additions and 32 deletions

155
.github/workflows/build-windows.yml vendored Normal file
View File

@@ -0,0 +1,155 @@
name: Build Windows Client
on:
workflow_dispatch: # 手動觸發
inputs:
api_url:
description: 'Backend API URL (e.g., http://192.168.1.100:8000/api)'
required: false
default: 'http://localhost:8000/api'
type: string
whisper_model:
description: 'Whisper model size'
required: false
default: 'medium'
type: choice
options:
- tiny
- base
- small
- medium
- large
push:
tags:
- 'v*' # 推送版本 tag 時自動觸發
jobs:
build-sidecar:
name: Build Sidecar (Python → exe)
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: sidecar/requirements.txt
- name: Install sidecar dependencies
working-directory: sidecar
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build sidecar with PyInstaller
working-directory: sidecar
run: |
pyinstaller `
--onedir `
--name transcriber `
--distpath dist `
--workpath build `
--noconfirm `
--clean `
--console `
--hidden-import=faster_whisper `
--hidden-import=ctranslate2 `
--hidden-import=huggingface_hub `
--hidden-import=tokenizers `
--hidden-import=onnxruntime `
--hidden-import=opencc `
--hidden-import=pydub `
--hidden-import=numpy `
--hidden-import=av `
--collect-data=onnxruntime `
--collect-data=faster_whisper `
transcriber.py
- name: Upload sidecar artifact
uses: actions/upload-artifact@v4
with:
name: sidecar-windows
path: sidecar/dist/transcriber/
retention-days: 1
build-electron:
name: Build Electron App
needs: build-sidecar
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: Download sidecar artifact
uses: actions/download-artifact@v4
with:
name: sidecar-windows
path: sidecar/dist/transcriber/
- name: Install client dependencies
working-directory: client
run: npm ci
- name: Update config.json with API URL
working-directory: client
shell: pwsh
run: |
$configPath = "config.json"
$apiUrl = "${{ inputs.api_url || 'http://localhost:8000/api' }}"
if (Test-Path $configPath) {
$config = Get-Content $configPath -Raw | ConvertFrom-Json
$config.apiBaseUrl = $apiUrl
$config | ConvertTo-Json -Depth 10 | Set-Content $configPath -Encoding UTF8
Write-Host "Updated API URL to: $apiUrl"
}
- name: Build Electron app
working-directory: client
run: npm run build -- --win
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Windows build
uses: actions/upload-artifact@v4
with:
name: meeting-assistant-windows
path: |
client/dist/*.exe
client/dist/*.zip
retention-days: 30
release:
name: Create Release
needs: build-electron
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Windows build
uses: actions/download-artifact@v4
with:
name: meeting-assistant-windows
path: dist/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
draft: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}