- 添加 api-generator.bat/api-generator.sh 脚本,简化后端接口修改后的前端 API 同步流程 - 新增 reading-platform-frontend/README.md,说明 API 开发协作规范 - 更新 docs/开发协作指南.md,补充协作模式说明和新功能开发检查清单 - 同步最新 API 规范和生成的 TypeScript 类型代码 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.1 KiB
Batchfile
50 lines
1.1 KiB
Batchfile
@echo off
|
||
|
||
REM 后端接口变更后自动更新前端 API 规范
|
||
REM 使用方式:修改接口后运行 api-generator.bat
|
||
|
||
echo === 自动更新前端 API 规格 ===
|
||
|
||
REM 检查前端目录是否存在
|
||
if not exist "reading-platform-frontend" (
|
||
echo ❌ 错误:前端目录不存在
|
||
exit /b 1
|
||
)
|
||
|
||
REM 进入前端目录
|
||
cd reading-platform-frontend
|
||
|
||
REM 检查 npm 是否安装
|
||
node --version > NUL 2>&1
|
||
if %errorlevel% neq 0 (
|
||
echo ❌ 错误:未找到 Node.js,请安装 Node.js 18+
|
||
exit /b 1
|
||
)
|
||
|
||
REM 检查 package.json 中是否有 api:update 脚本
|
||
findstr "api:update" package.json > NUL
|
||
if %errorlevel% neq 0 (
|
||
echo ❌ 错误:package.json 中未找到 api:update 脚本
|
||
exit /b 1
|
||
)
|
||
|
||
echo 📦 正在安装依赖...
|
||
call npm install
|
||
|
||
echo 🔄 正在拉取最新 API 规范并生成代码...
|
||
call npm run api:update
|
||
|
||
echo ✅ 完成!
|
||
|
||
REM 显示修改的文件
|
||
echo.
|
||
echo 📝 修改的文件:
|
||
git status --short
|
||
|
||
REM 提示用户检查并提交
|
||
echo.
|
||
echo 💡 请检查生成的文件,然后提交:
|
||
echo git add api-spec.yml src/api/generated/
|
||
echo git commit -m "chore(api): 同步最新接口规范"
|
||
echo git push
|