kindergarten_java/api-generator.sh
En 745f4e4b06 feat(api): 新增自动化 API 更新工具和协作文档
- 添加 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>
2026-03-09 18:04:29 +08:00

48 lines
1.1 KiB
Bash
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.

#!/bin/bash
# 后端接口变更后自动更新前端 API 规范
# 使用方式:修改接口后运行 ./api-generator.sh
echo "=== 自动更新前端 API 规范 ==="
# 检查前端目录是否存在
if [ ! -d "reading-platform-frontend" ]; then
echo "❌ 错误:前端目录不存在"
exit 1
fi
# 进入前端目录
cd reading-platform-frontend
# 检查 npm 是否安装
if ! npm --version > /dev/null 2>&1; then
echo "❌ 错误:未找到 npm请安装 Node.js 18+"
exit 1
fi
# 检查 package.json 中是否有 api:update 脚本
if ! grep -q "api:update" package.json; then
echo "❌ 错误package.json 中未找到 api:update 脚本"
exit 1
fi
echo "📦 正在安装依赖..."
npm install
echo "🔄 正在拉取最新 API 规范并生成代码..."
npm run api:update
echo "✅ 完成!"
# 显示修改的文件
echo ""
echo "📝 修改的文件:"
git status --short
# 提示用户检查并提交
echo ""
echo "💡 请检查生成的文件,然后提交:"
echo " git add api-spec.yml src/api/generated/"
echo " git commit -m 'chore(api): 同步最新接口规范'"
echo " git push"