feat(admin): 添加用户管理相关文件

添加用户管理视图、API和状态管理文件
This commit is contained in:
张翔
2026-03-28 14:37:29 +08:00
commit 08ea5fbe98
1643 changed files with 255646 additions and 0 deletions
+160
View File
@@ -0,0 +1,160 @@
#!/bin/bash
# E2E测试运行脚本
# 支持多种运行模式和报告生成
set -e
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# 默认配置
ENV="local"
PROJECT=""
TAG=""
REPORT=false
HEADLESS=false
DEBUG=false
# 帮助信息
show_help() {
echo "E2E测试运行脚本"
echo ""
echo "用法: ./run-e2e-tests.sh [选项]"
echo ""
echo "选项:"
echo " -e, --env <环境> 指定测试环境 (local|dev|test|ci) [默认: local]"
echo " -p, --project <项目> 指定测试项目 (admin|uniapp|integration)"
echo " -t, --tag <标签> 按标签运行测试 (如: @boundary, @error)"
echo " -r, --report 生成完整测试报告"
echo " -h, --headless 无头模式运行"
echo " -d, --debug 调试模式"
echo " --help 显示帮助信息"
echo ""
echo "示例:"
echo " ./run-e2e-tests.sh -e ci -r # CI环境运行所有测试并生成报告"
echo " ./run-e2e-tests.sh -p admin -t @boundary # 只运行admin的边界测试"
echo " ./run-e2e-tests.sh -p uniapp -h # 无头模式运行uniapp测试"
}
# 解析参数
while [[ $# -gt 0 ]]; do
case $1 in
-e|--env)
ENV="$2"
shift 2
;;
-p|--project)
PROJECT="$2"
shift 2
;;
-t|--tag)
TAG="$2"
shift 2
;;
-r|--report)
REPORT=true
shift
;;
-h|--headless)
HEADLESS=true
shift
;;
-d|--debug)
DEBUG=true
shift
;;
--help)
show_help
exit 0
;;
*)
echo -e "${RED}错误: 未知选项 $1${NC}"
show_help
exit 1
;;
esac
done
# 设置环境变量
export E2E_ENV="$ENV"
if [ "$HEADLESS" = true ]; then
export HEADLESS="true"
fi
if [ "$DEBUG" = true ]; then
export DEBUG="pw:api"
fi
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} E2E端到端测试运行器${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
echo -e "环境: ${GREEN}$ENV${NC}"
echo -e "项目: ${GREEN}${PROJECT:-全部}${NC}"
echo -e "标签: ${GREEN}${TAG:-}${NC}"
echo -e "报告: ${GREEN}$REPORT${NC}"
echo -e "无头: ${GREEN}$HEADLESS${NC}"
echo ""
# 构建Playwright命令
CMD="npx playwright test"
# 添加项目过滤
if [ -n "$PROJECT" ]; then
CMD="$CMD --project=$PROJECT"
fi
# 添加标签过滤
if [ -n "$TAG" ]; then
CMD="$CMD --grep='$TAG'"
fi
# 添加报告器
if [ "$REPORT" = true ]; then
CMD="$CMD --reporter=html,json,junit,list"
fi
# 添加调试选项
if [ "$DEBUG" = true ]; then
CMD="$CMD --debug"
fi
# 显示执行的命令
echo -e "${YELLOW}执行命令: $CMD${NC}"
echo ""
# 运行测试
eval $CMD
# 生成报告
if [ "$REPORT" = true ]; then
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} 生成测试报告${NC}"
echo -e "${BLUE}========================================${NC}"
# 显示HTML报告路径
if [ -f "test-results/html-report/index.html" ]; then
echo -e "${GREEN}HTML报告: test-results/html-report/index.html${NC}"
# 尝试自动打开报告(macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
open test-results/html-report/index.html
fi
fi
if [ -f "test-results/e2e-results.json" ]; then
echo -e "${GREEN}JSON报告: test-results/e2e-results.json${NC}"
fi
if [ -f "test-results/junit-report.xml" ]; then
echo -e "${GREEN}JUnit报告: test-results/junit-report.xml${NC}"
fi
fi
echo ""
echo -e "${GREEN}测试完成!${NC}"