Twilioapp/scripts/start-dev.bat

87 lines
2.0 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul
title 跨平台翻译应用开发环境
echo 🚀 启动跨平台翻译应用开发环境...
REM 检查Node.js是否安装
node --version >nul 2>&1
if errorlevel 1 (
echo ❌ Node.js未安装请先安装Node.js
pause
exit /b 1
)
REM 检查npm是否安装
npm --version >nul 2>&1
if errorlevel 1 (
echo ❌ npm未安装请先安装npm
pause
exit /b 1
)
REM 检查环境变量文件
if not exist .env (
echo ⚠️ .env文件不存在从.env.example复制...
if exist .env.example (
copy .env.example .env >nul
echo ✅ 已创建.env文件请配置相应的环境变量
) else (
echo ❌ .env.example文件不存在
pause
exit /b 1
)
)
REM 安装依赖
echo 📦 安装依赖包...
call npm install
if errorlevel 1 (
echo ❌ 依赖安装失败
pause
exit /b 1
)
REM 清理缓存并启动Metro服务器
echo 🧹 清理缓存并启动Metro服务器...
start "Metro Server" cmd /c "npx react-native start --reset-cache"
REM 等待Metro服务器启动
echo ⏳ 等待Metro服务器启动...
timeout /t 5 /nobreak >nul
REM 询问用户要启动哪个平台
echo.
echo 请选择要启动的平台:
echo 1) Android
echo 2) iOS (需要macOS)
echo 3) 只启动Metro服务器
echo.
set /p choice=请输入选择 (1-3):
if "%choice%"=="1" (
echo 🤖 启动Android应用...
call npx react-native run-android
) else if "%choice%"=="2" (
echo 🍎 启动iOS应用...
call npx react-native run-ios
) else if "%choice%"=="3" (
echo 📱 只启动Metro服务器请手动运行应用
) else (
echo ❌ 无效选择
pause
exit /b 1
)
echo.
echo ✅ 开发环境启动完成!
echo 📱 应用正在构建和安装到设备/模拟器...
echo.
echo 🔧 如遇到问题,请检查:
echo - Android Studio是否正确安装和配置
echo - 设备/模拟器是否正常运行
echo - 环境变量是否正确配置
echo - 防火墙是否阻止了Metro服务器
echo.
echo 按任意键退出...
pause >nul