修复Windows批处理脚本问题
- 解决中文字符编码问题 - 修复语法错误和参数传递 - 改用英文界面提高兼容性 - 增强错误处理逻辑
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
"Bash(git init:*)",
|
||||
"Bash(git remote add:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git rm:*)"
|
||||
"Bash(git rm:*)",
|
||||
"Bash(git push:*)",
|
||||
"Bash(git commit:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -1,44 +1,40 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
chcp 65001 >nul 2>&1
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: ========================================
|
||||
:: 教务系统 - Windows智能启动脚本
|
||||
:: Education System - Windows Startup Script
|
||||
:: ========================================
|
||||
|
||||
:: 颜色定义
|
||||
color 0A
|
||||
|
||||
:: 清屏并显示标题
|
||||
:MAIN_MENU
|
||||
cls
|
||||
echo ========================================
|
||||
echo 教务系统 - 智能启动脚本 (Windows)
|
||||
echo Education System - Smart Launcher
|
||||
echo ========================================
|
||||
echo.
|
||||
echo 请选择操作:
|
||||
echo Select an option:
|
||||
echo.
|
||||
echo 0) 启动所有产业
|
||||
echo 0 - Start All Industries
|
||||
echo --------------
|
||||
echo 1) 文旅产业 (端口: 5150)
|
||||
echo 2) 智能制造 (端口: 5151)
|
||||
echo 3) 智能开发 (端口: 5152)
|
||||
echo 4) 财经商贸 (端口: 5153)
|
||||
echo 5) 视觉设计 (端口: 5154)
|
||||
echo 6) 交通物流 (端口: 5155)
|
||||
echo 7) 大健康 (端口: 5156)
|
||||
echo 8) 土木水利 (端口: 5157)
|
||||
echo 9) 食品产业 (端口: 5158)
|
||||
echo 10) 化工产业 (端口: 5159)
|
||||
echo 11) 能源产业 (端口: 5160)
|
||||
echo 12) 环保产业 (端口: 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 and Logistics (Port: 5155)
|
||||
echo 7 - Healthcare (Port: 5156)
|
||||
echo 8 - Civil and Water Engineering (Port: 5157)
|
||||
echo 9 - Food Industry (Port: 5158)
|
||||
echo 10 - Chemical Industry (Port: 5159)
|
||||
echo 11 - Energy Industry (Port: 5160)
|
||||
echo 12 - Environmental Protection (Port: 5161)
|
||||
echo --------------
|
||||
echo a) 停止所有产业
|
||||
echo s) 查看运行状态
|
||||
echo q) 退出
|
||||
echo A - Stop All Industries
|
||||
echo S - Check Status
|
||||
echo Q - Exit
|
||||
echo.
|
||||
|
||||
set /p choice=请输入选项:
|
||||
set /p choice=Enter your choice:
|
||||
|
||||
if "%choice%"=="0" goto START_ALL
|
||||
if "%choice%"=="1" goto START_1
|
||||
@@ -53,158 +49,152 @@ if "%choice%"=="9" goto START_9
|
||||
if "%choice%"=="10" goto START_10
|
||||
if "%choice%"=="11" goto START_11
|
||||
if "%choice%"=="12" goto START_12
|
||||
if /i "%choice%"=="a" goto STOP_ALL
|
||||
if /i "%choice%"=="s" goto CHECK_STATUS
|
||||
if /i "%choice%"=="q" goto EXIT
|
||||
if /i "%choice%"=="A" goto STOP_ALL
|
||||
if /i "%choice%"=="S" goto CHECK_STATUS
|
||||
if /i "%choice%"=="Q" goto EXIT
|
||||
|
||||
echo 无效选项!
|
||||
echo Invalid option!
|
||||
timeout /t 2 >nul
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_ALL
|
||||
echo.
|
||||
echo 正在启动所有产业...
|
||||
call :START_INDUSTRY frontend "文旅产业" 5150
|
||||
call :START_INDUSTRY frontend_智能制造 "智能制造" 5151
|
||||
call :START_INDUSTRY frontend_智能开发 "智能开发" 5152
|
||||
call :START_INDUSTRY frontend_财经商贸 "财经商贸" 5153
|
||||
call :START_INDUSTRY frontend_视觉设计 "视觉设计" 5154
|
||||
call :START_INDUSTRY frontend_交通物流 "交通物流" 5155
|
||||
call :START_INDUSTRY frontend_大健康 "大健康" 5156
|
||||
call :START_INDUSTRY frontend_土木水利 "土木水利" 5157
|
||||
call :START_INDUSTRY frontend_食品 "食品产业" 5158
|
||||
call :START_INDUSTRY frontend_化工 "化工产业" 5159
|
||||
call :START_INDUSTRY frontend_能源 "能源产业" 5160
|
||||
call :START_INDUSTRY frontend_环保 "环保产业" 5161
|
||||
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
|
||||
echo.
|
||||
echo 所有产业启动完成!
|
||||
echo All industries started!
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_1
|
||||
call :START_INDUSTRY frontend "文旅产业" 5150
|
||||
call :START_INDUSTRY "frontend" "Cultural Tourism" 5150
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_2
|
||||
call :START_INDUSTRY frontend_智能制造 "智能制造" 5151
|
||||
call :START_INDUSTRY "frontend_智能制造" "Smart Manufacturing" 5151
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_3
|
||||
call :START_INDUSTRY frontend_智能开发 "智能开发" 5152
|
||||
call :START_INDUSTRY "frontend_智能开发" "Smart Development" 5152
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_4
|
||||
call :START_INDUSTRY frontend_财经商贸 "财经商贸" 5153
|
||||
call :START_INDUSTRY "frontend_财经商贸" "Finance Commerce" 5153
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_5
|
||||
call :START_INDUSTRY frontend_视觉设计 "视觉设计" 5154
|
||||
call :START_INDUSTRY "frontend_视觉设计" "Visual Design" 5154
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_6
|
||||
call :START_INDUSTRY frontend_交通物流 "交通物流" 5155
|
||||
call :START_INDUSTRY "frontend_交通物流" "Transportation" 5155
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_7
|
||||
call :START_INDUSTRY frontend_大健康 "大健康" 5156
|
||||
call :START_INDUSTRY "frontend_大健康" "Healthcare" 5156
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_8
|
||||
call :START_INDUSTRY frontend_土木水利 "土木水利" 5157
|
||||
call :START_INDUSTRY "frontend_土木水利" "Civil Engineering" 5157
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_9
|
||||
call :START_INDUSTRY frontend_食品 "食品产业" 5158
|
||||
call :START_INDUSTRY "frontend_食品" "Food Industry" 5158
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_10
|
||||
call :START_INDUSTRY frontend_化工 "化工产业" 5159
|
||||
call :START_INDUSTRY "frontend_化工" "Chemical Industry" 5159
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_11
|
||||
call :START_INDUSTRY frontend_能源 "能源产业" 5160
|
||||
call :START_INDUSTRY "frontend_能源" "Energy Industry" 5160
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:START_12
|
||||
call :START_INDUSTRY frontend_环保 "环保产业" 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 启动 %name% (端口: %port%)
|
||||
echo Starting %name% (Port: %port%)
|
||||
echo ========================================
|
||||
|
||||
:: 检查目录是否存在
|
||||
if not exist "%dir%" (
|
||||
echo [错误] 目录 %dir% 不存在!
|
||||
echo [ERROR] Directory %dir% does not exist!
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: 检查端口是否被占用
|
||||
netstat -an | findstr ":%port%" >nul
|
||||
netstat -an | findstr ":%port%" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo [警告] 端口 %port% 已被占用
|
||||
set /p stop_choice=是否停止现有服务并重启?(y/n):
|
||||
echo [WARNING] Port %port% is already in use
|
||||
set /p stop_choice=Stop existing service and restart? (y/n):
|
||||
if /i "!stop_choice!"=="y" (
|
||||
echo 正在停止端口 %port% 的服务...
|
||||
echo Stopping service on port %port%...
|
||||
for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":%port%"') do (
|
||||
taskkill /F /PID %%a >nul 2>&1
|
||||
)
|
||||
timeout /t 2 >nul
|
||||
) else (
|
||||
echo 跳过 %name%
|
||||
echo Skipping %name%
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
:: 检查并安装依赖
|
||||
cd %dir%
|
||||
cd "%dir%" 2>nul
|
||||
if not exist "node_modules" (
|
||||
echo [信息] 检测到依赖未安装,正在安装...
|
||||
echo 这可能需要1-3分钟,请稍候...
|
||||
echo [INFO] Dependencies not found, installing...
|
||||
echo This may take 1-3 minutes, please wait...
|
||||
call npm install
|
||||
if !errorlevel! neq 0 (
|
||||
echo [错误] %name% 依赖安装失败!
|
||||
echo [ERROR] Failed to install dependencies for %name%!
|
||||
cd ..
|
||||
exit /b 1
|
||||
)
|
||||
echo [成功] %name% 依赖安装成功!
|
||||
echo [SUCCESS] Dependencies installed for %name%!
|
||||
) else (
|
||||
echo [信息] %name% 依赖已存在
|
||||
echo [INFO] Dependencies already exist for %name%
|
||||
)
|
||||
|
||||
:: 启动服务
|
||||
echo [信息] 正在启动 %name%...
|
||||
echo [INFO] Starting %name%...
|
||||
start /min cmd /c "npm run dev"
|
||||
cd ..
|
||||
|
||||
timeout /t 3 >nul
|
||||
|
||||
:: 验证启动
|
||||
netstat -an | findstr ":%port%" >nul
|
||||
netstat -an | findstr ":%port%" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo [成功] %name% 启动成功!
|
||||
echo 访问地址: http://localhost:%port%
|
||||
echo [SUCCESS] %name% started successfully!
|
||||
echo Access URL: http://localhost:%port%
|
||||
) else (
|
||||
echo [错误] %name% 启动失败!
|
||||
echo [ERROR] Failed to start %name%!
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
@@ -212,44 +202,47 @@ exit /b 0
|
||||
|
||||
:STOP_ALL
|
||||
echo.
|
||||
echo 正在停止所有产业服务...
|
||||
:: 停止所有node进程
|
||||
echo Stopping all industry services...
|
||||
taskkill /F /IM node.exe >nul 2>&1
|
||||
echo 所有服务已停止
|
||||
if %errorlevel%==0 (
|
||||
echo All services stopped successfully!
|
||||
) else (
|
||||
echo No running services found.
|
||||
)
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:CHECK_STATUS
|
||||
cls
|
||||
echo ========================================
|
||||
echo 产业运行状态检查
|
||||
echo Industry Running Status
|
||||
echo ========================================
|
||||
echo.
|
||||
call :CHECK_PORT 5150 "文旅产业"
|
||||
call :CHECK_PORT 5151 "智能制造"
|
||||
call :CHECK_PORT 5152 "智能开发"
|
||||
call :CHECK_PORT 5153 "财经商贸"
|
||||
call :CHECK_PORT 5154 "视觉设计"
|
||||
call :CHECK_PORT 5155 "交通物流"
|
||||
call :CHECK_PORT 5156 "大健康"
|
||||
call :CHECK_PORT 5157 "土木水利"
|
||||
call :CHECK_PORT 5158 "食品产业"
|
||||
call :CHECK_PORT 5159 "化工产业"
|
||||
call :CHECK_PORT 5160 "能源产业"
|
||||
call :CHECK_PORT 5161 "环保产业"
|
||||
call :CHECK_PORT 5150 "Cultural Tourism"
|
||||
call :CHECK_PORT 5151 "Smart Manufacturing"
|
||||
call :CHECK_PORT 5152 "Smart Development"
|
||||
call :CHECK_PORT 5153 "Finance Commerce"
|
||||
call :CHECK_PORT 5154 "Visual Design"
|
||||
call :CHECK_PORT 5155 "Transportation"
|
||||
call :CHECK_PORT 5156 "Healthcare"
|
||||
call :CHECK_PORT 5157 "Civil Engineering"
|
||||
call :CHECK_PORT 5158 "Food Industry"
|
||||
call :CHECK_PORT 5159 "Chemical Industry"
|
||||
call :CHECK_PORT 5160 "Energy Industry"
|
||||
call :CHECK_PORT 5161 "Environmental"
|
||||
echo.
|
||||
pause
|
||||
goto MAIN_MENU
|
||||
|
||||
:CHECK_PORT
|
||||
netstat -an | findstr ":%1" >nul
|
||||
netstat -an | findstr ":%1" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo [运行中] %2 (端口: %1) - http://localhost:%1
|
||||
echo [RUNNING] %~2 - Port: %1 - http://localhost:%1
|
||||
) else (
|
||||
echo [未启动] %2 (端口: %1)
|
||||
echo [STOPPED] %~2 - Port: %1
|
||||
)
|
||||
exit /b 0
|
||||
|
||||
:EXIT
|
||||
echo 再见!
|
||||
echo Goodbye!
|
||||
exit
|
||||
Reference in New Issue
Block a user