修复批处理脚本语法错误
主要修复: - 移除可能被误解析的特殊字符 - 修复条件判断语句 - 简化变量传递方式 - 使用方括号标识选项避免歧义 - 优化参数处理逻辑
This commit is contained in:
@@ -4,7 +4,6 @@ setlocal enabledelayedexpansion
|
||||
|
||||
:: ========================================
|
||||
:: Education System - Windows Startup Script
|
||||
:: 教务系统 - Windows启动脚本
|
||||
:: ========================================
|
||||
|
||||
:MAIN_MENU
|
||||
@@ -16,27 +15,27 @@ echo ========================================
|
||||
echo.
|
||||
echo Select an option / 请选择一个选项:
|
||||
echo.
|
||||
echo 0 - Start All Industries / 启动所有产业
|
||||
echo [0] Start All Industries / 启动所有产业
|
||||
echo --------------
|
||||
echo 1 - Cultural Tourism / 文旅产业 (Port/端口: 5150)
|
||||
echo 2 - Smart Manufacturing / 智能制造 (Port/端口: 5151)
|
||||
echo 3 - Smart Development / 智能开发 (Port/端口: 5152)
|
||||
echo 4 - Finance and Commerce / 财经商贸 (Port/端口: 5153)
|
||||
echo 5 - Visual Design / 视觉设计 (Port/端口: 5154)
|
||||
echo 6 - Transportation / 交通物流 (Port/端口: 5155)
|
||||
echo 7 - Healthcare / 大健康 (Port/端口: 5156)
|
||||
echo 8 - Civil Engineering / 土木水利 (Port/端口: 5157)
|
||||
echo 9 - Food Industry / 食品产业 (Port/端口: 5158)
|
||||
echo 10 - Chemical Industry / 化工产业 (Port/端口: 5159)
|
||||
echo 11 - Energy Industry / 能源产业 (Port/端口: 5160)
|
||||
echo 12 - Environmental / 环保产业 (Port/端口: 5161)
|
||||
echo [1] Cultural Tourism / 文旅产业 (Port: 5150)
|
||||
echo [2] Smart Manufacturing / 智能制造 (Port: 5151)
|
||||
echo [3] Smart Development / 智能开发 (Port: 5152)
|
||||
echo [4] Finance and Commerce / 财经商贸 (Port: 5153)
|
||||
echo [5] Visual Design / 视觉设计 (Port: 5154)
|
||||
echo [6] Transportation / 交通物流 (Port: 5155)
|
||||
echo [7] Healthcare / 大健康 (Port: 5156)
|
||||
echo [8] Civil Engineering / 土木水利 (Port: 5157)
|
||||
echo [9] Food Industry / 食品产业 (Port: 5158)
|
||||
echo [10] Chemical Industry / 化工产业 (Port: 5159)
|
||||
echo [11] Energy Industry / 能源产业 (Port: 5160)
|
||||
echo [12] Environmental / 环保产业 (Port: 5161)
|
||||
echo --------------
|
||||
echo A - Stop All / 停止所有
|
||||
echo S - Check Status / 查看状态
|
||||
echo Q - Exit / 退出
|
||||
echo [A] Stop All / 停止所有
|
||||
echo [S] Status / 查看状态
|
||||
echo [Q] Exit / 退出
|
||||
echo.
|
||||
|
||||
set /p choice=Enter your choice / 请输入选项:
|
||||
set /p choice="Enter your choice / 请输入选项: "
|
||||
|
||||
if "%choice%"=="0" goto START_ALL
|
||||
if "%choice%"=="1" goto START_1
|
||||
@@ -62,103 +61,105 @@ goto MAIN_MENU
|
||||
:START_ALL
|
||||
echo.
|
||||
echo Starting all industries... / 正在启动所有产业...
|
||||
call :START_INDUSTRY "frontend" "Cultural Tourism / 文旅产业" 5150
|
||||
call :START_INDUSTRY "frontend_智能制造" "Smart Manufacturing / 智能制造" 5151
|
||||
call :START_INDUSTRY "frontend_智能开发" "Smart Development / 智能开发" 5152
|
||||
call :START_INDUSTRY "frontend_财经商贸" "Finance Commerce / 财经商贸" 5153
|
||||
call :START_INDUSTRY "frontend_视觉设计" "Visual Design / 视觉设计" 5154
|
||||
call :START_INDUSTRY "frontend_交通物流" "Transportation / 交通物流" 5155
|
||||
call :START_INDUSTRY "frontend_大健康" "Healthcare / 大健康" 5156
|
||||
call :START_INDUSTRY "frontend_土木水利" "Civil Engineering / 土木水利" 5157
|
||||
call :START_INDUSTRY "frontend_食品" "Food Industry / 食品产业" 5158
|
||||
call :START_INDUSTRY "frontend_化工" "Chemical Industry / 化工产业" 5159
|
||||
call :START_INDUSTRY "frontend_能源" "Energy Industry / 能源产业" 5160
|
||||
call :START_INDUSTRY "frontend_环保" "Environmental / 环保产业" 5161
|
||||
call :START_INDUSTRY frontend "Cultural Tourism / 文旅产业" 5150
|
||||
call :START_INDUSTRY frontend_智能制造 "Smart Manufacturing / 智能制造" 5151
|
||||
call :START_INDUSTRY frontend_智能开发 "Smart Development / 智能开发" 5152
|
||||
call :START_INDUSTRY frontend_财经商贸 "Finance Commerce / 财经商贸" 5153
|
||||
call :START_INDUSTRY frontend_视觉设计 "Visual Design / 视觉设计" 5154
|
||||
call :START_INDUSTRY frontend_交通物流 "Transportation / 交通物流" 5155
|
||||
call :START_INDUSTRY frontend_大健康 "Healthcare / 大健康" 5156
|
||||
call :START_INDUSTRY frontend_土木水利 "Civil Engineering / 土木水利" 5157
|
||||
call :START_INDUSTRY frontend_食品 "Food Industry / 食品产业" 5158
|
||||
call :START_INDUSTRY frontend_化工 "Chemical Industry / 化工产业" 5159
|
||||
call :START_INDUSTRY frontend_能源 "Energy Industry / 能源产业" 5160
|
||||
call :START_INDUSTRY frontend_环保 "Environmental / 环保产业" 5161
|
||||
echo.
|
||||
echo All industries started! / 所有产业已启动!
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_1
|
||||
call :START_INDUSTRY "frontend" "Cultural Tourism / 文旅产业" 5150
|
||||
call :START_INDUSTRY frontend "Cultural Tourism / 文旅产业" 5150
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_2
|
||||
call :START_INDUSTRY "frontend_智能制造" "Smart Manufacturing / 智能制造" 5151
|
||||
call :START_INDUSTRY frontend_智能制造 "Smart Manufacturing / 智能制造" 5151
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_3
|
||||
call :START_INDUSTRY "frontend_智能开发" "Smart Development / 智能开发" 5152
|
||||
call :START_INDUSTRY frontend_智能开发 "Smart Development / 智能开发" 5152
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_4
|
||||
call :START_INDUSTRY "frontend_财经商贸" "Finance Commerce / 财经商贸" 5153
|
||||
call :START_INDUSTRY frontend_财经商贸 "Finance Commerce / 财经商贸" 5153
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_5
|
||||
call :START_INDUSTRY "frontend_视觉设计" "Visual Design / 视觉设计" 5154
|
||||
call :START_INDUSTRY frontend_视觉设计 "Visual Design / 视觉设计" 5154
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_6
|
||||
call :START_INDUSTRY "frontend_交通物流" "Transportation / 交通物流" 5155
|
||||
call :START_INDUSTRY frontend_交通物流 "Transportation / 交通物流" 5155
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_7
|
||||
call :START_INDUSTRY "frontend_大健康" "Healthcare / 大健康" 5156
|
||||
call :START_INDUSTRY frontend_大健康 "Healthcare / 大健康" 5156
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_8
|
||||
call :START_INDUSTRY "frontend_土木水利" "Civil Engineering / 土木水利" 5157
|
||||
call :START_INDUSTRY frontend_土木水利 "Civil Engineering / 土木水利" 5157
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_9
|
||||
call :START_INDUSTRY "frontend_食品" "Food Industry / 食品产业" 5158
|
||||
call :START_INDUSTRY frontend_食品 "Food Industry / 食品产业" 5158
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_10
|
||||
call :START_INDUSTRY "frontend_化工" "Chemical Industry / 化工产业" 5159
|
||||
call :START_INDUSTRY frontend_化工 "Chemical Industry / 化工产业" 5159
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_11
|
||||
call :START_INDUSTRY "frontend_能源" "Energy Industry / 能源产业" 5160
|
||||
call :START_INDUSTRY frontend_能源 "Energy Industry / 能源产业" 5160
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_12
|
||||
call :START_INDUSTRY "frontend_环保" "Environmental / 环保产业" 5161
|
||||
call :START_INDUSTRY frontend_环保 "Environmental / 环保产业" 5161
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_INDUSTRY
|
||||
set "dir=%~1"
|
||||
set "name=%~2"
|
||||
set "port=%~3"
|
||||
set dir=%1
|
||||
set name=%2
|
||||
set port=%3
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Starting / 正在启动: %name%
|
||||
echo Port / 端口: %port%
|
||||
echo Starting: %name%
|
||||
echo Port: %port%
|
||||
echo ========================================
|
||||
|
||||
if not exist "%dir%" (
|
||||
echo [ERROR/错误] Directory does not exist! / 目录不存在: %dir%
|
||||
if not exist %dir% (
|
||||
echo ERROR: Directory %dir% does not exist!
|
||||
echo 错误: 目录 %dir% 不存在!
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
netstat -an | findstr ":%port%" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo [WARNING/警告] Port is already in use / 端口已被占用: %port%
|
||||
set /p stop_choice=Stop existing service? / 停止现有服务? (y/n):
|
||||
echo WARNING: Port %port% is already in use
|
||||
echo 警告: 端口 %port% 已被占用
|
||||
set /p stop_choice="Stop existing service? (y/n) / 停止现有服务? (y/n): "
|
||||
if /i "!stop_choice!"=="y" (
|
||||
echo Stopping service... / 正在停止服务...
|
||||
for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":%port%"') do (
|
||||
@@ -171,22 +172,22 @@ if %errorlevel%==0 (
|
||||
)
|
||||
)
|
||||
|
||||
cd "%dir%" 2>nul
|
||||
if not exist "node_modules" (
|
||||
echo [INFO/信息] Installing dependencies... / 正在安装依赖...
|
||||
echo Please wait 1-3 minutes... / 请等待1-3分钟...
|
||||
cd %dir% 2>nul
|
||||
if not exist node_modules (
|
||||
echo INFO: Installing dependencies... / 正在安装依赖...
|
||||
echo Please wait 1-3 minutes... / 请等待1-3分钟...
|
||||
call npm install
|
||||
if !errorlevel! neq 0 (
|
||||
echo [ERROR/错误] Installation failed! / 安装失败!
|
||||
echo ERROR: Installation failed! / 安装失败!
|
||||
cd ..
|
||||
exit /b 1
|
||||
)
|
||||
echo [SUCCESS/成功] Dependencies installed! / 依赖安装完成!
|
||||
echo SUCCESS: Dependencies installed! / 依赖安装完成!
|
||||
) else (
|
||||
echo [INFO/信息] Dependencies exist / 依赖已存在
|
||||
echo INFO: Dependencies exist / 依赖已存在
|
||||
)
|
||||
|
||||
echo [INFO/信息] Starting service... / 正在启动服务...
|
||||
echo INFO: Starting service... / 正在启动服务...
|
||||
start /min cmd /c "npm run dev"
|
||||
cd ..
|
||||
|
||||
@@ -195,12 +196,13 @@ timeout /t 3 >nul
|
||||
|
||||
netstat -an | findstr ":%port%" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo [SUCCESS/成功] Started successfully! / 启动成功!
|
||||
echo SUCCESS: Started successfully! / 启动成功!
|
||||
echo.
|
||||
echo Access URL / 访问地址: http://localhost:%port%
|
||||
echo Access URL: http://localhost:%port%
|
||||
echo 访问地址: http://localhost:%port%
|
||||
echo.
|
||||
) else (
|
||||
echo [ERROR/错误] Failed to start! / 启动失败!
|
||||
echo ERROR: Failed to start! / 启动失败!
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
@@ -242,12 +244,14 @@ pause >nul
|
||||
goto MAIN_MENU
|
||||
|
||||
:CHECK_PORT
|
||||
netstat -an | findstr ":%1" >nul 2>&1
|
||||
set port=%1
|
||||
set name=%2
|
||||
netstat -an | findstr ":%port%" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo [RUNNING/运行中] %~2 - Port/端口: %1
|
||||
echo URL: http://localhost:%1
|
||||
echo [RUNNING] %name% - Port: %port%
|
||||
echo URL: http://localhost:%port%
|
||||
) else (
|
||||
echo [STOPPED/未启动] %~2 - Port/端口: %1
|
||||
echo [STOPPED] %name% - Port: %port%
|
||||
)
|
||||
exit /b 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user