#!/bin/bash

# 知识库系统 - 安装验证脚本

echo "=========================================="
echo "知识库系统 - 安装验证"
echo "=========================================="
echo ""

# 检查 PHP 版本
echo "1. 检查 PHP 版本..."
php -v | head -n 1
echo ""

# 检查 Composer
echo "2. 检查 Composer..."
composer --version
echo ""

# 检查 Laravel
echo "3. 检查 Laravel 版本..."
php artisan --version
echo ""

# 检查数据库
echo "4. 检查数据库文件..."
if [ -f "database/database.sqlite" ]; then
    echo "✓ 数据库文件存在"
    ls -lh database/database.sqlite
else
    echo "✗ 数据库文件不存在"
fi
echo ""

# 检查语言文件
echo "5. 检查中文语言文件..."
if [ -d "lang/zh_CN" ]; then
    echo "✓ Laravel 中文语言包已安装"
    ls lang/zh_CN/
else
    echo "✗ Laravel 中文语言包未安装"
fi
echo ""

if [ -d "lang/vendor/filament/zh_CN" ]; then
    echo "✓ Filament 中文翻译已安装"
else
    echo "✗ Filament 中文翻译未安装"
fi
echo ""

# 检查 Filament
echo "6. 检查 Filament 配置..."
if [ -f "app/Providers/Filament/AdminPanelProvider.php" ]; then
    echo "✓ Filament 面板配置文件存在"
else
    echo "✗ Filament 面板配置文件不存在"
fi
echo ""

# 检查环境配置
echo "7. 检查环境配置..."
if grep -q "APP_LOCALE=zh_CN" .env; then
    echo "✓ 应用语言已设置为简体中文"
else
    echo "✗ 应用语言未设置为简体中文"
fi
echo ""

# 运行测试
echo "8. 运行配置测试..."
php artisan test --filter=SetupTest
echo ""

echo "=========================================="
echo "验证完成！"
echo "=========================================="
echo ""
echo "启动开发服务器："
echo "  php artisan serve"
echo ""
echo "访问管理面板："
echo "  http://localhost:8000/admin/login"
echo ""
