#!/bin/bash

echo "=========================================="
echo "Filament 登录页面样式问题 - 快速验证"
echo "=========================================="
echo ""

# 检查 Filament 资产
echo "1. 检查 Filament 静态资产..."
if [ -f "public/css/filament/filament/app.css" ]; then
    SIZE=$(stat -f%z "public/css/filament/filament/app.css" 2>/dev/null || stat -c%s "public/css/filament/filament/app.css" 2>/dev/null)
    echo "   ✅ app.css 存在 (${SIZE} 字节)"
else
    echo "   ❌ app.css 不存在"
fi

if [ -f "public/js/filament/filament/app.js" ]; then
    SIZE=$(stat -f%z "public/js/filament/filament/app.js" 2>/dev/null || stat -c%s "public/js/filament/filament/app.js" 2>/dev/null)
    echo "   ✅ app.js 存在 (${SIZE} 字节)"
else
    echo "   ❌ app.js 不存在"
fi

echo ""

# 检查路由
echo "2. 检查 Filament 路由..."
php artisan route:list --path=admin/login --columns=Method,URI,Name 2>/dev/null | grep -E "GET|admin/login" | head -3

echo ""

# 检查配置
echo "3. 检查配置..."
if grep -q "renderHook.*vite" app/Providers/Filament/AdminPanelProvider.php; then
    echo "   ⚠️  发现 Vite 钩子，可能导致冲突"
else
    echo "   ✅ 无 Vite 钩子冲突"
fi

echo ""

# 检查用户
echo "4. 检查用户..."
USER_COUNT=$(php artisan tinker --execute="echo User::count();" 2>/dev/null | tail -1)
echo "   用户数量: ${USER_COUNT}"

echo ""

# 生成访问信息
echo "=========================================="
echo "访问信息"
echo "=========================================="
echo "登录页面: http://fa.test/admin/login"
echo "管理后台: http://fa.test/admin"
echo "学生仪表板: http://fa.test/admin/student-dashboard"
echo ""
echo "=========================================="
echo "如果样式仍未加载，请："
echo "1. 按 Ctrl+Shift+R 强制刷新"
echo "2. 清除浏览器缓存"
echo "3. 或使用无痕模式访问"
echo "=========================================="
