Files
Agent-n8n/n8n-n8n-1.109.2/start_cn.bat
Yep_Q 3e7d0f39f8 feat: 优化展会演示前端界面和功能
主要更新:
- 重新设计首页UI,采用现代黑色科技风格
- 修复结果弹窗按钮显示问题,固定在底部
- 添加Duoduo Agent Logo和三击调试功能
- 添加右下角浮动查看结果按钮
- 优化功能卡片布局和对齐
- 简化按钮文字为'开始'
- 移除首页演示案例内容
- 创建Windows启动脚本start_cn.bat

技术改进:
- 使用深色主题配色方案
- 添加网格背景和动态光效
- 优化组件动画效果
- 改进响应式布局

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:18:37 +08:00

500 lines
12 KiB
Batchfile

@echo off
REM Save original codepage
for /f "tokens=2 delims=:" %%a in ('chcp') do set OLDCP=%%a
chcp 65001 >nul 2>&1
REM n8n Chinese Version Quick Start Script (Windows)
REM Author: xiaoqi
REM Last Update: 2025-09-09
REM Compatibility: Windows 7/8/10/11
setlocal enabledelayedexpansion
REM Display banner
:show_banner
echo ======================================
echo n8n Chinese Version Launcher
echo Version: n8n-1.109.2 with CN
echo Maintainer: xiaoqi
echo ======================================
echo.
REM Parse command line arguments
set "DEV_MODE="
set "FORCE_BUILD="
set "CHECK_ONLY="
set "SKIP_DEPS="
set "USE_NPM="
set "CUSTOM_PORT=5678"
:parse_args
if "%~1"=="" goto main_execution
if /I "%~1"=="-h" goto show_help
if /I "%~1"=="--help" goto show_help
if /I "%~1"=="-d" (
set "DEV_MODE=true"
shift
goto parse_args
)
if /I "%~1"=="--dev" (
set "DEV_MODE=true"
shift
goto parse_args
)
if /I "%~1"=="-b" (
set "FORCE_BUILD=true"
shift
goto parse_args
)
if /I "%~1"=="--build" (
set "FORCE_BUILD=true"
shift
goto parse_args
)
if /I "%~1"=="-c" (
set "CHECK_ONLY=true"
shift
goto parse_args
)
if /I "%~1"=="--check" (
set "CHECK_ONLY=true"
shift
goto parse_args
)
if /I "%~1"=="--skip-deps" (
set "SKIP_DEPS=true"
shift
goto parse_args
)
if /I "%~1"=="--npm" (
set "USE_NPM=true"
shift
goto parse_args
)
if /I "%~1"=="-p" (
set "CUSTOM_PORT=%~2"
shift
shift
goto parse_args
)
if /I "%~1"=="--port" (
set "CUSTOM_PORT=%~2"
shift
shift
goto parse_args
)
echo [ERROR] Unknown option: %~1
goto show_help
:main_execution
REM Check OS version
call :check_os_version
REM Check and change to correct directory
call :check_and_change_directory
if errorlevel 1 goto error_exit
REM Check dependencies
if not defined SKIP_DEPS (
echo [INFO] Checking system dependencies...
call :check_dependencies
if errorlevel 1 goto error_exit
)
REM Check port
call :check_port
if errorlevel 1 goto error_exit
REM Stop existing processes
call :stop_existing
REM Setup environment
call :setup_environment
REM Check only mode
if defined CHECK_ONLY (
echo [SUCCESS] System check completed
goto end
)
REM Install dependencies if needed
if not exist "node_modules\" (
echo [INFO] Installing dependencies...
if defined USE_NPM (
call :install_with_npm
) else (
call :install_with_pnpm
)
if errorlevel 1 goto error_exit
)
REM Check and install run-script-os
if not exist "node_modules\run-script-os" (
echo [FIX] Installing run-script-os...
call npm install run-script-os
)
REM Build or check build
if defined FORCE_BUILD (
echo [INFO] Force rebuilding project...
call :build_project
if errorlevel 1 goto error_exit
) else (
call :check_build
if errorlevel 1 goto error_exit
)
REM Dev mode or normal start
if defined DEV_MODE (
echo [INFO] Starting n8n in development mode...
echo [WARNING] Dev mode takes longer to start...
if defined USE_NPM (
call npm run dev
) else (
call pnpm dev
)
) else (
call :start_n8n
)
goto end
REM ========== Functions ==========
:check_os_version
ver | findstr /i "5\.1\." >nul
if not errorlevel 1 (
echo [WARNING] Windows XP detected
)
ver | findstr /i "6\.0\." >nul
if not errorlevel 1 (
echo [INFO] Windows Vista detected
)
ver | findstr /i "6\.1\." >nul
if not errorlevel 1 (
echo [INFO] Windows 7 detected
)
ver | findstr /i "6\.2\." >nul
if not errorlevel 1 (
echo [INFO] Windows 8 detected
)
ver | findstr /i "6\.3\." >nul
if not errorlevel 1 (
echo [INFO] Windows 8.1 detected
)
ver | findstr /i "10\.0\." >nul
if not errorlevel 1 (
echo [INFO] Windows 10/11 detected
)
exit /b 0
:check_and_change_directory
if exist "package.json" if exist "packages" (
echo [INFO] Already in n8n project directory
exit /b 0
)
set "SCRIPT_DIR=%~dp0"
if "%SCRIPT_DIR:~-1%"=="\" set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%"
echo %SCRIPT_DIR% | findstr /I /C:"n8n-n8n-1.109.2" >nul
if not errorlevel 1 (
echo [INFO] Switching to n8n project directory
cd /d "%SCRIPT_DIR%" 2>nul
if errorlevel 1 (
cd "%SCRIPT_DIR%" 2>nul
if errorlevel 1 (
echo [ERROR] Cannot change to directory: %SCRIPT_DIR%
exit /b 1
)
)
echo [SUCCESS] Changed to correct n8n project directory
exit /b 0
)
if exist "n8n-n8n-1.109.2\" (
cd n8n-n8n-1.109.2
) else if exist "..\n8n-n8n-1.109.2\" (
cd ..\n8n-n8n-1.109.2
) else if exist "..\..\n8n-n8n-1.109.2\" (
cd ..\..\n8n-n8n-1.109.2
) else (
echo [ERROR] n8n-n8n-1.109.2 directory not found
echo [INFO] Please run this script from the correct project directory
exit /b 1
)
if not exist "package.json" (
echo [ERROR] Invalid directory structure, missing package.json
exit /b 1
)
if not exist "packages" (
echo [ERROR] Invalid directory structure, missing packages directory
exit /b 1
)
echo [SUCCESS] Changed to correct n8n project directory
exit /b 0
:check_dependencies
where node >nul 2>&1
if errorlevel 1 (
if exist "C:\Program Files\nodejs\node.exe" (
set "PATH=C:\Program Files\nodejs;%PATH%"
) else if exist "C:\Program Files (x86)\nodejs\node.exe" (
set "PATH=C:\Program Files (x86)\nodejs;%PATH%"
) else (
echo [ERROR] Node.js not installed or not in PATH
echo [INFO] Please visit https://nodejs.org to download and install
exit /b 1
)
)
echo [INFO] Node.js version:
node --version
if not defined USE_NPM (
where pnpm >nul 2>&1
if errorlevel 1 (
echo [WARNING] pnpm not installed, trying npm
set "USE_NPM=true"
) else (
echo [INFO] Using pnpm as package manager
)
) else (
echo [INFO] Using npm as package manager
)
echo [SUCCESS] Dependencies check passed
exit /b 0
:install_with_pnpm
echo [INFO] Installing dependencies with pnpm...
where pnpm >nul 2>&1
if errorlevel 1 (
echo [INFO] Installing pnpm...
call npm install -g pnpm@8
if errorlevel 1 (
echo [ERROR] pnpm installation failed
exit /b 1
)
)
call pnpm install --no-frozen-lockfile
exit /b %errorlevel%
:install_with_npm
echo [WARNING] Using npm install
echo [INFO] Recommend installing pnpm: npm install -g pnpm
call npm install --legacy-peer-deps
exit /b %errorlevel%
:check_port
echo [INFO] Checking port %CUSTOM_PORT% availability...
netstat -ano 2>nul | findstr ":%CUSTOM_PORT%" >nul 2>&1
if not errorlevel 1 (
echo [WARNING] Port %CUSTOM_PORT% is already in use
echo [INFO] Checking process using the port...
netstat -ano | findstr ":%CUSTOM_PORT%"
echo.
set /p "kill_process=Terminate the process? (y/N): "
if /I "!kill_process!"=="y" (
echo [INFO] Terminating process...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%CUSTOM_PORT%"') do (
taskkill /PID %%a /F >nul 2>&1
if errorlevel 1 (
tskill %%a >nul 2>&1
)
)
echo [SUCCESS] Process terminated
timeout /t 2 /nobreak >nul 2>&1
if errorlevel 1 (
ping -n 3 127.0.0.1 >nul
)
) else (
echo [ERROR] Cannot start n8n, port is in use
exit /b 1
)
)
exit /b 0
:stop_existing
echo [INFO] Stopping existing n8n processes...
taskkill /F /IM node.exe /FI "WINDOWTITLE eq *n8n*" >nul 2>&1
taskkill /F /IM node.exe /FI "WINDOWTITLE eq *pnpm*" >nul 2>&1
taskkill /F /IM node.exe /FI "WINDOWTITLE eq *npm*" >nul 2>&1
timeout /t 2 /nobreak >nul 2>&1
if errorlevel 1 (
ping -n 3 127.0.0.1 >nul
)
echo [SUCCESS] Existing processes stopped
exit /b 0
:setup_environment
echo [INFO] Setting environment variables...
set "N8N_PORT=%CUSTOM_PORT%"
set "N8N_DEFAULT_LOCALE=zh-CN"
set "N8N_SECURE_COOKIE=false"
set "DB_SQLITE_POOL_SIZE=5"
set "N8N_RUNNERS_ENABLED=true"
set "N8N_BLOCK_ENV_ACCESS_IN_NODE=false"
set "NODE_OPTIONS=--max-old-space-size=4096"
echo [SUCCESS] Environment variables set
echo - N8N_PORT=%CUSTOM_PORT%
echo - N8N_DEFAULT_LOCALE=zh-CN
echo - N8N_SECURE_COOKIE=false
echo - DB_SQLITE_POOL_SIZE=5
echo - NODE_OPTIONS=--max-old-space-size=4096
exit /b 0
:check_build
if not exist "packages\cli\dist\" goto need_build
if not exist "packages\core\dist\" goto need_build
if not exist "packages\workflow\dist\" goto need_build
exit /b 0
:need_build
echo [WARNING] Project needs to be built
set /p "build_project=Build project now? This may take a few minutes (y/N): "
if /I "!build_project!"=="y" (
call :build_project
)
exit /b 0
:build_project
echo [INFO] Building project...
if defined USE_NPM (
call npm run build > build.log 2>&1
) else (
call pnpm build > build.log 2>&1
)
if errorlevel 1 (
echo [ERROR] Build failed, check build.log
type build.log | more
exit /b 1
)
echo [SUCCESS] Project built successfully
exit /b 0
:start_n8n
echo [INFO] Starting n8n Chinese version...
set "DATETIME=%date:~0,4%%date:~5,2%%date:~8,2%-%time:~0,2%%time:~3,2%"
set "DATETIME=%DATETIME: =0%"
set "DATETIME=%DATETIME:/=%"
set "DATETIME=%DATETIME:\=%"
set "LOG_FILE=n8n-%DATETIME%.log"
echo [INFO] Starting n8n service...
echo [INFO] Log file: %LOG_FILE%
if defined USE_NPM (
start "n8n Server" /B cmd /c "npm start > %LOG_FILE% 2>&1"
) else (
start "n8n Server" /B cmd /c "pnpm start > %LOG_FILE% 2>&1"
)
echo Waiting for n8n to start
set "count=0"
:wait_loop
set /a count+=1
if %count% gtr 60 goto start_failed
netstat -an 2>nul | findstr ":%CUSTOM_PORT%" | findstr "LISTENING" >nul 2>&1
if not errorlevel 1 goto start_success
set /p "=." <nul
timeout /t 1 /nobreak >nul 2>&1
if errorlevel 1 (
ping -n 2 127.0.0.1 >nul
)
goto wait_loop
:start_success
echo.
echo [SUCCESS] n8n started successfully!
echo.
echo ========== START INFO ==========
echo Access URL: http://localhost:%CUSTOM_PORT%
echo Interface Language: Chinese (zh-CN)
echo Log file: %LOG_FILE%
echo =================================
echo.
echo [INFO] Use Ctrl+C to stop service
echo [TIP] First visit requires account setup
echo.
pause
exit /b 0
:start_failed
echo.
echo [ERROR] n8n failed to start
echo [INFO] Check log file: %LOG_FILE%
if exist "%LOG_FILE%" (
echo.
echo ===== ERROR LOG =====
type "%LOG_FILE%" | more
)
echo.
echo [INFO] Trying alternative start method...
call npx n8n
if errorlevel 1 (
echo [ERROR] Alternative method also failed
echo.
echo Please try:
echo 1. Run: npm install run-script-os
echo 2. Run: node packages/cli/bin/n8n
)
pause
exit /b 1
:show_help
echo Usage: %~nx0 [options]
echo.
echo Options:
echo -h, --help Show this help
echo -d, --dev Start in development mode
echo -b, --build Force rebuild project
echo -c, --check Only check system status
echo -p, --port Specify port (default: 5678)
echo --skip-deps Skip dependency check
echo --npm Use npm instead of pnpm
echo.
echo Examples:
echo %~nx0 # Normal start (port 5678)
echo %~nx0 -p 8080 # Use port 8080
echo %~nx0 -d # Development mode
echo %~nx0 -b # Rebuild and start
echo %~nx0 --npm # Use npm
echo %~nx0 -p 3000 -d # Dev mode on port 3000
echo.
echo Troubleshooting:
echo 1. If pnpm install fails, use --npm option
echo 2. If port is in use, script will prompt to terminate process
echo 3. Check build.log when build fails
echo.
goto end
:error_exit
echo [ERROR] Script execution failed
echo.
echo Common solutions:
echo 1. Ensure Node.js version is 18.x or 20.x
echo 2. Try running with administrator privileges
echo 3. Use --npm option if pnpm has issues
echo 4. Check network connection and proxy settings
echo.
pause
exit /b 1
:end
REM Restore original codepage
if defined OLDCP (
chcp %OLDCP% >nul 2>&1
)
endlocal
exit /b 0