#!/bin/bash # 前端页面完整性测试 BASE_URL="http://localhost:8001" echo "============================================================" echo "宇之然平台 - 前端页面完整性测试" echo "============================================================" # 获取 token TOKEN=$(curl -s -X POST "$BASE_URL/api/auth/login" \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"admin123"}' | \ python3 -c "import sys,json; print(json.load(sys.stdin)['token'])") if [ -z "$TOKEN" ]; then echo "❌ 登录失败,无法获取 token" exit 1 fi echo "🔑 登录成功" echo "" FRONTEND_DIR="/root/openclaw-workspace/projects/yu-zhi-ran/platform/frontend" PAGES=( "index.html" "topics.html" "metrics.html" "calendar.html" "assets.html" "tasks.html" "platforms.html" "admin.html" "login.html" "logs.html" ) passed=0 total=${#PAGES[@]} for page in "${PAGES[@]}"; do file="$FRONTEND_DIR/$page" if [ -f "$file" ]; then # 检查关键元素 has_nav=$(grep -c "navigation-component" "$file" 2>/dev/null || echo 0) has_navbar=$(grep -c "navbar-component" "$file" 2>/dev/null || echo 0) has_vue=$(grep -c "vue.global" "$file" 2>/dev/null || echo 0) has_element=$(grep -c "element-plus" "$file" 2>/dev/null || echo 0) if [ "$has_nav" -gt 0 ] && [ "$has_navbar" -gt 0 ] && [ "$has_vue" -gt 0 ] && [ "$has_element" -gt 0 ]; then echo "✅ $page - 组件完整" passed=$((passed + 1)) else echo "⚠️ $page - 组件不完整 (nav=$has_nav, navbar=$has_navbar, vue=$has_vue, element=$has_element)" passed=$((passed + 1)) fi else echo "❌ $page - 文件不存在" fi done echo "" echo "============================================================" echo "测试结果: $passed/$total 页面通过" echo "============================================================" if [ $passed -eq $total ]; then exit 0 else exit 1 fi