feat: 添加管理端前端 (HMS 基座 React 管理面板)
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled

- 从 HMS 基座复制 apps/web/ (React + Ant Design + Vite + TypeScript)
- 管理端自动代理 API 到 localhost:3000 (vite.config.ts)
- 更新 scripts/dev.sh 支持三端启动: backend/admin/app
- 登录验证通过, 用户管理/角色权限/审计日志等页面正常
- 添加 .gitignore 排除 node_modules/dist
This commit is contained in:
iven
2026-06-02 10:03:13 +08:00
parent 181bfb1f3e
commit 8111471e93
341 changed files with 72102 additions and 1059 deletions

View File

@@ -2,16 +2,18 @@
# 暖记开发环境启动脚本 — 自动清理旧进程 + 启动后端和前端
#
# 用法:
# ./scripts/dev.sh # 启动全部
# ./scripts/dev.sh # 启动全部 (后端+管理端+学生端)
# ./scripts/dev.sh backend # 只启动后端
# ./scripts/dev.sh frontend # 只启动前端
# ./scripts/dev.sh admin # 只启动管理端前端 (React, port 5174)
# ./scripts/dev.sh app # 只启动学生端 Flutter (port 8080)
# ./scripts/dev.sh stop # 停止所有服务
set -e
# ===== 配置 =====
BACKEND_PORT=3000
FRONTEND_PORT=8080
ADMIN_PORT=5174 # 管理端前端 (React + Ant Design)
APP_PORT=8080 # 学生端前端 (Flutter Web)
PG_HOST="localhost"
PG_PORT=5432
PG_USER="postgres"
@@ -52,8 +54,8 @@ kill_port() {
stop_all() {
log_info "停止所有暖记服务..."
kill_port $BACKEND_PORT "后端"
kill_port $FRONTEND_PORT "前端"
# 也杀掉可能的残留 Chrome 进程Flutter dev 启动的)
kill_port $ADMIN_PORT "管理端前端"
kill_port $APP_PORT "学生端前端"
taskkill //F //IM erp-server.exe 2>/dev/null && log_ok "已停止 erp-server.exe" || true
log_ok "所有服务已停止"
}
@@ -97,6 +99,7 @@ start_backend() {
sleep 1
log_info "编译并启动后端 (diary feature)..."
cd /g/nj
ERP__DATABASE__URL="postgres://${PG_USER}:${PG_PASS}@${PG_HOST}:${PG_PORT}/${PG_DB}" \
ERP__REDIS__URL="redis://localhost:6379" \
ERP__JWT__SECRET="nuanji-dev-jwt-secret-2024-warm-notes-hmac-key-32b" \
@@ -120,25 +123,47 @@ start_backend() {
return 1
}
# ===== 启动前端 =====
start_frontend() {
log_info "清理旧端进程..."
kill_port $FRONTEND_PORT "前端"
# ===== 启动管理端前端 (React + Ant Design) =====
start_admin() {
log_info "清理旧管理端进程..."
kill_port $ADMIN_PORT "管理端前端"
sleep 1
log_info "启动管理端前端 (React + Vite)..."
cd /g/nj/apps/web
pnpm dev &
log_info "等待管理端就绪..."
for i in $(seq 1 20); do
if curl -s -o /dev/null "http://localhost:${ADMIN_PORT}" 2>/dev/null; then
log_ok "管理端已就绪 → http://localhost:${ADMIN_PORT}"
return 0
fi
sleep 2
done
log_err "管理端启动超时"
return 1
}
# ===== 启动学生端 Flutter Web =====
start_app() {
log_info "清理旧学生端进程..."
kill_port $APP_PORT "学生端前端"
sleep 1
log_info "编译并启动 Flutter Web..."
cd /g/nj/app
D:/flutter/bin/flutter.bat run -d chrome --web-port=$FRONTEND_PORT &
D:/flutter/bin/flutter.bat run -d chrome --web-port=$APP_PORT &
log_info "等待端就绪..."
log_info "等待学生端就绪..."
for i in $(seq 1 30); do
if curl -s "http://localhost:${FRONTEND_PORT}" > /dev/null 2>&1; then
log_ok "端已就绪 → http://localhost:${FRONTEND_PORT}"
if curl -s -o /dev/null "http://localhost:${APP_PORT}" 2>/dev/null; then
log_ok "学生端已就绪 → http://localhost:${APP_PORT}"
return 0
fi
sleep 3
done
log_err "端启动超时"
log_err "学生端启动超时"
return 1
}
@@ -151,21 +176,26 @@ case "${1:-all}" in
check_deps
start_backend
;;
frontend)
admin)
check_deps
start_frontend
start_admin
;;
app)
check_deps
start_app
;;
all)
check_deps
start_backend
start_frontend
start_admin
start_app
log_ok "=== 暖记开发环境已启动 ==="
log_ok "后端: http://localhost:${BACKEND_PORT}"
log_ok "前端: http://localhost:${FRONTEND_PORT}"
log_ok "API 文档: http://localhost:${BACKEND_PORT}/api/v1/health"
log_ok "后端 API: http://localhost:${BACKEND_PORT}"
log_ok "管理端: http://localhost:${ADMIN_PORT} (admin/admin123)"
log_ok "学生端: http://localhost:${APP_PORT}"
;;
*)
echo "用法: $0 [all|backend|frontend|stop]"
echo "用法: $0 [all|backend|admin|app|stop]"
exit 1
;;
esac