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

View File

@@ -19,17 +19,6 @@ BACKEND_DIR="$PROJECT_DIR/backend"
CLIENT_DIR="$PROJECT_DIR/client"
SIDECAR_DIR="$PROJECT_DIR/sidecar"
# Load environment variables from .env files if they exist
if [ -f "$BACKEND_DIR/.env" ]; then
log_info "Loading backend environment from $BACKEND_DIR/.env"
export $(grep -v '^#' "$BACKEND_DIR/.env" | grep -v '^$' | xargs)
fi
if [ -f "$CLIENT_DIR/.env" ]; then
log_info "Loading client environment from $CLIENT_DIR/.env"
export $(grep -v '^#' "$CLIENT_DIR/.env" | grep -v '^$' | xargs)
fi
# Server Configuration (can be overridden by .env)
BACKEND_HOST="${BACKEND_HOST:-0.0.0.0}"
BACKEND_PORT="${BACKEND_PORT:-8000}"
@@ -59,6 +48,17 @@ log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Load environment variables from .env files if they exist
if [ -f "$BACKEND_DIR/.env" ]; then
log_info "Loading backend environment from $BACKEND_DIR/.env"
export $(grep -v '^#' "$BACKEND_DIR/.env" | grep -v '^$' | xargs)
fi
if [ -f "$CLIENT_DIR/.env" ]; then
log_info "Loading client environment from $CLIENT_DIR/.env"
export $(grep -v '^#' "$CLIENT_DIR/.env" | grep -v '^$' | xargs)
fi
# 函數:檢查 port 是否被佔用
check_port() {
local port=$1
@@ -221,6 +221,10 @@ start_frontend() {
cd "$CLIENT_DIR"
# WSLg 下 Electron 走 X11 通常比 Wayland 穩
export ELECTRON_OZONE_PLATFORM_HINT=x11
export OZONE_PLATFORM=x11
# 背景啟動 Electron它會自動管理 Sidecar
nohup npm start > "$PROJECT_DIR/frontend.log" 2>&1 &
local frontend_pid=$!