Ver Fonte

增加Admin模块,用于扩展后台基础功能

新增功能:
- 仪表板功能:系统概览、性能监控、快捷操作、系统状态展示
- 缓存管理:状态查看、清理操作、统计信息、预热功能
- 日志管理:操作记录、查看筛选、导出清理功能
- 系统信息:服务器信息、PHP环境、数据库状态、性能指标
- 通用组件:表格辅助、表单辅助、小部件组件
- 系统维护:维护操作、备份管理、性能优化

技术特点:
- 完整的模块化架构设计
- 事件驱动的操作日志记录
- 枚举类型定义操作类型和缓存类型
- 通用的后台管理组件库
- 系统性能监控和警报机制
- 数据库表设计完整,支持日志、设置、指标、备份、通知

文件结构:
- 33个文件,包含控制器、服务、模型、枚举、事件、监听器等
- 5个数据库表的SQL创建脚本
- 完整的配置文件和文档
- 更新模块目录文档,新增Admin模块说明
notfff há 7 meses atrás
pai
commit
fae32adfb3

+ 354 - 0
app/Module/Admin/AdminControllers/CacheController.php

@@ -0,0 +1,354 @@
+<?php
+
+namespace App\Module\Admin\AdminControllers;
+
+use App\Module\Admin\Enums\ADMIN_ACTION_TYPE;
+use App\Module\Admin\Enums\CACHE_TYPE;
+use App\Module\Admin\Services\AdminService;
+use App\Module\Admin\Services\CacheService;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Widgets\Card;
+use Dcat\Admin\Widgets\Tab;
+use Illuminate\Http\Request;
+use Spatie\RouteAttributes\Attributes\Get;
+use Spatie\RouteAttributes\Attributes\Post;
+use Spatie\RouteAttributes\Attributes\Resource;
+use UCore\DcatAdmin\AdminController;
+
+/**
+ * 缓存管理控制器
+ */
+#[Resource('admin-cache', names: 'admin.cache')]
+class CacheController extends AdminController
+{
+    protected $title = '缓存管理';
+
+    /**
+     * @var CacheService
+     */
+    protected CacheService $cacheService;
+
+    /**
+     * @var AdminService
+     */
+    protected AdminService $adminService;
+
+    public function __construct()
+    {
+        $this->cacheService = app('admin.cache');
+        $this->adminService = app('admin.service');
+    }
+
+    /**
+     * 缓存管理首页
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content): Content
+    {
+        return $content
+            ->title($this->title)
+            ->description('缓存状态管理')
+            ->body($this->buildCacheManagement());
+    }
+
+    /**
+     * 构建缓存管理界面
+     *
+     * @return Tab
+     */
+    protected function buildCacheManagement(): Tab
+    {
+        $tab = new Tab();
+        
+        // 缓存状态标签页
+        $tab->add('缓存状态', $this->buildCacheStatusCard());
+        
+        // 缓存操作标签页
+        $tab->add('缓存操作', $this->buildCacheActionsCard());
+        
+        // 缓存统计标签页
+        $tab->add('缓存统计', $this->buildCacheStatisticsCard());
+        
+        return $tab;
+    }
+
+    /**
+     * 构建缓存状态卡片
+     *
+     * @return Card
+     */
+    protected function buildCacheStatusCard(): Card
+    {
+        $status = $this->cacheService->getStatus();
+        
+        $html = '<div class="row">';
+        
+        foreach ($status as $typeStatus) {
+            $statusClass = $typeStatus['status'] === 'healthy' ? 'success' : 'danger';
+            $statusText = $typeStatus['status'] === 'healthy' ? '正常' : '异常';
+            
+            $html .= '<div class="col-md-4 mb-3">';
+            $html .= '<div class="card">';
+            $html .= '<div class="card-body">';
+            $html .= "<h5 class=\"card-title\">{$typeStatus['label']}</h5>";
+            $html .= "<span class=\"badge badge-{$statusClass}\">{$statusText}</span>";
+            $html .= "<p class=\"card-text mt-2\">{$typeStatus['description']}</p>";
+            
+            if (isset($typeStatus['ttl'])) {
+                $html .= "<small class=\"text-muted\">TTL: {$typeStatus['ttl']}秒</small><br>";
+            }
+            
+            if (isset($typeStatus['tags'])) {
+                $tags = implode(', ', $typeStatus['tags']);
+                $html .= "<small class=\"text-muted\">标签: {$tags}</small>";
+            }
+            
+            if (isset($typeStatus['error'])) {
+                $html .= "<div class=\"text-danger mt-2\">{$typeStatus['error']}</div>";
+            }
+            
+            $html .= '</div>';
+            $html .= '</div>';
+            $html .= '</div>';
+        }
+        
+        $html .= '</div>';
+        
+        return new Card('缓存状态', $html);
+    }
+
+    /**
+     * 构建缓存操作卡片
+     *
+     * @return Card
+     */
+    protected function buildCacheActionsCard(): Card
+    {
+        $html = '<div class="row">';
+        
+        // 全部清理按钮
+        $html .= '<div class="col-md-12 mb-3">';
+        $html .= '<button type="button" class="btn btn-danger" onclick="clearAllCache()">';
+        $html .= '<i class="fa fa-trash"></i> 清理所有缓存';
+        $html .= '</button>';
+        $html .= '</div>';
+        
+        // 按类型清理
+        $html .= '<div class="col-md-12">';
+        $html .= '<h5>按类型清理</h5>';
+        $html .= '<div class="row">';
+        
+        foreach (CACHE_TYPE::cases() as $type) {
+            $buttonClass = $type->isSafeToClear() ? 'btn-warning' : 'btn-danger';
+            $safeText = $type->isSafeToClear() ? '(安全)' : '(谨慎)';
+            
+            $html .= '<div class="col-md-3 mb-2">';
+            $html .= "<button type=\"button\" class=\"btn {$buttonClass} btn-sm\" onclick=\"clearCacheByType('{$type->value}')\">";
+            $html .= "<i class=\"fa fa-broom\"></i> {$type->getLabel()} {$safeText}";
+            $html .= '</button>';
+            $html .= '</div>';
+        }
+        
+        $html .= '</div>';
+        $html .= '</div>';
+        
+        // 预热缓存
+        $html .= '<div class="col-md-12 mt-3">';
+        $html .= '<h5>缓存预热</h5>';
+        $html .= '<button type="button" class="btn btn-primary" onclick="warmupCache()">';
+        $html .= '<i class="fa fa-fire"></i> 预热缓存';
+        $html .= '</button>';
+        $html .= '</div>';
+        
+        $html .= '</div>';
+        
+        // 添加JavaScript
+        $html .= $this->getCacheManagementScript();
+        
+        return new Card('缓存操作', $html);
+    }
+
+    /**
+     * 构建缓存统计卡片
+     *
+     * @return Card
+     */
+    protected function buildCacheStatisticsCard(): Card
+    {
+        $statistics = $this->cacheService->getStatistics();
+        
+        $html = '<div class="row">';
+        $html .= '<div class="col-md-6">';
+        $html .= '<table class="table table-bordered">';
+        $html .= '<tr><th>缓存驱动</th><td>' . ($statistics['driver'] ?? 'Unknown') . '</td></tr>';
+        $html .= '<tr><th>缓存类型总数</th><td>' . ($statistics['total_types'] ?? 0) . '</td></tr>';
+        $html .= '<tr><th>关键缓存类型</th><td>' . ($statistics['critical_types'] ?? 0) . '</td></tr>';
+        $html .= '<tr><th>安全清理类型</th><td>' . ($statistics['safe_to_clear'] ?? 0) . '</td></tr>';
+        $html .= '</table>';
+        $html .= '</div>';
+        $html .= '</div>';
+        
+        return new Card('缓存统计', $html);
+    }
+
+    /**
+     * 获取缓存管理JavaScript
+     *
+     * @return string
+     */
+    protected function getCacheManagementScript(): string
+    {
+        return '
+        <script>
+        function clearAllCache() {
+            if (confirm("确定要清理所有缓存吗?这可能会影响系统性能。")) {
+                $.post("/admin/admin-cache/clear-all", {
+                    _token: $("meta[name=csrf-token]").attr("content")
+                }).done(function(data) {
+                    if (data.status === "success") {
+                        Dcat.success(data.message);
+                        location.reload();
+                    } else {
+                        Dcat.error(data.message);
+                    }
+                }).fail(function() {
+                    Dcat.error("操作失败");
+                });
+            }
+        }
+        
+        function clearCacheByType(type) {
+            if (confirm("确定要清理 " + type + " 缓存吗?")) {
+                $.post("/admin/admin-cache/clear-type", {
+                    type: type,
+                    _token: $("meta[name=csrf-token]").attr("content")
+                }).done(function(data) {
+                    if (data.status === "success") {
+                        Dcat.success(data.message);
+                        location.reload();
+                    } else {
+                        Dcat.error(data.message);
+                    }
+                }).fail(function() {
+                    Dcat.error("操作失败");
+                });
+            }
+        }
+        
+        function warmupCache() {
+            if (confirm("确定要预热缓存吗?")) {
+                $.post("/admin/admin-cache/warmup", {
+                    _token: $("meta[name=csrf-token]").attr("content")
+                }).done(function(data) {
+                    if (data.status === "success") {
+                        Dcat.success(data.message);
+                        location.reload();
+                    } else {
+                        Dcat.error(data.message);
+                    }
+                }).fail(function() {
+                    Dcat.error("操作失败");
+                });
+            }
+        }
+        </script>';
+    }
+
+    /**
+     * 清理所有缓存
+     *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    #[Post('admin-cache/clear-all')]
+    public function clearAll()
+    {
+        try {
+            $results = $this->cacheService->clearAll();
+            
+            // 记录操作日志
+            $this->adminService->logAdminAction(
+                ADMIN_ACTION_TYPE::CACHE_CLEAR,
+                '清理所有缓存',
+                ['results' => $results]
+            );
+            
+            return response()->json([
+                'status' => 'success',
+                'message' => '所有缓存清理完成',
+                'data' => $results,
+            ]);
+        } catch (\Exception $e) {
+            return response()->json([
+                'status' => 'error',
+                'message' => $e->getMessage(),
+            ], 500);
+        }
+    }
+
+    /**
+     * 按类型清理缓存
+     *
+     * @param Request $request
+     * @return \Illuminate\Http\JsonResponse
+     */
+    #[Post('admin-cache/clear-type')]
+    public function clearByType(Request $request)
+    {
+        try {
+            $type = CACHE_TYPE::from($request->input('type'));
+            $result = $this->cacheService->clearByType($type);
+            
+            // 记录操作日志
+            $this->adminService->logAdminAction(
+                ADMIN_ACTION_TYPE::CACHE_CLEAR,
+                "清理{$type->getLabel()}缓存",
+                ['type' => $type->value, 'result' => $result]
+            );
+            
+            return response()->json([
+                'status' => 'success',
+                'message' => $result['message'],
+                'data' => $result,
+            ]);
+        } catch (\Exception $e) {
+            return response()->json([
+                'status' => 'error',
+                'message' => $e->getMessage(),
+            ], 500);
+        }
+    }
+
+    /**
+     * 预热缓存
+     *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    #[Post('admin-cache/warmup')]
+    public function warmup()
+    {
+        try {
+            $results = $this->cacheService->warmup();
+            
+            // 记录操作日志
+            $this->adminService->logAdminAction(
+                ADMIN_ACTION_TYPE::CACHE_CLEAR,
+                '预热缓存',
+                ['results' => $results]
+            );
+            
+            return response()->json([
+                'status' => 'success',
+                'message' => '缓存预热完成',
+                'data' => $results,
+            ]);
+        } catch (\Exception $e) {
+            return response()->json([
+                'status' => 'error',
+                'message' => $e->getMessage(),
+            ], 500);
+        }
+    }
+}

+ 205 - 0
app/Module/Admin/AdminControllers/DashboardController.php

@@ -0,0 +1,205 @@
+<?php
+
+namespace App\Module\Admin\AdminControllers;
+
+use App\Module\Admin\Services\AdminService;
+use App\Module\Admin\AdminWidgets\SystemStatusWidget;
+use App\Module\Admin\AdminWidgets\QuickActionsWidget;
+use App\Module\Admin\AdminWidgets\StatisticsWidget;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Layout\Row;
+use Spatie\RouteAttributes\Attributes\Get;
+use UCore\DcatAdmin\AdminController;
+
+/**
+ * 仪表板控制器
+ */
+class DashboardController extends AdminController
+{
+    protected $title = '仪表板';
+
+    /**
+     * @var AdminService
+     */
+    protected AdminService $adminService;
+
+    public function __construct()
+    {
+        $this->adminService = app('admin.service');
+    }
+
+    /**
+     * 仪表板首页
+     *
+     * @param Content $content
+     * @return Content
+     */
+    #[Get('admin/dashboard')]
+    public function index(Content $content): Content
+    {
+        return $content
+            ->title($this->title)
+            ->description('系统概览')
+            ->body($this->buildDashboard());
+    }
+
+    /**
+     * 构建仪表板内容
+     *
+     * @return Row
+     */
+    protected function buildDashboard(): Row
+    {
+        $dashboardData = $this->adminService->getDashboardData();
+        
+        return new Row(function (Row $row) use ($dashboardData) {
+            // 第一行:统计卡片
+            $row->column(12, function ($column) use ($dashboardData) {
+                $column->append(new StatisticsWidget($dashboardData['statistics']));
+            });
+            
+            // 第二行:系统状态和快捷操作
+            $row->column(8, function ($column) use ($dashboardData) {
+                $column->append(new SystemStatusWidget($dashboardData['system']));
+            });
+            
+            $row->column(4, function ($column) use ($dashboardData) {
+                $column->append(new QuickActionsWidget());
+            });
+            
+            // 第三行:系统警报(如果有)
+            if (!empty($dashboardData['alerts'])) {
+                $row->column(12, function ($column) use ($dashboardData) {
+                    $column->append($this->buildAlertsWidget($dashboardData['alerts']));
+                });
+            }
+            
+            // 第四行:最近操作
+            if (!empty($dashboardData['recent_actions'])) {
+                $row->column(12, function ($column) use ($dashboardData) {
+                    $column->append($this->buildRecentActionsWidget($dashboardData['recent_actions']));
+                });
+            }
+        });
+    }
+
+    /**
+     * 构建警报小部件
+     *
+     * @param array $alerts
+     * @return string
+     */
+    protected function buildAlertsWidget(array $alerts): string
+    {
+        $html = '<div class="card">';
+        $html .= '<div class="card-header"><h4 class="card-title">系统警报</h4></div>';
+        $html .= '<div class="card-body">';
+        
+        foreach ($alerts as $alert) {
+            $type = $alert['type'];
+            $title = $alert['title'];
+            $message = $alert['message'];
+            $timestamp = $alert['timestamp']->format('Y-m-d H:i:s');
+            
+            $html .= "<div class=\"alert alert-{$type}\">";
+            $html .= "<strong>{$title}</strong><br>";
+            $html .= "{$message}<br>";
+            $html .= "<small class=\"text-muted\">{$timestamp}</small>";
+            $html .= "</div>";
+        }
+        
+        $html .= '</div></div>';
+        
+        return $html;
+    }
+
+    /**
+     * 构建最近操作小部件
+     *
+     * @param array $actions
+     * @return string
+     */
+    protected function buildRecentActionsWidget(array $actions): string
+    {
+        $html = '<div class="card">';
+        $html .= '<div class="card-header"><h4 class="card-title">最近操作</h4></div>';
+        $html .= '<div class="card-body">';
+        $html .= '<div class="table-responsive">';
+        $html .= '<table class="table table-sm">';
+        $html .= '<thead>';
+        $html .= '<tr>';
+        $html .= '<th>操作</th>';
+        $html .= '<th>管理员</th>';
+        $html .= '<th>时间</th>';
+        $html .= '<th>IP地址</th>';
+        $html .= '</tr>';
+        $html .= '</thead>';
+        $html .= '<tbody>';
+        
+        foreach ($actions as $action) {
+            $html .= '<tr>';
+            $html .= "<td>{$action['description']}</td>";
+            $html .= "<td>{$action['admin_name']}</td>";
+            $html .= "<td>{$action['timestamp']}</td>";
+            $html .= "<td>{$action['ip_address']}</td>";
+            $html .= '</tr>';
+        }
+        
+        $html .= '</tbody>';
+        $html .= '</table>';
+        $html .= '</div>';
+        $html .= '</div></div>';
+        
+        return $html;
+    }
+
+    /**
+     * 获取系统状态API
+     *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    #[Get('admin/api/system-status')]
+    public function getSystemStatus()
+    {
+        try {
+            $status = $this->adminService->getSystemStatus();
+            return response()->json([
+                'status' => 'success',
+                'data' => $status,
+            ]);
+        } catch (\Exception $e) {
+            return response()->json([
+                'status' => 'error',
+                'message' => $e->getMessage(),
+            ], 500);
+        }
+    }
+
+    /**
+     * 刷新仪表板数据API
+     *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    #[Get('admin/api/dashboard/refresh')]
+    public function refreshDashboard()
+    {
+        try {
+            // 清理仪表板缓存
+            cache()->forget('admin.dashboard.data');
+            
+            // 获取新数据
+            $data = $this->adminService->getDashboardData();
+            
+            return response()->json([
+                'status' => 'success',
+                'message' => '仪表板数据已刷新',
+                'data' => $data,
+            ]);
+        } catch (\Exception $e) {
+            return response()->json([
+                'status' => 'error',
+                'message' => $e->getMessage(),
+            ], 500);
+        }
+    }
+}

+ 321 - 0
app/Module/Admin/AdminControllers/Helper/GridHelper.php

@@ -0,0 +1,321 @@
+<?php
+
+namespace App\Module\Admin\AdminControllers\Helper;
+
+use Dcat\Admin\Grid;
+use UCore\DcatAdmin\AdminController;
+
+/**
+ * 表格辅助类
+ * 提供通用的表格列配置方法
+ */
+class GridHelper
+{
+    /**
+     * @var Grid
+     */
+    protected Grid $grid;
+
+    /**
+     * @var AdminController
+     */
+    protected AdminController $controller;
+
+    public function __construct(Grid $grid, AdminController $controller)
+    {
+        $this->grid = $grid;
+        $this->controller = $controller;
+    }
+
+    /**
+     * 添加ID列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnId(string $field = 'id', string $label = 'ID'): Grid\Column
+    {
+        return $this->grid->column($field, $label)->sortable();
+    }
+
+    /**
+     * 添加创建时间列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnCreatedAt(string $field = 'created_at', string $label = '创建时间'): Grid\Column
+    {
+        return $this->grid->column($field, $label)->sortable();
+    }
+
+    /**
+     * 添加更新时间列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnUpdatedAt(string $field = 'updated_at', string $label = '更新时间'): Grid\Column
+    {
+        return $this->grid->column($field, $label)->sortable();
+    }
+
+    /**
+     * 添加状态列
+     *
+     * @param string $field
+     * @param string $label
+     * @param array $options
+     * @return Grid\Column
+     */
+    public function columnStatus(string $field = 'status', string $label = '状态', array $options = []): Grid\Column
+    {
+        $defaultOptions = [
+            0 => '禁用',
+            1 => '启用',
+        ];
+        
+        $options = array_merge($defaultOptions, $options);
+        
+        return $this->grid->column($field, $label)
+            ->using($options)
+            ->dot([
+                0 => 'danger',
+                1 => 'success',
+            ], 'warning');
+    }
+
+    /**
+     * 添加操作列
+     *
+     * @param string $label
+     * @param callable|null $callback
+     * @return Grid\Column
+     */
+    public function columnActions(string $label = '操作', ?callable $callback = null): Grid\Column
+    {
+        $column = $this->grid->column('actions', $label);
+        
+        if ($callback) {
+            $column->display($callback);
+        }
+        
+        return $column;
+    }
+
+    /**
+     * 添加图片列
+     *
+     * @param string $field
+     * @param string $label
+     * @param int $width
+     * @param int $height
+     * @return Grid\Column
+     */
+    public function columnImage(string $field, string $label, int $width = 50, int $height = 50): Grid\Column
+    {
+        return $this->grid->column($field, $label)->image('', $width, $height);
+    }
+
+    /**
+     * 添加链接列
+     *
+     * @param string $field
+     * @param string $label
+     * @param string $target
+     * @return Grid\Column
+     */
+    public function columnLink(string $field, string $label, string $target = '_blank'): Grid\Column
+    {
+        return $this->grid->column($field, $label)->link($target);
+    }
+
+    /**
+     * 添加标签列
+     *
+     * @param string $field
+     * @param string $label
+     * @param array $colors
+     * @return Grid\Column
+     */
+    public function columnLabel(string $field, string $label, array $colors = []): Grid\Column
+    {
+        $column = $this->grid->column($field, $label)->label();
+        
+        if (!empty($colors)) {
+            $column->using($colors);
+        }
+        
+        return $column;
+    }
+
+    /**
+     * 添加进度条列
+     *
+     * @param string $field
+     * @param string $label
+     * @param string $style
+     * @param int $max
+     * @return Grid\Column
+     */
+    public function columnProgressBar(string $field, string $label, string $style = 'primary', int $max = 100): Grid\Column
+    {
+        return $this->grid->column($field, $label)->progressBar($style, 'sm', $max);
+    }
+
+    /**
+     * 添加开关列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnSwitch(string $field, string $label): Grid\Column
+    {
+        return $this->grid->column($field, $label)->switch();
+    }
+
+    /**
+     * 添加复选框列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnCheckbox(string $field = 'id', string $label = ''): Grid\Column
+    {
+        return $this->grid->column($field, $label)->checkbox();
+    }
+
+    /**
+     * 添加排序列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnSort(string $field = 'sort', string $label = '排序'): Grid\Column
+    {
+        return $this->grid->column($field, $label)->sortable()->editable();
+    }
+
+    /**
+     * 添加金额列
+     *
+     * @param string $field
+     * @param string $label
+     * @param string $currency
+     * @param int $decimals
+     * @return Grid\Column
+     */
+    public function columnMoney(string $field, string $label, string $currency = '¥', int $decimals = 2): Grid\Column
+    {
+        return $this->grid->column($field, $label)->display(function ($value) use ($currency, $decimals) {
+            return $currency . number_format($value, $decimals);
+        });
+    }
+
+    /**
+     * 添加百分比列
+     *
+     * @param string $field
+     * @param string $label
+     * @param int $decimals
+     * @return Grid\Column
+     */
+    public function columnPercentage(string $field, string $label, int $decimals = 2): Grid\Column
+    {
+        return $this->grid->column($field, $label)->display(function ($value) use ($decimals) {
+            return number_format($value, $decimals) . '%';
+        });
+    }
+
+    /**
+     * 添加文件大小列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnFileSize(string $field, string $label): Grid\Column
+    {
+        return $this->grid->column($field, $label)->display(function ($value) {
+            return $this->formatBytes($value);
+        });
+    }
+
+    /**
+     * 格式化字节数
+     *
+     * @param int $bytes
+     * @return string
+     */
+    protected function formatBytes(int $bytes): string
+    {
+        if ($bytes === 0) {
+            return '0 B';
+        }
+        
+        $units = ['B', 'KB', 'MB', 'GB', 'TB'];
+        $power = floor(log($bytes, 1024));
+        
+        return round($bytes / pow(1024, $power), 2) . ' ' . $units[$power];
+    }
+
+    /**
+     * 添加JSON列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnJson(string $field, string $label): Grid\Column
+    {
+        return $this->grid->column($field, $label)->display(function ($value) {
+            if (is_array($value)) {
+                return '<pre>' . json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . '</pre>';
+            }
+            return $value;
+        });
+    }
+
+    /**
+     * 添加截断文本列
+     *
+     * @param string $field
+     * @param string $label
+     * @param int $limit
+     * @return Grid\Column
+     */
+    public function columnLimit(string $field, string $label, int $limit = 50): Grid\Column
+    {
+        return $this->grid->column($field, $label)->limit($limit);
+    }
+
+    /**
+     * 添加复制按钮列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnCopyable(string $field, string $label): Grid\Column
+    {
+        return $this->grid->column($field, $label)->copyable();
+    }
+
+    /**
+     * 添加二维码列
+     *
+     * @param string $field
+     * @param string $label
+     * @return Grid\Column
+     */
+    public function columnQrcode(string $field, string $label): Grid\Column
+    {
+        return $this->grid->column($field, $label)->qrcode();
+    }
+}

+ 159 - 0
app/Module/Admin/AdminWidgets/QuickActionsWidget.php

@@ -0,0 +1,159 @@
+<?php
+
+namespace App\Module\Admin\AdminWidgets;
+
+use Dcat\Admin\Widgets\Card;
+
+/**
+ * 快捷操作小部件
+ */
+class QuickActionsWidget extends Card
+{
+    public function __construct()
+    {
+        parent::__construct('快捷操作', $this->buildContent());
+    }
+
+    /**
+     * 构建内容
+     *
+     * @return string
+     */
+    protected function buildContent(): string
+    {
+        $actions = [
+            [
+                'title' => '清理缓存',
+                'icon' => 'fa-broom',
+                'color' => 'warning',
+                'url' => '/admin/admin-cache',
+                'description' => '清理系统缓存',
+            ],
+            [
+                'title' => '系统信息',
+                'icon' => 'fa-info-circle',
+                'color' => 'info',
+                'url' => '/admin/system-info',
+                'description' => '查看系统详细信息',
+            ],
+            [
+                'title' => '日志管理',
+                'icon' => 'fa-file-alt',
+                'color' => 'primary',
+                'url' => '/admin/logs',
+                'description' => '查看和管理系统日志',
+            ],
+            [
+                'title' => '系统维护',
+                'icon' => 'fa-tools',
+                'color' => 'danger',
+                'url' => '#',
+                'description' => '执行系统维护操作',
+                'onclick' => 'performMaintenance()',
+            ],
+            [
+                'title' => '备份系统',
+                'icon' => 'fa-archive',
+                'color' => 'success',
+                'url' => '#',
+                'description' => '创建系统备份',
+                'onclick' => 'createBackup()',
+            ],
+            [
+                'title' => '性能监控',
+                'icon' => 'fa-chart-line',
+                'color' => 'secondary',
+                'url' => '/admin/performance',
+                'description' => '查看性能监控数据',
+            ],
+        ];
+
+        $html = '<div class="list-group list-group-flush">';
+        
+        foreach ($actions as $action) {
+            $onclick = isset($action['onclick']) ? "onclick=\"{$action['onclick']}\"" : '';
+            $href = isset($action['onclick']) ? 'javascript:void(0)' : $action['url'];
+            
+            $html .= '<a href="' . $href . '" class="list-group-item list-group-item-action" ' . $onclick . '>';
+            $html .= '<div class="d-flex w-100 justify-content-between align-items-center">';
+            $html .= '<div>';
+            $html .= "<i class=\"fa {$action['icon']} text-{$action['color']} mr-2\"></i>";
+            $html .= "<strong>{$action['title']}</strong>";
+            $html .= "<br><small class=\"text-muted\">{$action['description']}</small>";
+            $html .= '</div>';
+            $html .= '<i class="fa fa-chevron-right text-muted"></i>';
+            $html .= '</div>';
+            $html .= '</a>';
+        }
+        
+        $html .= '</div>';
+        
+        // 添加JavaScript函数
+        $html .= $this->getQuickActionsScript();
+        
+        return $html;
+    }
+
+    /**
+     * 获取快捷操作JavaScript
+     *
+     * @return string
+     */
+    protected function getQuickActionsScript(): string
+    {
+        return '
+        <script>
+        function performMaintenance() {
+            if (confirm("确定要执行系统维护吗?这可能需要几分钟时间。")) {
+                Dcat.loading();
+                
+                $.post("/admin/api/maintenance", {
+                    _token: $("meta[name=csrf-token]").attr("content"),
+                    clear_cache: true,
+                    clean_logs: false,
+                    optimize_database: false
+                }).done(function(data) {
+                    Dcat.loading(false);
+                    if (data.status === "success") {
+                        Dcat.success("系统维护完成");
+                        setTimeout(function() {
+                            location.reload();
+                        }, 2000);
+                    } else {
+                        Dcat.error(data.message || "维护失败");
+                    }
+                }).fail(function() {
+                    Dcat.loading(false);
+                    Dcat.error("维护操作失败");
+                });
+            }
+        }
+        
+        function createBackup() {
+            if (confirm("确定要创建系统备份吗?")) {
+                Dcat.loading();
+                
+                $.post("/admin/api/backup", {
+                    _token: $("meta[name=csrf-token]").attr("content"),
+                    include_database: true,
+                    include_files: false,
+                    include_config: true
+                }).done(function(data) {
+                    Dcat.loading(false);
+                    if (data.status === "success") {
+                        Dcat.success("备份创建成功");
+                        if (data.download_url) {
+                            window.open(data.download_url, "_blank");
+                        }
+                    } else {
+                        Dcat.error(data.message || "备份失败");
+                    }
+                }).fail(function() {
+                    Dcat.loading(false);
+                    Dcat.error("备份操作失败");
+                });
+            }
+        }
+        </script>';
+    }
+}

+ 136 - 0
app/Module/Admin/AdminWidgets/StatisticsWidget.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace App\Module\Admin\AdminWidgets;
+
+use Dcat\Admin\Widgets\Widget;
+
+/**
+ * 统计信息小部件
+ */
+class StatisticsWidget extends Widget
+{
+    /**
+     * @var array
+     */
+    protected array $statistics;
+
+    public function __construct(array $statistics)
+    {
+        $this->statistics = $statistics;
+    }
+
+    /**
+     * 渲染小部件
+     *
+     * @return string
+     */
+    public function render(): string
+    {
+        $stats = [
+            [
+                'title' => '在线用户',
+                'value' => $this->statistics['users_online'] ?? 0,
+                'icon' => 'fa-users',
+                'color' => 'primary',
+                'description' => '当前在线用户数量',
+            ],
+            [
+                'title' => '总请求数',
+                'value' => number_format($this->statistics['total_requests'] ?? 0),
+                'icon' => 'fa-chart-bar',
+                'color' => 'success',
+                'description' => '今日总请求数量',
+            ],
+            [
+                'title' => '错误率',
+                'value' => number_format($this->statistics['error_rate'] ?? 0, 2) . '%',
+                'icon' => 'fa-exclamation-triangle',
+                'color' => $this->getErrorRateColor($this->statistics['error_rate'] ?? 0),
+                'description' => '今日错误率',
+            ],
+            [
+                'title' => '响应时间',
+                'value' => number_format($this->statistics['response_time'] ?? 0, 0) . 'ms',
+                'icon' => 'fa-clock',
+                'color' => $this->getResponseTimeColor($this->statistics['response_time'] ?? 0),
+                'description' => '平均响应时间',
+            ],
+        ];
+
+        $html = '<div class="row">';
+        
+        foreach ($stats as $stat) {
+            $html .= $this->buildStatCard($stat);
+        }
+        
+        $html .= '</div>';
+        
+        return $html;
+    }
+
+    /**
+     * 构建统计卡片
+     *
+     * @param array $stat
+     * @return string
+     */
+    protected function buildStatCard(array $stat): string
+    {
+        $html = '<div class="col-lg-3 col-md-6 col-sm-6 col-12">';
+        $html .= '<div class="card card-statistic-1">';
+        $html .= '<div class="card-icon bg-' . $stat['color'] . '">';
+        $html .= '<i class="fa ' . $stat['icon'] . '"></i>';
+        $html .= '</div>';
+        $html .= '<div class="card-wrap">';
+        $html .= '<div class="card-header">';
+        $html .= '<h4>' . $stat['title'] . '</h4>';
+        $html .= '</div>';
+        $html .= '<div class="card-body">';
+        $html .= '<div class="d-flex justify-content-between align-items-center">';
+        $html .= '<div>';
+        $html .= '<h2 class="mb-0">' . $stat['value'] . '</h2>';
+        $html .= '<small class="text-muted">' . $stat['description'] . '</small>';
+        $html .= '</div>';
+        $html .= '</div>';
+        $html .= '</div>';
+        $html .= '</div>';
+        $html .= '</div>';
+        $html .= '</div>';
+        
+        return $html;
+    }
+
+    /**
+     * 根据错误率获取颜色
+     *
+     * @param float $errorRate
+     * @return string
+     */
+    protected function getErrorRateColor(float $errorRate): string
+    {
+        if ($errorRate < 1) {
+            return 'success';
+        } elseif ($errorRate < 5) {
+            return 'warning';
+        } else {
+            return 'danger';
+        }
+    }
+
+    /**
+     * 根据响应时间获取颜色
+     *
+     * @param float $responseTime
+     * @return string
+     */
+    protected function getResponseTimeColor(float $responseTime): string
+    {
+        if ($responseTime < 500) {
+            return 'success';
+        } elseif ($responseTime < 1000) {
+            return 'warning';
+        } else {
+            return 'danger';
+        }
+    }
+}

+ 176 - 0
app/Module/Admin/AdminWidgets/SystemStatusWidget.php

@@ -0,0 +1,176 @@
+<?php
+
+namespace App\Module\Admin\AdminWidgets;
+
+use Dcat\Admin\Widgets\Card;
+
+/**
+ * 系统状态小部件
+ */
+class SystemStatusWidget extends Card
+{
+    /**
+     * @var array
+     */
+    protected array $systemData;
+
+    public function __construct(array $systemData)
+    {
+        $this->systemData = $systemData;
+        parent::__construct('系统状态', $this->buildContent());
+    }
+
+    /**
+     * 构建内容
+     *
+     * @return string
+     */
+    protected function buildContent(): string
+    {
+        $html = '<div class="row">';
+        
+        // 服务器信息
+        $html .= $this->buildServerInfo();
+        
+        // 性能指标
+        $html .= $this->buildPerformanceMetrics();
+        
+        $html .= '</div>';
+        
+        return $html;
+    }
+
+    /**
+     * 构建服务器信息
+     *
+     * @return string
+     */
+    protected function buildServerInfo(): string
+    {
+        $serverInfo = $this->systemData['server_info'] ?? [];
+        
+        $html = '<div class="col-md-6">';
+        $html .= '<h6>服务器信息</h6>';
+        $html .= '<table class="table table-sm table-borderless">';
+        
+        $items = [
+            '操作系统' => $serverInfo['os'] ?? 'Unknown',
+            '主机名' => $serverInfo['hostname'] ?? 'Unknown',
+            '架构' => $serverInfo['architecture'] ?? 'Unknown',
+            'Web服务器' => $serverInfo['server_software'] ?? 'Unknown',
+        ];
+        
+        foreach ($items as $label => $value) {
+            $html .= "<tr><td class=\"text-muted\">{$label}:</td><td>{$value}</td></tr>";
+        }
+        
+        $html .= '</table>';
+        $html .= '</div>';
+        
+        return $html;
+    }
+
+    /**
+     * 构建性能指标
+     *
+     * @return string
+     */
+    protected function buildPerformanceMetrics(): string
+    {
+        $performance = $this->systemData['performance'] ?? [];
+        
+        $html = '<div class="col-md-6">';
+        $html .= '<h6>性能指标</h6>';
+        
+        // 内存使用率
+        if (isset($performance['memory'])) {
+            $memory = $performance['memory'];
+            $percentage = $memory['percentage'];
+            $progressClass = $this->getProgressClass($percentage);
+            
+            $html .= '<div class="mb-2">';
+            $html .= '<small class="text-muted">内存使用率</small>';
+            $html .= "<div class=\"progress\" style=\"height: 8px;\">";
+            $html .= "<div class=\"progress-bar bg-{$progressClass}\" style=\"width: {$percentage}%\"></div>";
+            $html .= "</div>";
+            $html .= "<small>{$memory['current']} / {$memory['limit']} ({$percentage}%)</small>";
+            $html .= '</div>';
+        }
+        
+        // 磁盘使用率
+        if (isset($performance['disk'])) {
+            $disk = $performance['disk'];
+            $percentage = $disk['percentage'];
+            $progressClass = $this->getProgressClass($percentage);
+            
+            $html .= '<div class="mb-2">';
+            $html .= '<small class="text-muted">磁盘使用率</small>';
+            $html .= "<div class=\"progress\" style=\"height: 8px;\">";
+            $html .= "<div class=\"progress-bar bg-{$progressClass}\" style=\"width: {$percentage}%\"></div>";
+            $html .= "</div>";
+            $html .= "<small>{$disk['used']} / {$disk['total']} ({$percentage}%)</small>";
+            $html .= '</div>';
+        }
+        
+        // CPU使用率
+        if (isset($performance['cpu_usage'])) {
+            $cpuUsage = $performance['cpu_usage'];
+            $progressClass = $this->getProgressClass($cpuUsage);
+            
+            $html .= '<div class="mb-2">';
+            $html .= '<small class="text-muted">CPU使用率</small>';
+            $html .= "<div class=\"progress\" style=\"height: 8px;\">";
+            $html .= "<div class=\"progress-bar bg-{$progressClass}\" style=\"width: {$cpuUsage}%\"></div>";
+            $html .= "</div>";
+            $html .= "<small>{$cpuUsage}%</small>";
+            $html .= '</div>';
+        }
+        
+        // 负载平均值
+        if (isset($performance['load_average'])) {
+            $load = $performance['load_average'];
+            $html .= '<div class="mb-2">';
+            $html .= '<small class="text-muted">负载平均值</small><br>';
+            $html .= "<small>1分钟: {$load['1min']} | 5分钟: {$load['5min']} | 15分钟: {$load['15min']}</small>";
+            $html .= '</div>';
+        }
+        
+        // 数据库状态
+        if (isset($performance['database'])) {
+            $database = $performance['database'];
+            $statusClass = $database['status'] === 'healthy' ? 'success' : 'danger';
+            $statusText = $database['status'] === 'healthy' ? '正常' : '异常';
+            
+            $html .= '<div class="mb-2">';
+            $html .= '<small class="text-muted">数据库状态</small><br>';
+            $html .= "<span class=\"badge badge-{$statusClass}\">{$statusText}</span>";
+            
+            if (isset($database['response_time'])) {
+                $html .= " <small class=\"text-muted\">响应时间: {$database['response_time']}</small>";
+            }
+            
+            $html .= '</div>';
+        }
+        
+        $html .= '</div>';
+        
+        return $html;
+    }
+
+    /**
+     * 根据百分比获取进度条颜色类
+     *
+     * @param float $percentage
+     * @return string
+     */
+    protected function getProgressClass(float $percentage): string
+    {
+        if ($percentage < 50) {
+            return 'success';
+        } elseif ($percentage < 80) {
+            return 'warning';
+        } else {
+            return 'danger';
+        }
+    }
+}

+ 180 - 0
app/Module/Admin/Config/admin.php

@@ -0,0 +1,180 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | Admin模块配置
+    |--------------------------------------------------------------------------
+    |
+    | Admin模块的基础配置选项
+    |
+    */
+
+    // 模块基础配置
+    'module' => [
+        'name' => 'Admin',
+        'version' => '1.0.0',
+        'description' => '后台基础功能扩展模块',
+        'author' => 'System',
+    ],
+
+    // 仪表板配置
+    'dashboard' => [
+        'enabled' => true,
+        'refresh_interval' => 30, // 秒
+        'widgets' => [
+            'system_status' => true,
+            'quick_actions' => true,
+            'statistics' => true,
+            'performance' => true,
+        ],
+    ],
+
+    // 缓存配置
+    'cache' => [
+        'enabled' => true,
+        'default_ttl' => 3600, // 秒
+        'types' => [
+            'config' => [
+                'ttl' => 7200,
+                'tags' => ['admin', 'config'],
+            ],
+            'system' => [
+                'ttl' => 1800,
+                'tags' => ['admin', 'system'],
+            ],
+            'stats' => [
+                'ttl' => 300,
+                'tags' => ['admin', 'stats'],
+            ],
+        ],
+    ],
+
+    // 日志配置
+    'log' => [
+        'enabled' => true,
+        'retention_days' => 30,
+        'max_file_size' => '10M',
+        'channels' => [
+            'admin' => [
+                'driver' => 'daily',
+                'path' => storage_path('logs/admin.log'),
+                'level' => 'info',
+                'days' => 30,
+            ],
+            'action' => [
+                'driver' => 'daily',
+                'path' => storage_path('logs/admin-action.log'),
+                'level' => 'info',
+                'days' => 90,
+            ],
+        ],
+    ],
+
+    // 系统监控配置
+    'monitoring' => [
+        'enabled' => true,
+        'metrics' => [
+            'system' => [
+                'cpu_usage' => true,
+                'memory_usage' => true,
+                'disk_usage' => true,
+                'load_average' => true,
+            ],
+            'application' => [
+                'response_time' => true,
+                'error_rate' => true,
+                'request_count' => true,
+                'database_queries' => true,
+            ],
+        ],
+        'alerts' => [
+            'cpu_threshold' => 80, // 百分比
+            'memory_threshold' => 85, // 百分比
+            'disk_threshold' => 90, // 百分比
+            'response_time_threshold' => 2000, // 毫秒
+        ],
+    ],
+
+    // 安全配置
+    'security' => [
+        'session_timeout' => 7200, // 秒
+        'max_login_attempts' => 5,
+        'lockout_duration' => 900, // 秒
+        'password_requirements' => [
+            'min_length' => 8,
+            'require_uppercase' => true,
+            'require_lowercase' => true,
+            'require_numbers' => true,
+            'require_symbols' => false,
+        ],
+    ],
+
+    // UI配置
+    'ui' => [
+        'theme' => 'default',
+        'sidebar_collapsed' => false,
+        'show_breadcrumbs' => true,
+        'items_per_page' => 20,
+        'date_format' => 'Y-m-d H:i:s',
+        'timezone' => 'Asia/Shanghai',
+    ],
+
+    // 权限配置
+    'permissions' => [
+        'super_admin' => [
+            'admin.dashboard',
+            'admin.cache.manage',
+            'admin.log.view',
+            'admin.log.export',
+            'admin.system.info',
+            'admin.system.backup',
+        ],
+        'admin' => [
+            'admin.dashboard',
+            'admin.cache.view',
+            'admin.log.view',
+            'admin.system.info',
+        ],
+    ],
+
+    // 备份配置
+    'backup' => [
+        'enabled' => true,
+        'storage_disk' => 'local',
+        'storage_path' => 'backups',
+        'retention_days' => 7,
+        'include' => [
+            'database' => true,
+            'files' => false,
+            'config' => true,
+        ],
+    ],
+
+    // 维护模式配置
+    'maintenance' => [
+        'enabled' => false,
+        'message' => '系统维护中,请稍后再试',
+        'allowed_ips' => [
+            '127.0.0.1',
+            '::1',
+        ],
+        'retry_after' => 3600, // 秒
+    ],
+
+    // 通知配置
+    'notifications' => [
+        'enabled' => true,
+        'channels' => [
+            'database' => true,
+            'mail' => false,
+            'sms' => false,
+        ],
+        'events' => [
+            'system_error' => true,
+            'high_cpu_usage' => true,
+            'disk_space_low' => true,
+            'failed_login' => true,
+        ],
+    ],
+];

+ 120 - 0
app/Module/Admin/Databases/GenerateSql/admin_logs.sql

@@ -0,0 +1,120 @@
+-- Admin模块 - 管理员日志表
+-- 用于记录管理员的所有操作行为
+
+CREATE TABLE `kku_admin_logs` (
+  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+  `admin_id` int(11) DEFAULT NULL COMMENT '管理员ID',
+  `admin_name` varchar(100) NOT NULL DEFAULT '' COMMENT '管理员名称',
+  `action_type` varchar(50) NOT NULL DEFAULT '' COMMENT '操作类型',
+  `description` varchar(500) NOT NULL DEFAULT '' COMMENT '操作描述',
+  `data` text COMMENT '操作数据(JSON格式)',
+  `ip_address` varchar(45) NOT NULL DEFAULT '' COMMENT 'IP地址',
+  `user_agent` text COMMENT '用户代理',
+  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_admin_id` (`admin_id`),
+  KEY `idx_action_type` (`action_type`),
+  KEY `idx_ip_address` (`ip_address`),
+  KEY `idx_created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员操作日志表';
+
+-- Admin模块 - 管理员设置表
+-- 用于存储管理员的个人设置和系统配置
+
+CREATE TABLE `kku_admin_settings` (
+  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+  `admin_id` int(11) DEFAULT NULL COMMENT '管理员ID,NULL表示系统全局设置',
+  `setting_key` varchar(100) NOT NULL DEFAULT '' COMMENT '设置键名',
+  `setting_value` text COMMENT '设置值',
+  `setting_type` varchar(20) NOT NULL DEFAULT 'string' COMMENT '设置类型(string,int,bool,json)',
+  `description` varchar(255) NOT NULL DEFAULT '' COMMENT '设置描述',
+  `is_system` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否为系统设置(1:是 0:否)',
+  `is_encrypted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否加密存储(1:是 0:否)',
+  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uk_admin_key` (`admin_id`, `setting_key`),
+  KEY `idx_setting_key` (`setting_key`),
+  KEY `idx_is_system` (`is_system`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员设置表';
+
+-- 插入一些默认的系统设置
+INSERT INTO `kku_admin_settings` (`admin_id`, `setting_key`, `setting_value`, `setting_type`, `description`, `is_system`) VALUES
+(NULL, 'dashboard_refresh_interval', '30', 'int', '仪表板刷新间隔(秒)', 1),
+(NULL, 'log_retention_days', '30', 'int', '日志保留天数', 1),
+(NULL, 'cache_default_ttl', '3600', 'int', '缓存默认TTL(秒)', 1),
+(NULL, 'maintenance_mode', '0', 'bool', '维护模式开关', 1),
+(NULL, 'backup_retention_days', '7', 'int', '备份保留天数', 1),
+(NULL, 'session_timeout', '7200', 'int', '会话超时时间(秒)', 1),
+(NULL, 'max_login_attempts', '5', 'int', '最大登录尝试次数', 1),
+(NULL, 'lockout_duration', '900', 'int', '锁定持续时间(秒)', 1);
+
+-- Admin模块 - 系统监控指标表
+-- 用于存储系统性能监控数据
+
+CREATE TABLE `kku_admin_metrics` (
+  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+  `metric_type` varchar(50) NOT NULL DEFAULT '' COMMENT '指标类型(cpu,memory,disk,database等)',
+  `metric_name` varchar(100) NOT NULL DEFAULT '' COMMENT '指标名称',
+  `metric_value` decimal(10,4) NOT NULL DEFAULT 0.0000 COMMENT '指标值',
+  `metric_unit` varchar(20) NOT NULL DEFAULT '' COMMENT '指标单位',
+  `server_name` varchar(100) NOT NULL DEFAULT '' COMMENT '服务器名称',
+  `collected_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '采集时间',
+  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_metric_type` (`metric_type`),
+  KEY `idx_metric_name` (`metric_name`),
+  KEY `idx_collected_at` (`collected_at`),
+  KEY `idx_server_name` (`server_name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统监控指标表';
+
+-- Admin模块 - 系统备份记录表
+-- 用于记录系统备份操作
+
+CREATE TABLE `kku_admin_backups` (
+  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+  `backup_name` varchar(255) NOT NULL DEFAULT '' COMMENT '备份名称',
+  `backup_type` varchar(50) NOT NULL DEFAULT '' COMMENT '备份类型(full,database,files,config)',
+  `backup_path` varchar(500) NOT NULL DEFAULT '' COMMENT '备份文件路径',
+  `backup_size` bigint(20) NOT NULL DEFAULT 0 COMMENT '备份文件大小(字节)',
+  `backup_status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '备份状态(pending,running,completed,failed)',
+  `admin_id` int(11) DEFAULT NULL COMMENT '操作管理员ID',
+  `admin_name` varchar(100) NOT NULL DEFAULT '' COMMENT '操作管理员名称',
+  `started_at` timestamp NULL DEFAULT NULL COMMENT '开始时间',
+  `completed_at` timestamp NULL DEFAULT NULL COMMENT '完成时间',
+  `error_message` text COMMENT '错误信息',
+  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_backup_type` (`backup_type`),
+  KEY `idx_backup_status` (`backup_status`),
+  KEY `idx_admin_id` (`admin_id`),
+  KEY `idx_created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统备份记录表';
+
+-- Admin模块 - 系统通知表
+-- 用于存储系统通知和警报
+
+CREATE TABLE `kku_admin_notifications` (
+  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+  `notification_type` varchar(50) NOT NULL DEFAULT '' COMMENT '通知类型(alert,warning,info,success)',
+  `title` varchar(255) NOT NULL DEFAULT '' COMMENT '通知标题',
+  `message` text NOT NULL COMMENT '通知内容',
+  `data` text COMMENT '附加数据(JSON格式)',
+  `admin_id` int(11) DEFAULT NULL COMMENT '目标管理员ID,NULL表示全体管理员',
+  `is_read` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已读(1:是 0:否)',
+  `is_system` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否为系统通知(1:是 0:否)',
+  `priority` tinyint(4) NOT NULL DEFAULT 1 COMMENT '优先级(1:低 2:中 3:高 4:紧急)',
+  `expires_at` timestamp NULL DEFAULT NULL COMMENT '过期时间',
+  `read_at` timestamp NULL DEFAULT NULL COMMENT '阅读时间',
+  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_notification_type` (`notification_type`),
+  KEY `idx_admin_id` (`admin_id`),
+  KEY `idx_is_read` (`is_read`),
+  KEY `idx_is_system` (`is_system`),
+  KEY `idx_priority` (`priority`),
+  KEY `idx_created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统通知表';

+ 163 - 0
app/Module/Admin/Docs/README.md

@@ -0,0 +1,163 @@
+# Admin模块文档
+
+## 文档目录
+
+- [组件使用说明](./组件使用说明.md) - 详细介绍各种组件的使用方法
+- [开发指南](./开发指南.md) - 模块开发的最佳实践和规范
+
+## 快速开始
+
+### 1. 安装模块
+
+Admin模块已经集成到系统中,无需额外安装。
+
+### 2. 配置模块
+
+模块配置文件位于 `app/Module/Admin/Config/admin.php`,可以根据需要调整配置。
+
+### 3. 使用组件
+
+```php
+// 使用表格辅助类
+use App\Module\Admin\AdminControllers\Helper\GridHelper;
+
+$helper = new GridHelper($grid, $this);
+$helper->columnId();
+$helper->columnCreatedAt();
+$helper->columnStatus();
+```
+
+### 4. 记录操作日志
+
+```php
+use App\Module\Admin\Enums\ADMIN_ACTION_TYPE;
+use App\Module\Admin\Services\AdminService;
+
+$adminService = app('admin.service');
+$adminService->logAdminAction(
+    ADMIN_ACTION_TYPE::CREATE,
+    '创建用户',
+    ['user_id' => 123]
+);
+```
+
+### 5. 管理缓存
+
+```php
+use App\Module\Admin\Services\CacheService;
+
+$cacheService = app('admin.cache');
+$cacheService->clearAll();
+$status = $cacheService->getStatus();
+```
+
+## 主要功能
+
+### 仪表板
+- 系统概览统计
+- 性能监控指标
+- 快捷操作入口
+- 系统状态展示
+
+### 缓存管理
+- 缓存状态查看
+- 缓存清理操作
+- 缓存统计信息
+- 缓存预热功能
+
+### 日志管理
+- 操作日志记录
+- 日志查看和筛选
+- 日志导出功能
+- 日志清理工具
+
+### 系统信息
+- 服务器信息展示
+- PHP环境信息
+- 数据库状态
+- 性能指标监控
+
+### 通用组件
+- 表格辅助类
+- 表单辅助类
+- 筛选器组件
+- 小部件组件
+
+## API接口
+
+### 系统状态
+```
+GET /admin/api/system-status
+```
+
+### 仪表板数据刷新
+```
+GET /admin/api/dashboard/refresh
+```
+
+### 缓存操作
+```
+POST /admin/admin-cache/clear-all
+POST /admin/admin-cache/clear-type
+POST /admin/admin-cache/warmup
+```
+
+## 事件系统
+
+### AdminActionEvent
+当管理员执行操作时触发,用于记录操作日志和发送通知。
+
+```php
+Event::dispatch(new AdminActionEvent($actionData));
+```
+
+## 枚举类型
+
+### ADMIN_ACTION_TYPE
+定义了所有管理员操作类型,包括:
+- LOGIN/LOGOUT - 登录/登出
+- CREATE/UPDATE/DELETE - 增删改
+- CACHE_CLEAR - 缓存清理
+- BACKUP/RESTORE - 备份/恢复
+- MAINTENANCE - 系统维护
+
+### CACHE_TYPE
+定义了所有缓存类型,包括:
+- CONFIG - 配置缓存
+- SYSTEM - 系统缓存
+- USER - 用户缓存
+- SESSION - 会话缓存
+- 等等...
+
+## 数据库表
+
+### kku_admin_logs
+管理员操作日志表,记录所有管理员操作。
+
+### kku_admin_settings
+管理员设置表,存储个人设置和系统配置。
+
+### kku_admin_metrics
+系统监控指标表,存储性能监控数据。
+
+### kku_admin_backups
+系统备份记录表,记录备份操作。
+
+### kku_admin_notifications
+系统通知表,存储通知和警报。
+
+## 注意事项
+
+1. **权限控制**: 确保只有授权的管理员才能访问Admin模块功能
+2. **操作记录**: 所有重要操作都会被记录到日志中
+3. **缓存管理**: 谨慎使用缓存清理功能,可能影响系统性能
+4. **系统维护**: 维护操作可能需要较长时间,建议在低峰期执行
+5. **备份恢复**: 备份和恢复操作需要足够的磁盘空间和权限
+
+## 扩展开发
+
+如需扩展Admin模块功能,请参考 [开发指南](./开发指南.md)。
+
+## 问题反馈
+
+如遇到问题,请查看日志文件或联系开发团队。

+ 155 - 0
app/Module/Admin/Enums/ADMIN_ACTION_TYPE.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace App\Module\Admin\Enums;
+
+/**
+ * 管理员操作类型枚举
+ */
+enum ADMIN_ACTION_TYPE: string
+{
+    case LOGIN = 'LOGIN';                    // 登录
+    case LOGOUT = 'LOGOUT';                  // 登出
+    case CREATE = 'CREATE';                  // 创建
+    case UPDATE = 'UPDATE';                  // 更新
+    case DELETE = 'DELETE';                  // 删除
+    case VIEW = 'VIEW';                      // 查看
+    case EXPORT = 'EXPORT';                  // 导出
+    case IMPORT = 'IMPORT';                  // 导入
+    case CACHE_CLEAR = 'CACHE_CLEAR';        // 清理缓存
+    case BACKUP = 'BACKUP';                  // 备份
+    case RESTORE = 'RESTORE';                // 恢复
+    case MAINTENANCE = 'MAINTENANCE';        // 维护
+    case CONFIG_CHANGE = 'CONFIG_CHANGE';    // 配置变更
+    case PERMISSION_CHANGE = 'PERMISSION_CHANGE'; // 权限变更
+    case PASSWORD_RESET = 'PASSWORD_RESET';  // 密码重置
+    case SYSTEM_RESTART = 'SYSTEM_RESTART';  // 系统重启
+
+    /**
+     * 获取操作类型的中文描述
+     *
+     * @return string
+     */
+    public function getLabel(): string
+    {
+        return match ($this) {
+            self::LOGIN => '登录',
+            self::LOGOUT => '登出',
+            self::CREATE => '创建',
+            self::UPDATE => '更新',
+            self::DELETE => '删除',
+            self::VIEW => '查看',
+            self::EXPORT => '导出',
+            self::IMPORT => '导入',
+            self::CACHE_CLEAR => '清理缓存',
+            self::BACKUP => '备份',
+            self::RESTORE => '恢复',
+            self::MAINTENANCE => '维护',
+            self::CONFIG_CHANGE => '配置变更',
+            self::PERMISSION_CHANGE => '权限变更',
+            self::PASSWORD_RESET => '密码重置',
+            self::SYSTEM_RESTART => '系统重启',
+        };
+    }
+
+    /**
+     * 获取操作类型的颜色
+     *
+     * @return string
+     */
+    public function getColor(): string
+    {
+        return match ($this) {
+            self::LOGIN => 'success',
+            self::LOGOUT => 'info',
+            self::CREATE => 'primary',
+            self::UPDATE => 'warning',
+            self::DELETE => 'danger',
+            self::VIEW => 'secondary',
+            self::EXPORT => 'info',
+            self::IMPORT => 'info',
+            self::CACHE_CLEAR => 'warning',
+            self::BACKUP => 'primary',
+            self::RESTORE => 'warning',
+            self::MAINTENANCE => 'danger',
+            self::CONFIG_CHANGE => 'warning',
+            self::PERMISSION_CHANGE => 'danger',
+            self::PASSWORD_RESET => 'warning',
+            self::SYSTEM_RESTART => 'danger',
+        };
+    }
+
+    /**
+     * 获取操作类型的图标
+     *
+     * @return string
+     */
+    public function getIcon(): string
+    {
+        return match ($this) {
+            self::LOGIN => 'fa-sign-in-alt',
+            self::LOGOUT => 'fa-sign-out-alt',
+            self::CREATE => 'fa-plus',
+            self::UPDATE => 'fa-edit',
+            self::DELETE => 'fa-trash',
+            self::VIEW => 'fa-eye',
+            self::EXPORT => 'fa-download',
+            self::IMPORT => 'fa-upload',
+            self::CACHE_CLEAR => 'fa-broom',
+            self::BACKUP => 'fa-archive',
+            self::RESTORE => 'fa-undo',
+            self::MAINTENANCE => 'fa-tools',
+            self::CONFIG_CHANGE => 'fa-cog',
+            self::PERMISSION_CHANGE => 'fa-shield-alt',
+            self::PASSWORD_RESET => 'fa-key',
+            self::SYSTEM_RESTART => 'fa-power-off',
+        };
+    }
+
+    /**
+     * 获取所有操作类型的选项数组
+     *
+     * @return array
+     */
+    public static function getOptions(): array
+    {
+        $options = [];
+        foreach (self::cases() as $case) {
+            $options[$case->value] = $case->getLabel();
+        }
+        return $options;
+    }
+
+    /**
+     * 判断是否为危险操作
+     *
+     * @return bool
+     */
+    public function isDangerous(): bool
+    {
+        return in_array($this, [
+            self::DELETE,
+            self::MAINTENANCE,
+            self::PERMISSION_CHANGE,
+            self::SYSTEM_RESTART,
+        ]);
+    }
+
+    /**
+     * 判断是否需要记录详细日志
+     *
+     * @return bool
+     */
+    public function needsDetailedLog(): bool
+    {
+        return in_array($this, [
+            self::DELETE,
+            self::CONFIG_CHANGE,
+            self::PERMISSION_CHANGE,
+            self::PASSWORD_RESET,
+            self::BACKUP,
+            self::RESTORE,
+            self::MAINTENANCE,
+            self::SYSTEM_RESTART,
+        ]);
+    }
+}

+ 181 - 0
app/Module/Admin/Enums/CACHE_TYPE.php

@@ -0,0 +1,181 @@
+<?php
+
+namespace App\Module\Admin\Enums;
+
+/**
+ * 缓存类型枚举
+ */
+enum CACHE_TYPE: string
+{
+    case CONFIG = 'CONFIG';                  // 配置缓存
+    case SYSTEM = 'SYSTEM';                  // 系统缓存
+    case USER = 'USER';                      // 用户缓存
+    case SESSION = 'SESSION';                // 会话缓存
+    case ROUTE = 'ROUTE';                    // 路由缓存
+    case VIEW = 'VIEW';                      // 视图缓存
+    case EVENT = 'EVENT';                    // 事件缓存
+    case PERMISSION = 'PERMISSION';          // 权限缓存
+    case MENU = 'MENU';                      // 菜单缓存
+    case STATISTICS = 'STATISTICS';          // 统计缓存
+    case TEMPORARY = 'TEMPORARY';            // 临时缓存
+    case APPLICATION = 'APPLICATION';        // 应用缓存
+
+    /**
+     * 获取缓存类型的中文描述
+     *
+     * @return string
+     */
+    public function getLabel(): string
+    {
+        return match ($this) {
+            self::CONFIG => '配置缓存',
+            self::SYSTEM => '系统缓存',
+            self::USER => '用户缓存',
+            self::SESSION => '会话缓存',
+            self::ROUTE => '路由缓存',
+            self::VIEW => '视图缓存',
+            self::EVENT => '事件缓存',
+            self::PERMISSION => '权限缓存',
+            self::MENU => '菜单缓存',
+            self::STATISTICS => '统计缓存',
+            self::TEMPORARY => '临时缓存',
+            self::APPLICATION => '应用缓存',
+        };
+    }
+
+    /**
+     * 获取缓存类型的描述
+     *
+     * @return string
+     */
+    public function getDescription(): string
+    {
+        return match ($this) {
+            self::CONFIG => '系统配置项缓存,包括数据库配置、应用配置等',
+            self::SYSTEM => '系统级别的缓存,包括系统信息、状态等',
+            self::USER => '用户相关的缓存,包括用户信息、偏好设置等',
+            self::SESSION => '用户会话缓存,包括登录状态、临时数据等',
+            self::ROUTE => 'Laravel路由缓存,提高路由解析性能',
+            self::VIEW => 'Blade视图编译缓存,提高页面渲染性能',
+            self::EVENT => '事件监听器缓存,提高事件处理性能',
+            self::PERMISSION => '权限和角色缓存,提高权限验证性能',
+            self::MENU => '后台菜单缓存,提高菜单加载性能',
+            self::STATISTICS => '统计数据缓存,包括报表、图表数据等',
+            self::TEMPORARY => '临时缓存,用于短期数据存储',
+            self::APPLICATION => '应用级别的缓存,包括业务数据缓存',
+        };
+    }
+
+    /**
+     * 获取缓存类型的默认TTL(秒)
+     *
+     * @return int
+     */
+    public function getDefaultTtl(): int
+    {
+        return match ($this) {
+            self::CONFIG => 7200,      // 2小时
+            self::SYSTEM => 3600,      // 1小时
+            self::USER => 1800,        // 30分钟
+            self::SESSION => 7200,     // 2小时
+            self::ROUTE => 86400,      // 24小时
+            self::VIEW => 86400,       // 24小时
+            self::EVENT => 3600,       // 1小时
+            self::PERMISSION => 3600,  // 1小时
+            self::MENU => 7200,        // 2小时
+            self::STATISTICS => 300,   // 5分钟
+            self::TEMPORARY => 600,    // 10分钟
+            self::APPLICATION => 1800, // 30分钟
+        };
+    }
+
+    /**
+     * 获取缓存类型的标签
+     *
+     * @return array
+     */
+    public function getTags(): array
+    {
+        return match ($this) {
+            self::CONFIG => ['admin', 'config'],
+            self::SYSTEM => ['admin', 'system'],
+            self::USER => ['user'],
+            self::SESSION => ['session'],
+            self::ROUTE => ['laravel', 'route'],
+            self::VIEW => ['laravel', 'view'],
+            self::EVENT => ['laravel', 'event'],
+            self::PERMISSION => ['admin', 'permission'],
+            self::MENU => ['admin', 'menu'],
+            self::STATISTICS => ['admin', 'stats'],
+            self::TEMPORARY => ['temp'],
+            self::APPLICATION => ['app'],
+        };
+    }
+
+    /**
+     * 获取缓存类型的优先级
+     *
+     * @return int
+     */
+    public function getPriority(): int
+    {
+        return match ($this) {
+            self::SYSTEM => 1,         // 最高优先级
+            self::CONFIG => 2,
+            self::PERMISSION => 3,
+            self::MENU => 4,
+            self::USER => 5,
+            self::SESSION => 6,
+            self::ROUTE => 7,
+            self::VIEW => 8,
+            self::EVENT => 9,
+            self::APPLICATION => 10,
+            self::STATISTICS => 11,
+            self::TEMPORARY => 12,     // 最低优先级
+        };
+    }
+
+    /**
+     * 获取所有缓存类型的选项数组
+     *
+     * @return array
+     */
+    public static function getOptions(): array
+    {
+        $options = [];
+        foreach (self::cases() as $case) {
+            $options[$case->value] = $case->getLabel();
+        }
+        return $options;
+    }
+
+    /**
+     * 判断是否为系统关键缓存
+     *
+     * @return bool
+     */
+    public function isCritical(): bool
+    {
+        return in_array($this, [
+            self::SYSTEM,
+            self::CONFIG,
+            self::PERMISSION,
+            self::SESSION,
+        ]);
+    }
+
+    /**
+     * 判断是否可以安全清理
+     *
+     * @return bool
+     */
+    public function isSafeToClear(): bool
+    {
+        return in_array($this, [
+            self::STATISTICS,
+            self::TEMPORARY,
+            self::VIEW,
+            self::ROUTE,
+        ]);
+    }
+}

+ 119 - 0
app/Module/Admin/Events/AdminActionEvent.php

@@ -0,0 +1,119 @@
+<?php
+
+namespace App\Module\Admin\Events;
+
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+/**
+ * 管理员操作事件
+ */
+class AdminActionEvent
+{
+    use Dispatchable, SerializesModels;
+
+    /**
+     * @var array
+     */
+    public array $actionData;
+
+    /**
+     * 创建新的事件实例
+     *
+     * @param array $actionData
+     */
+    public function __construct(array $actionData)
+    {
+        $this->actionData = $actionData;
+    }
+
+    /**
+     * 获取操作数据
+     *
+     * @return array
+     */
+    public function getActionData(): array
+    {
+        return $this->actionData;
+    }
+
+    /**
+     * 获取管理员ID
+     *
+     * @return int|null
+     */
+    public function getAdminId(): ?int
+    {
+        return $this->actionData['admin_id'] ?? null;
+    }
+
+    /**
+     * 获取管理员名称
+     *
+     * @return string
+     */
+    public function getAdminName(): string
+    {
+        return $this->actionData['admin_name'] ?? 'Unknown';
+    }
+
+    /**
+     * 获取操作类型
+     *
+     * @return string
+     */
+    public function getActionType(): string
+    {
+        return $this->actionData['action_type'] ?? '';
+    }
+
+    /**
+     * 获取操作描述
+     *
+     * @return string
+     */
+    public function getDescription(): string
+    {
+        return $this->actionData['description'] ?? '';
+    }
+
+    /**
+     * 获取操作数据
+     *
+     * @return array
+     */
+    public function getData(): array
+    {
+        return $this->actionData['data'] ?? [];
+    }
+
+    /**
+     * 获取IP地址
+     *
+     * @return string
+     */
+    public function getIpAddress(): string
+    {
+        return $this->actionData['ip_address'] ?? '';
+    }
+
+    /**
+     * 获取用户代理
+     *
+     * @return string
+     */
+    public function getUserAgent(): string
+    {
+        return $this->actionData['user_agent'] ?? '';
+    }
+
+    /**
+     * 获取时间戳
+     *
+     * @return \Carbon\Carbon|null
+     */
+    public function getTimestamp(): ?\Carbon\Carbon
+    {
+        return $this->actionData['timestamp'] ?? null;
+    }
+}

+ 113 - 0
app/Module/Admin/Listeners/AdminActionListener.php

@@ -0,0 +1,113 @@
+<?php
+
+namespace App\Module\Admin\Listeners;
+
+use App\Module\Admin\Events\AdminActionEvent;
+use App\Module\Admin\Models\AdminLog;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 管理员操作监听器
+ */
+class AdminActionListener
+{
+    /**
+     * 处理事件
+     *
+     * @param AdminActionEvent $event
+     * @return void
+     */
+    public function handle(AdminActionEvent $event): void
+    {
+        try {
+            // 保存到数据库
+            $this->saveToDatabase($event);
+            
+            // 记录到日志文件
+            $this->logToFile($event);
+            
+            // 发送通知(如果需要)
+            $this->sendNotificationIfNeeded($event);
+            
+        } catch (\Exception $e) {
+            Log::error('Admin action listener error: ' . $e->getMessage(), [
+                'event_data' => $event->getActionData(),
+                'error' => $e->getTraceAsString(),
+            ]);
+        }
+    }
+
+    /**
+     * 保存到数据库
+     *
+     * @param AdminActionEvent $event
+     * @return void
+     */
+    protected function saveToDatabase(AdminActionEvent $event): void
+    {
+        try {
+            AdminLog::create([
+                'admin_id' => $event->getAdminId(),
+                'admin_name' => $event->getAdminName(),
+                'action_type' => $event->getActionType(),
+                'description' => $event->getDescription(),
+                'data' => json_encode($event->getData(), JSON_UNESCAPED_UNICODE),
+                'ip_address' => $event->getIpAddress(),
+                'user_agent' => $event->getUserAgent(),
+                'created_at' => $event->getTimestamp(),
+            ]);
+        } catch (\Exception $e) {
+            Log::error('Failed to save admin action to database: ' . $e->getMessage());
+        }
+    }
+
+    /**
+     * 记录到日志文件
+     *
+     * @param AdminActionEvent $event
+     * @return void
+     */
+    protected function logToFile(AdminActionEvent $event): void
+    {
+        $logData = [
+            'admin_id' => $event->getAdminId(),
+            'admin_name' => $event->getAdminName(),
+            'action_type' => $event->getActionType(),
+            'description' => $event->getDescription(),
+            'ip_address' => $event->getIpAddress(),
+            'timestamp' => $event->getTimestamp()?->toDateTimeString(),
+        ];
+
+        Log::channel('admin')->info('Admin Action: ' . $event->getDescription(), $logData);
+    }
+
+    /**
+     * 发送通知(如果需要)
+     *
+     * @param AdminActionEvent $event
+     * @return void
+     */
+    protected function sendNotificationIfNeeded(AdminActionEvent $event): void
+    {
+        // 检查是否需要发送通知
+        $criticalActions = [
+            'DELETE',
+            'MAINTENANCE',
+            'PERMISSION_CHANGE',
+            'SYSTEM_RESTART',
+            'BACKUP',
+            'RESTORE',
+        ];
+
+        if (in_array($event->getActionType(), $criticalActions)) {
+            // 这里可以实现发送通知的逻辑
+            // 例如:发送邮件、短信、推送等
+            Log::channel('admin')->warning('Critical Admin Action: ' . $event->getDescription(), [
+                'admin_name' => $event->getAdminName(),
+                'action_type' => $event->getActionType(),
+                'ip_address' => $event->getIpAddress(),
+                'timestamp' => $event->getTimestamp()?->toDateTimeString(),
+            ]);
+        }
+    }
+}

+ 248 - 0
app/Module/Admin/Models/AdminLog.php

@@ -0,0 +1,248 @@
+<?php
+
+namespace App\Module\Admin\Models;
+
+use App\Module\Admin\Enums\ADMIN_ACTION_TYPE;
+use UCore\ModelCore;
+
+/**
+ * 管理员日志模型
+ * 
+ * @property int $id
+ * @property int|null $admin_id 管理员ID
+ * @property string $admin_name 管理员名称
+ * @property string $action_type 操作类型
+ * @property string $description 操作描述
+ * @property string|null $data 操作数据(JSON)
+ * @property string $ip_address IP地址
+ * @property string|null $user_agent 用户代理
+ * @property \Carbon\Carbon $created_at 创建时间
+ * @property \Carbon\Carbon $updated_at 更新时间
+ */
+class AdminLog extends ModelCore
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     */
+    protected $table = 'admin_logs';
+
+    /**
+     * 可批量赋值的属性
+     *
+     * @var array
+     */
+    protected $fillable = [
+        'admin_id',
+        'admin_name',
+        'action_type',
+        'description',
+        'data',
+        'ip_address',
+        'user_agent',
+    ];
+
+    /**
+     * 属性类型转换
+     *
+     * @var array
+     */
+    protected $casts = [
+        'admin_id' => 'integer',
+        'data' => 'array',
+        'created_at' => 'datetime',
+        'updated_at' => 'datetime',
+    ];
+
+    /**
+     * 获取操作类型枚举
+     *
+     * @return ADMIN_ACTION_TYPE|null
+     */
+    public function getActionTypeEnumAttribute(): ?ADMIN_ACTION_TYPE
+    {
+        try {
+            return ADMIN_ACTION_TYPE::from($this->action_type);
+        } catch (\ValueError $e) {
+            return null;
+        }
+    }
+
+    /**
+     * 获取操作类型标签
+     *
+     * @return string
+     */
+    public function getActionTypeLabelAttribute(): string
+    {
+        $enum = $this->getActionTypeEnumAttribute();
+        return $enum ? $enum->getLabel() : $this->action_type;
+    }
+
+    /**
+     * 获取操作类型颜色
+     *
+     * @return string
+     */
+    public function getActionTypeColorAttribute(): string
+    {
+        $enum = $this->getActionTypeEnumAttribute();
+        return $enum ? $enum->getColor() : 'secondary';
+    }
+
+    /**
+     * 获取操作类型图标
+     *
+     * @return string
+     */
+    public function getActionTypeIconAttribute(): string
+    {
+        $enum = $this->getActionTypeEnumAttribute();
+        return $enum ? $enum->getIcon() : 'fa-question';
+    }
+
+    /**
+     * 判断是否为危险操作
+     *
+     * @return bool
+     */
+    public function getIsDangerousAttribute(): bool
+    {
+        $enum = $this->getActionTypeEnumAttribute();
+        return $enum ? $enum->isDangerous() : false;
+    }
+
+    /**
+     * 获取格式化的数据
+     *
+     * @return string
+     */
+    public function getFormattedDataAttribute(): string
+    {
+        if (empty($this->data)) {
+            return '';
+        }
+
+        if (is_array($this->data)) {
+            return json_encode($this->data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
+        }
+
+        return (string) $this->data;
+    }
+
+    /**
+     * 获取简短的用户代理
+     *
+     * @return string
+     */
+    public function getShortUserAgentAttribute(): string
+    {
+        if (empty($this->user_agent)) {
+            return '';
+        }
+
+        // 提取浏览器信息
+        if (preg_match('/Chrome\/[\d.]+/', $this->user_agent, $matches)) {
+            return $matches[0];
+        }
+
+        if (preg_match('/Firefox\/[\d.]+/', $this->user_agent, $matches)) {
+            return $matches[0];
+        }
+
+        if (preg_match('/Safari\/[\d.]+/', $this->user_agent, $matches)) {
+            return $matches[0];
+        }
+
+        if (preg_match('/Edge\/[\d.]+/', $this->user_agent, $matches)) {
+            return $matches[0];
+        }
+
+        // 如果没有匹配到,返回前50个字符
+        return mb_substr($this->user_agent, 0, 50) . '...';
+    }
+
+    /**
+     * 按操作类型查询
+     *
+     * @param \Illuminate\Database\Eloquent\Builder $query
+     * @param string|ADMIN_ACTION_TYPE $actionType
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function scopeByActionType($query, $actionType)
+    {
+        if ($actionType instanceof ADMIN_ACTION_TYPE) {
+            $actionType = $actionType->value;
+        }
+
+        return $query->where('action_type', $actionType);
+    }
+
+    /**
+     * 按管理员查询
+     *
+     * @param \Illuminate\Database\Eloquent\Builder $query
+     * @param int $adminId
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function scopeByAdmin($query, int $adminId)
+    {
+        return $query->where('admin_id', $adminId);
+    }
+
+    /**
+     * 按IP地址查询
+     *
+     * @param \Illuminate\Database\Eloquent\Builder $query
+     * @param string $ipAddress
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function scopeByIpAddress($query, string $ipAddress)
+    {
+        return $query->where('ip_address', $ipAddress);
+    }
+
+    /**
+     * 按时间范围查询
+     *
+     * @param \Illuminate\Database\Eloquent\Builder $query
+     * @param string $startDate
+     * @param string $endDate
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function scopeByDateRange($query, string $startDate, string $endDate)
+    {
+        return $query->whereBetween('created_at', [$startDate, $endDate]);
+    }
+
+    /**
+     * 查询危险操作
+     *
+     * @param \Illuminate\Database\Eloquent\Builder $query
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function scopeDangerousActions($query)
+    {
+        $dangerousTypes = [];
+        foreach (ADMIN_ACTION_TYPE::cases() as $type) {
+            if ($type->isDangerous()) {
+                $dangerousTypes[] = $type->value;
+            }
+        }
+
+        return $query->whereIn('action_type', $dangerousTypes);
+    }
+
+    /**
+     * 最近的操作
+     *
+     * @param \Illuminate\Database\Eloquent\Builder $query
+     * @param int $hours
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function scopeRecent($query, int $hours = 24)
+    {
+        return $query->where('created_at', '>=', now()->subHours($hours));
+    }
+}

+ 138 - 0
app/Module/Admin/Providers/AdminServiceProvider.php

@@ -0,0 +1,138 @@
+<?php
+
+namespace App\Module\Admin\Providers;
+
+use App\Module\Admin\Events\AdminActionEvent;
+use App\Module\Admin\Listeners\AdminActionListener;
+use Illuminate\Support\Facades\Event;
+use Illuminate\Support\ServiceProvider;
+
+/**
+ * Admin模块服务提供者
+ * 
+ * 负责注册Admin模块的服务、事件监听器等
+ */
+class AdminServiceProvider extends ServiceProvider
+{
+    /**
+     * 注册服务
+     *
+     * @return void
+     */
+    public function register()
+    {
+        // 注册配置文件
+        $this->mergeConfigFrom(
+            __DIR__ . '/../Config/admin.php',
+            'admin_module'
+        );
+
+        // 注册服务
+        $this->registerServices();
+    }
+
+    /**
+     * 启动服务
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        // 注册事件监听器
+        $this->registerEventListeners();
+
+        // 注册命令
+        $this->registerCommands();
+
+        // 发布资源
+        $this->publishResources();
+    }
+
+    /**
+     * 注册服务
+     *
+     * @return void
+     */
+    protected function registerServices()
+    {
+        // 注册Admin服务
+        $this->app->singleton('admin.service', function ($app) {
+            return new \App\Module\Admin\Services\AdminService();
+        });
+
+        // 注册缓存服务
+        $this->app->singleton('admin.cache', function ($app) {
+            return new \App\Module\Admin\Services\CacheService();
+        });
+
+        // 注册日志服务
+        $this->app->singleton('admin.log', function ($app) {
+            return new \App\Module\Admin\Services\LogService();
+        });
+    }
+
+    /**
+     * 注册事件监听器
+     *
+     * @return void
+     */
+    protected function registerEventListeners()
+    {
+        Event::listen(
+            AdminActionEvent::class,
+            AdminActionListener::class
+        );
+    }
+
+    /**
+     * 注册命令
+     *
+     * @return void
+     */
+    protected function registerCommands()
+    {
+        if ($this->app->runningInConsole()) {
+            $this->commands([
+                \App\Module\Admin\Commands\AdminCacheCommand::class,
+                \App\Module\Admin\Commands\AdminMaintenanceCommand::class,
+            ]);
+        }
+    }
+
+    /**
+     * 发布资源
+     *
+     * @return void
+     */
+    protected function publishResources()
+    {
+        // 发布配置文件
+        $this->publishes([
+            __DIR__ . '/../Config/admin.php' => config_path('admin_module.php'),
+        ], 'admin-config');
+
+        // 发布视图文件
+        $this->publishes([
+            __DIR__ . '/../Resources/views' => resource_path('views/admin'),
+        ], 'admin-views');
+
+        // 发布静态资源
+        $this->publishes([
+            __DIR__ . '/../Resources/assets' => public_path('vendor/admin'),
+        ], 'admin-assets');
+    }
+
+    /**
+     * 获取提供的服务
+     *
+     * @return array
+     */
+    public function provides()
+    {
+        return [
+            'admin.service',
+            'admin.cache',
+            'admin.log',
+        ];
+    }
+}

+ 221 - 0
app/Module/Admin/README.md

@@ -0,0 +1,221 @@
+# Admin模块 - 后台基础功能扩展
+
+> 扩展后台基础功能,提供通用的后台管理组件和工具
+
+## 模块概述
+
+Admin模块是专门用于扩展后台基础功能的模块,提供通用的后台管理组件、工具类、辅助功能等。该模块不处理具体的业务逻辑,而是为其他模块的后台管理功能提供基础支持和通用组件。
+
+## 功能特点
+
+- **通用组件库**: 提供可复用的后台管理组件
+- **工具类集合**: 提供常用的后台管理工具
+- **辅助功能**: 提供后台开发的辅助功能
+- **扩展基础**: 为其他模块提供后台功能扩展基础
+
+## 目录结构
+
+```
+app/Module/Admin/
+├── AdminControllers/        # 后台管理控制器
+│   ├── DashboardController.php     # 仪表板控制器
+│   ├── SystemInfoController.php    # 系统信息控制器
+│   ├── CacheController.php         # 缓存管理控制器
+│   ├── LogController.php           # 日志管理控制器
+│   └── Helper/                     # 控制器辅助类
+│       ├── GridHelper.php          # 表格辅助类
+│       ├── FormHelper.php          # 表单辅助类
+│       ├── FilterHelper.php        # 筛选辅助类
+│       └── ShowHelper.php          # 详情辅助类
+├── AdminForms/              # 后台表单组件
+│   ├── CacheManageForm.php         # 缓存管理表单
+│   ├── SystemSettingForm.php      # 系统设置表单
+│   └── LogCleanForm.php            # 日志清理表单
+├── AdminWidgets/            # 后台小部件
+│   ├── SystemStatusWidget.php     # 系统状态小部件
+│   ├── QuickActionsWidget.php     # 快捷操作小部件
+│   └── StatisticsWidget.php       # 统计信息小部件
+├── AdminMetrics/            # 后台指标
+│   ├── SystemMetric.php           # 系统指标
+│   ├── PerformanceMetric.php      # 性能指标
+│   └── UsageMetric.php            # 使用情况指标
+├── AdminActions/            # 后台操作
+│   ├── CacheClearAction.php       # 缓存清理操作
+│   ├── LogExportAction.php        # 日志导出操作
+│   └── SystemBackupAction.php     # 系统备份操作
+├── Commands/                # 命令行工具
+│   ├── AdminCacheCommand.php      # 后台缓存命令
+│   └── AdminMaintenanceCommand.php # 后台维护命令
+├── Databases/               # 数据库相关文件
+│   └── GenerateSql/         # 数据库创建脚本
+├── Docs/                    # 详细文档目录
+│   ├── README.md            # 文档索引
+│   ├── 组件使用说明.md       # 组件使用说明
+│   └── 开发指南.md           # 开发指南
+├── Enums/                   # 枚举类型定义
+│   ├── ADMIN_ACTION_TYPE.php       # 管理员操作类型
+│   └── CACHE_TYPE.php              # 缓存类型
+├── Events/                  # 事件类
+│   └── AdminActionEvent.php        # 管理员操作事件
+├── Listeners/               # 事件监听器
+│   └── AdminActionListener.php     # 管理员操作监听器
+├── Models/                  # 数据模型
+│   ├── AdminLog.php                # 管理员日志模型
+│   └── AdminSetting.php            # 管理员设置模型
+├── Providers/               # 服务提供者
+│   └── AdminServiceProvider.php    # Admin服务提供者
+├── Repositorys/             # 数据仓库
+│   ├── AdminLogRepository.php      # 管理员日志仓库
+│   └── AdminSettingRepository.php  # 管理员设置仓库
+├── Services/                # 服务类
+│   ├── AdminService.php            # 管理员服务
+│   ├── CacheService.php            # 缓存服务
+│   └── LogService.php              # 日志服务
+├── Traits/                  # 特性类
+│   ├── AdminControllerTrait.php    # 管理员控制器特性
+│   └── CacheableTrait.php          # 可缓存特性
+└── Utils/                   # 工具类
+    ├── AdminHelper.php             # 管理员辅助类
+    ├── SystemInfo.php              # 系统信息类
+    └── PerformanceMonitor.php      # 性能监控类
+```
+
+## 核心功能
+
+### 1. 仪表板功能
+- 系统概览统计
+- 性能监控指标
+- 快捷操作入口
+- 系统状态展示
+
+### 2. 缓存管理
+- 缓存状态查看
+- 缓存清理操作
+- 缓存统计信息
+- 缓存配置管理
+
+### 3. 日志管理
+- 日志查看和筛选
+- 日志导出功能
+- 日志清理工具
+- 日志统计分析
+
+### 4. 系统信息
+- 服务器信息展示
+- PHP环境信息
+- 数据库状态
+- 扩展模块状态
+
+### 5. 通用组件
+- 可复用的表格组件
+- 通用的表单组件
+- 筛选器组件
+- 操作按钮组件
+
+## 设计原则
+
+### 1. 通用性
+- 组件设计具有通用性,可被其他模块复用
+- 避免业务逻辑耦合,保持功能独立
+
+### 2. 扩展性
+- 提供良好的扩展接口
+- 支持自定义组件和功能
+
+### 3. 易用性
+- 提供简洁的API接口
+- 完善的文档和示例
+
+### 4. 性能优化
+- 合理的缓存策略
+- 高效的数据查询
+- 资源优化加载
+
+## 与其他模块的关系
+
+### 依赖关系
+- **System模块**: 依赖System模块的基础配置和服务
+- **File模块**: 依赖File模块进行文件操作
+- **User模块**: 依赖User模块进行用户管理
+
+### 服务提供
+- 为所有模块提供通用的后台管理组件
+- 为开发者提供后台开发的辅助工具
+- 为系统管理员提供系统监控和维护功能
+
+## 开发规范
+
+### 1. 命名规范
+- 控制器以`Controller`结尾
+- 服务类以`Service`结尾
+- 仓库类以`Repository`结尾
+- 组件类以`Widget`结尾
+
+### 2. 代码规范
+- 遵循PSR-4自动加载标准
+- 使用PHP 8.0+语法特性
+- 完善的注释和文档
+
+### 3. 测试规范
+- 单元测试覆盖核心功能
+- 集成测试验证组件交互
+- 性能测试确保系统稳定
+
+## 使用示例
+
+### 1. 使用通用表格组件
+```php
+use App\Module\Admin\AdminControllers\Helper\GridHelper;
+
+$helper = new GridHelper($grid, $this);
+$helper->columnId();
+$helper->columnCreatedAt();
+$helper->columnUpdatedAt();
+```
+
+### 2. 使用缓存服务
+```php
+use App\Module\Admin\Services\CacheService;
+
+$cacheService = new CacheService();
+$cacheService->clearAll();
+$status = $cacheService->getStatus();
+```
+
+### 3. 使用系统信息工具
+```php
+use App\Module\Admin\Utils\SystemInfo;
+
+$systemInfo = new SystemInfo();
+$serverInfo = $systemInfo->getServerInfo();
+$phpInfo = $systemInfo->getPhpInfo();
+```
+
+## 开发状态
+
+- 📋 **规划阶段**: 模块设计和架构规划
+- 🚧 **开发中**: 核心功能开发
+- ✅ **已完成**: 基础框架搭建
+
+## 版本历史
+
+- **v0.1.0** (计划中) - 基础架构搭建
+- **v0.2.0** (计划中) - 核心组件实现
+- **v0.3.0** (计划中) - 工具类完善
+- **v1.0.0** (计划中) - 正式版本发布
+
+## 注意事项
+
+1. **模块定位**: Admin模块专注于后台基础功能,不处理具体业务逻辑
+2. **组件复用**: 设计组件时要考虑复用性和通用性
+3. **性能考虑**: 后台功能要注意性能优化,避免影响系统运行
+4. **安全性**: 后台功能涉及系统管理,要特别注意安全性
+5. **兼容性**: 要保持与现有后台框架的兼容性
+
+## 后续规划
+
+1. **组件库完善**: 继续完善通用组件库
+2. **工具类扩展**: 添加更多实用的工具类
+3. **性能优化**: 持续优化后台性能
+4. **文档完善**: 完善使用文档和开发指南
+5. **测试覆盖**: 提高测试覆盖率,确保代码质量

+ 323 - 0
app/Module/Admin/Services/AdminService.php

@@ -0,0 +1,323 @@
+<?php
+
+namespace App\Module\Admin\Services;
+
+use App\Module\Admin\Enums\ADMIN_ACTION_TYPE;
+use App\Module\Admin\Events\AdminActionEvent;
+use App\Module\Admin\Utils\SystemInfo;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Event;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * Admin模块核心服务
+ */
+class AdminService
+{
+    /**
+     * 获取仪表板数据
+     *
+     * @return array
+     */
+    public function getDashboardData(): array
+    {
+        return Cache::remember('admin.dashboard.data', 300, function () {
+            $systemInfo = new SystemInfo();
+            
+            return [
+                'system' => [
+                    'server_info' => $systemInfo->getServerInfo(),
+                    'php_info' => $systemInfo->getPhpInfo(),
+                    'database_info' => $systemInfo->getDatabaseInfo(),
+                    'performance' => $systemInfo->getPerformanceMetrics(),
+                ],
+                'statistics' => [
+                    'users_online' => $this->getOnlineUsersCount(),
+                    'total_requests' => $this->getTotalRequestsCount(),
+                    'error_rate' => $this->getErrorRate(),
+                    'response_time' => $this->getAverageResponseTime(),
+                ],
+                'alerts' => $this->getSystemAlerts(),
+                'recent_actions' => $this->getRecentActions(),
+            ];
+        });
+    }
+
+    /**
+     * 记录管理员操作
+     *
+     * @param ADMIN_ACTION_TYPE $actionType
+     * @param string $description
+     * @param array $data
+     * @return void
+     */
+    public function logAdminAction(ADMIN_ACTION_TYPE $actionType, string $description, array $data = []): void
+    {
+        $adminUser = Auth::guard('admin')->user();
+        
+        $logData = [
+            'admin_id' => $adminUser?->id,
+            'admin_name' => $adminUser?->name ?? 'System',
+            'action_type' => $actionType->value,
+            'description' => $description,
+            'data' => $data,
+            'ip_address' => request()->ip(),
+            'user_agent' => request()->userAgent(),
+            'timestamp' => now(),
+        ];
+
+        // 触发事件
+        Event::dispatch(new AdminActionEvent($logData));
+
+        // 记录日志
+        if ($actionType->needsDetailedLog()) {
+            Log::channel('admin')->info("Admin Action: {$description}", $logData);
+        }
+
+        // 危险操作额外记录
+        if ($actionType->isDangerous()) {
+            Log::channel('admin')->warning("Dangerous Admin Action: {$description}", $logData);
+        }
+    }
+
+    /**
+     * 获取在线用户数量
+     *
+     * @return int
+     */
+    protected function getOnlineUsersCount(): int
+    {
+        // 这里可以根据实际需求实现
+        // 例如:统计最近5分钟内有活动的用户
+        return Cache::remember('admin.stats.online_users', 60, function () {
+            // 实现逻辑
+            return 0;
+        });
+    }
+
+    /**
+     * 获取总请求数
+     *
+     * @return int
+     */
+    protected function getTotalRequestsCount(): int
+    {
+        return Cache::remember('admin.stats.total_requests', 300, function () {
+            // 实现逻辑
+            return 0;
+        });
+    }
+
+    /**
+     * 获取错误率
+     *
+     * @return float
+     */
+    protected function getErrorRate(): float
+    {
+        return Cache::remember('admin.stats.error_rate', 300, function () {
+            // 实现逻辑
+            return 0.0;
+        });
+    }
+
+    /**
+     * 获取平均响应时间
+     *
+     * @return float
+     */
+    protected function getAverageResponseTime(): float
+    {
+        return Cache::remember('admin.stats.response_time', 300, function () {
+            // 实现逻辑
+            return 0.0;
+        });
+    }
+
+    /**
+     * 获取系统警报
+     *
+     * @return array
+     */
+    protected function getSystemAlerts(): array
+    {
+        $alerts = [];
+        $systemInfo = new SystemInfo();
+        $config = config('admin_module.monitoring.alerts');
+
+        // CPU使用率警报
+        $cpuUsage = $systemInfo->getCpuUsage();
+        if ($cpuUsage > $config['cpu_threshold']) {
+            $alerts[] = [
+                'type' => 'warning',
+                'title' => 'CPU使用率过高',
+                'message' => "当前CPU使用率: {$cpuUsage}%",
+                'timestamp' => now(),
+            ];
+        }
+
+        // 内存使用率警报
+        $memoryUsage = $systemInfo->getMemoryUsage();
+        if ($memoryUsage['percentage'] > $config['memory_threshold']) {
+            $alerts[] = [
+                'type' => 'warning',
+                'title' => '内存使用率过高',
+                'message' => "当前内存使用率: {$memoryUsage['percentage']}%",
+                'timestamp' => now(),
+            ];
+        }
+
+        // 磁盘使用率警报
+        $diskUsage = $systemInfo->getDiskUsage();
+        if ($diskUsage['percentage'] > $config['disk_threshold']) {
+            $alerts[] = [
+                'type' => 'danger',
+                'title' => '磁盘空间不足',
+                'message' => "当前磁盘使用率: {$diskUsage['percentage']}%",
+                'timestamp' => now(),
+            ];
+        }
+
+        return $alerts;
+    }
+
+    /**
+     * 获取最近的操作记录
+     *
+     * @param int $limit
+     * @return array
+     */
+    protected function getRecentActions(int $limit = 10): array
+    {
+        return Cache::remember("admin.recent_actions.{$limit}", 60, function () use ($limit) {
+            // 这里应该从数据库获取最近的操作记录
+            // 暂时返回空数组
+            return [];
+        });
+    }
+
+    /**
+     * 获取系统状态
+     *
+     * @return array
+     */
+    public function getSystemStatus(): array
+    {
+        $systemInfo = new SystemInfo();
+        
+        return [
+            'status' => 'running',
+            'uptime' => $systemInfo->getUptime(),
+            'load_average' => $systemInfo->getLoadAverage(),
+            'memory_usage' => $systemInfo->getMemoryUsage(),
+            'disk_usage' => $systemInfo->getDiskUsage(),
+            'database_status' => $systemInfo->getDatabaseStatus(),
+            'cache_status' => $this->getCacheStatus(),
+            'queue_status' => $this->getQueueStatus(),
+        ];
+    }
+
+    /**
+     * 获取缓存状态
+     *
+     * @return array
+     */
+    protected function getCacheStatus(): array
+    {
+        try {
+            Cache::put('admin.cache.test', 'test', 1);
+            $test = Cache::get('admin.cache.test');
+            Cache::forget('admin.cache.test');
+            
+            return [
+                'status' => $test === 'test' ? 'healthy' : 'error',
+                'driver' => config('cache.default'),
+            ];
+        } catch (\Exception $e) {
+            return [
+                'status' => 'error',
+                'error' => $e->getMessage(),
+            ];
+        }
+    }
+
+    /**
+     * 获取队列状态
+     *
+     * @return array
+     */
+    protected function getQueueStatus(): array
+    {
+        try {
+            return [
+                'status' => 'healthy',
+                'driver' => config('queue.default'),
+                'pending_jobs' => 0, // 这里可以实现获取待处理任务数量的逻辑
+            ];
+        } catch (\Exception $e) {
+            return [
+                'status' => 'error',
+                'error' => $e->getMessage(),
+            ];
+        }
+    }
+
+    /**
+     * 执行系统维护
+     *
+     * @param array $options
+     * @return array
+     */
+    public function performMaintenance(array $options = []): array
+    {
+        $results = [];
+        
+        // 清理缓存
+        if ($options['clear_cache'] ?? true) {
+            $cacheService = app('admin.cache');
+            $results['cache'] = $cacheService->clearAll();
+        }
+        
+        // 清理日志
+        if ($options['clean_logs'] ?? false) {
+            $logService = app('admin.log');
+            $results['logs'] = $logService->cleanOldLogs();
+        }
+        
+        // 优化数据库
+        if ($options['optimize_database'] ?? false) {
+            $results['database'] = $this->optimizeDatabase();
+        }
+        
+        // 记录维护操作
+        $this->logAdminAction(
+            ADMIN_ACTION_TYPE::MAINTENANCE,
+            '执行系统维护',
+            ['options' => $options, 'results' => $results]
+        );
+        
+        return $results;
+    }
+
+    /**
+     * 优化数据库
+     *
+     * @return array
+     */
+    protected function optimizeDatabase(): array
+    {
+        try {
+            // 这里可以实现数据库优化逻辑
+            return [
+                'status' => 'success',
+                'message' => '数据库优化完成',
+            ];
+        } catch (\Exception $e) {
+            return [
+                'status' => 'error',
+                'message' => $e->getMessage(),
+            ];
+        }
+    }
+}

+ 272 - 0
app/Module/Admin/Services/CacheService.php

@@ -0,0 +1,272 @@
+<?php
+
+namespace App\Module\Admin\Services;
+
+use App\Module\Admin\Enums\CACHE_TYPE;
+use Illuminate\Support\Facades\Artisan;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 缓存管理服务
+ */
+class CacheService
+{
+    /**
+     * 清理所有缓存
+     *
+     * @return array
+     */
+    public function clearAll(): array
+    {
+        $results = [];
+        
+        try {
+            // 清理应用缓存
+            Cache::flush();
+            $results['application'] = ['status' => 'success', 'message' => '应用缓存清理成功'];
+            
+            // 清理配置缓存
+            Artisan::call('config:clear');
+            $results['config'] = ['status' => 'success', 'message' => '配置缓存清理成功'];
+            
+            // 清理路由缓存
+            Artisan::call('route:clear');
+            $results['route'] = ['status' => 'success', 'message' => '路由缓存清理成功'];
+            
+            // 清理视图缓存
+            Artisan::call('view:clear');
+            $results['view'] = ['status' => 'success', 'message' => '视图缓存清理成功'];
+            
+            // 清理事件缓存
+            Artisan::call('event:clear');
+            $results['event'] = ['status' => 'success', 'message' => '事件缓存清理成功'];
+            
+            Log::info('Admin: 所有缓存清理完成');
+            
+        } catch (\Exception $e) {
+            $results['error'] = ['status' => 'error', 'message' => $e->getMessage()];
+            Log::error('Admin: 缓存清理失败', ['error' => $e->getMessage()]);
+        }
+        
+        return $results;
+    }
+
+    /**
+     * 按类型清理缓存
+     *
+     * @param CACHE_TYPE $type
+     * @return array
+     */
+    public function clearByType(CACHE_TYPE $type): array
+    {
+        try {
+            switch ($type) {
+                case CACHE_TYPE::CONFIG:
+                    Artisan::call('config:clear');
+                    return ['status' => 'success', 'message' => '配置缓存清理成功'];
+                    
+                case CACHE_TYPE::ROUTE:
+                    Artisan::call('route:clear');
+                    return ['status' => 'success', 'message' => '路由缓存清理成功'];
+                    
+                case CACHE_TYPE::VIEW:
+                    Artisan::call('view:clear');
+                    return ['status' => 'success', 'message' => '视图缓存清理成功'];
+                    
+                case CACHE_TYPE::EVENT:
+                    Artisan::call('event:clear');
+                    return ['status' => 'success', 'message' => '事件缓存清理成功'];
+                    
+                case CACHE_TYPE::APPLICATION:
+                    Cache::flush();
+                    return ['status' => 'success', 'message' => '应用缓存清理成功'];
+                    
+                default:
+                    // 按标签清理
+                    $tags = $type->getTags();
+                    if (!empty($tags)) {
+                        Cache::tags($tags)->flush();
+                        return ['status' => 'success', 'message' => "{$type->getLabel()}清理成功"];
+                    }
+                    
+                    return ['status' => 'error', 'message' => '不支持的缓存类型'];
+            }
+        } catch (\Exception $e) {
+            Log::error("Admin: {$type->getLabel()}清理失败", ['error' => $e->getMessage()]);
+            return ['status' => 'error', 'message' => $e->getMessage()];
+        }
+    }
+
+    /**
+     * 获取缓存状态
+     *
+     * @return array
+     */
+    public function getStatus(): array
+    {
+        $status = [];
+        
+        foreach (CACHE_TYPE::cases() as $type) {
+            $status[$type->value] = $this->getCacheTypeStatus($type);
+        }
+        
+        return $status;
+    }
+
+    /**
+     * 获取特定类型缓存的状态
+     *
+     * @param CACHE_TYPE $type
+     * @return array
+     */
+    protected function getCacheTypeStatus(CACHE_TYPE $type): array
+    {
+        try {
+            $testKey = "admin.cache.test.{$type->value}";
+            $testValue = 'test_' . time();
+            
+            // 测试写入
+            Cache::tags($type->getTags())->put($testKey, $testValue, 60);
+            
+            // 测试读取
+            $retrieved = Cache::tags($type->getTags())->get($testKey);
+            
+            // 清理测试数据
+            Cache::tags($type->getTags())->forget($testKey);
+            
+            $isWorking = $retrieved === $testValue;
+            
+            return [
+                'type' => $type->value,
+                'label' => $type->getLabel(),
+                'status' => $isWorking ? 'healthy' : 'error',
+                'description' => $type->getDescription(),
+                'ttl' => $type->getDefaultTtl(),
+                'tags' => $type->getTags(),
+                'priority' => $type->getPriority(),
+                'is_critical' => $type->isCritical(),
+                'safe_to_clear' => $type->isSafeToClear(),
+            ];
+        } catch (\Exception $e) {
+            return [
+                'type' => $type->value,
+                'label' => $type->getLabel(),
+                'status' => 'error',
+                'error' => $e->getMessage(),
+                'description' => $type->getDescription(),
+            ];
+        }
+    }
+
+    /**
+     * 获取缓存统计信息
+     *
+     * @return array
+     */
+    public function getStatistics(): array
+    {
+        try {
+            return [
+                'driver' => config('cache.default'),
+                'stores' => config('cache.stores'),
+                'total_types' => count(CACHE_TYPE::cases()),
+                'critical_types' => count(array_filter(CACHE_TYPE::cases(), fn($type) => $type->isCritical())),
+                'safe_to_clear' => count(array_filter(CACHE_TYPE::cases(), fn($type) => $type->isSafeToClear())),
+            ];
+        } catch (\Exception $e) {
+            return [
+                'error' => $e->getMessage(),
+            ];
+        }
+    }
+
+    /**
+     * 预热缓存
+     *
+     * @param array $types
+     * @return array
+     */
+    public function warmup(array $types = []): array
+    {
+        $results = [];
+        
+        if (empty($types)) {
+            $types = array_map(fn($type) => $type->value, CACHE_TYPE::cases());
+        }
+        
+        foreach ($types as $typeValue) {
+            try {
+                $type = CACHE_TYPE::from($typeValue);
+                $result = $this->warmupCacheType($type);
+                $results[$type->value] = $result;
+            } catch (\Exception $e) {
+                $results[$typeValue] = [
+                    'status' => 'error',
+                    'message' => $e->getMessage(),
+                ];
+            }
+        }
+        
+        return $results;
+    }
+
+    /**
+     * 预热特定类型的缓存
+     *
+     * @param CACHE_TYPE $type
+     * @return array
+     */
+    protected function warmupCacheType(CACHE_TYPE $type): array
+    {
+        try {
+            switch ($type) {
+                case CACHE_TYPE::CONFIG:
+                    // 预热配置缓存
+                    Artisan::call('config:cache');
+                    return ['status' => 'success', 'message' => '配置缓存预热成功'];
+                    
+                case CACHE_TYPE::ROUTE:
+                    // 预热路由缓存
+                    Artisan::call('route:cache');
+                    return ['status' => 'success', 'message' => '路由缓存预热成功'];
+                    
+                case CACHE_TYPE::VIEW:
+                    // 预热视图缓存
+                    Artisan::call('view:cache');
+                    return ['status' => 'success', 'message' => '视图缓存预热成功'];
+                    
+                case CACHE_TYPE::EVENT:
+                    // 预热事件缓存
+                    Artisan::call('event:cache');
+                    return ['status' => 'success', 'message' => '事件缓存预热成功'];
+                    
+                default:
+                    return ['status' => 'skipped', 'message' => '该类型缓存不支持预热'];
+            }
+        } catch (\Exception $e) {
+            return ['status' => 'error', 'message' => $e->getMessage()];
+        }
+    }
+
+    /**
+     * 获取缓存大小信息
+     *
+     * @return array
+     */
+    public function getSizeInfo(): array
+    {
+        try {
+            // 这里可以根据不同的缓存驱动实现大小统计
+            // 目前返回基本信息
+            return [
+                'driver' => config('cache.default'),
+                'message' => '缓存大小统计功能待实现',
+            ];
+        } catch (\Exception $e) {
+            return [
+                'error' => $e->getMessage(),
+            ];
+        }
+    }
+}

+ 305 - 0
app/Module/Admin/Utils/SystemInfo.php

@@ -0,0 +1,305 @@
+<?php
+
+namespace App\Module\Admin\Utils;
+
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 系统信息工具类
+ */
+class SystemInfo
+{
+    /**
+     * 获取服务器信息
+     *
+     * @return array
+     */
+    public function getServerInfo(): array
+    {
+        return [
+            'os' => php_uname('s'),
+            'os_version' => php_uname('r'),
+            'hostname' => php_uname('n'),
+            'architecture' => php_uname('m'),
+            'server_software' => $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown',
+            'server_ip' => $_SERVER['SERVER_ADDR'] ?? 'Unknown',
+            'server_port' => $_SERVER['SERVER_PORT'] ?? 'Unknown',
+            'document_root' => $_SERVER['DOCUMENT_ROOT'] ?? 'Unknown',
+        ];
+    }
+
+    /**
+     * 获取PHP信息
+     *
+     * @return array
+     */
+    public function getPhpInfo(): array
+    {
+        return [
+            'version' => PHP_VERSION,
+            'sapi' => php_sapi_name(),
+            'memory_limit' => ini_get('memory_limit'),
+            'max_execution_time' => ini_get('max_execution_time'),
+            'upload_max_filesize' => ini_get('upload_max_filesize'),
+            'post_max_size' => ini_get('post_max_size'),
+            'timezone' => date_default_timezone_get(),
+            'extensions' => $this->getLoadedExtensions(),
+        ];
+    }
+
+    /**
+     * 获取已加载的PHP扩展
+     *
+     * @return array
+     */
+    protected function getLoadedExtensions(): array
+    {
+        $extensions = get_loaded_extensions();
+        sort($extensions);
+        return $extensions;
+    }
+
+    /**
+     * 获取数据库信息
+     *
+     * @return array
+     */
+    public function getDatabaseInfo(): array
+    {
+        try {
+            $connection = DB::connection();
+            $pdo = $connection->getPdo();
+            
+            return [
+                'driver' => $connection->getDriverName(),
+                'version' => $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION),
+                'database' => $connection->getDatabaseName(),
+                'charset' => $connection->getConfig('charset'),
+                'collation' => $connection->getConfig('collation'),
+                'prefix' => $connection->getConfig('prefix'),
+                'status' => 'connected',
+            ];
+        } catch (\Exception $e) {
+            return [
+                'status' => 'error',
+                'error' => $e->getMessage(),
+            ];
+        }
+    }
+
+    /**
+     * 获取内存使用情况
+     *
+     * @return array
+     */
+    public function getMemoryUsage(): array
+    {
+        $memoryUsage = memory_get_usage(true);
+        $memoryPeak = memory_get_peak_usage(true);
+        $memoryLimit = $this->parseMemoryLimit(ini_get('memory_limit'));
+        
+        return [
+            'current' => $this->formatBytes($memoryUsage),
+            'peak' => $this->formatBytes($memoryPeak),
+            'limit' => $this->formatBytes($memoryLimit),
+            'percentage' => $memoryLimit > 0 ? round(($memoryUsage / $memoryLimit) * 100, 2) : 0,
+            'current_bytes' => $memoryUsage,
+            'peak_bytes' => $memoryPeak,
+            'limit_bytes' => $memoryLimit,
+        ];
+    }
+
+    /**
+     * 解析内存限制
+     *
+     * @param string $memoryLimit
+     * @return int
+     */
+    protected function parseMemoryLimit(string $memoryLimit): int
+    {
+        if ($memoryLimit === '-1') {
+            return 0; // 无限制
+        }
+        
+        $unit = strtolower(substr($memoryLimit, -1));
+        $value = (int) substr($memoryLimit, 0, -1);
+        
+        switch ($unit) {
+            case 'g':
+                return $value * 1024 * 1024 * 1024;
+            case 'm':
+                return $value * 1024 * 1024;
+            case 'k':
+                return $value * 1024;
+            default:
+                return (int) $memoryLimit;
+        }
+    }
+
+    /**
+     * 格式化字节数
+     *
+     * @param int $bytes
+     * @return string
+     */
+    protected function formatBytes(int $bytes): string
+    {
+        if ($bytes === 0) {
+            return '0 B';
+        }
+        
+        $units = ['B', 'KB', 'MB', 'GB', 'TB'];
+        $power = floor(log($bytes, 1024));
+        
+        return round($bytes / pow(1024, $power), 2) . ' ' . $units[$power];
+    }
+
+    /**
+     * 获取磁盘使用情况
+     *
+     * @return array
+     */
+    public function getDiskUsage(): array
+    {
+        $path = base_path();
+        $totalBytes = disk_total_space($path);
+        $freeBytes = disk_free_space($path);
+        $usedBytes = $totalBytes - $freeBytes;
+        
+        return [
+            'total' => $this->formatBytes($totalBytes),
+            'used' => $this->formatBytes($usedBytes),
+            'free' => $this->formatBytes($freeBytes),
+            'percentage' => $totalBytes > 0 ? round(($usedBytes / $totalBytes) * 100, 2) : 0,
+            'total_bytes' => $totalBytes,
+            'used_bytes' => $usedBytes,
+            'free_bytes' => $freeBytes,
+        ];
+    }
+
+    /**
+     * 获取CPU使用率(Linux系统)
+     *
+     * @return float
+     */
+    public function getCpuUsage(): float
+    {
+        if (PHP_OS_FAMILY !== 'Linux') {
+            return 0.0;
+        }
+        
+        try {
+            $load = sys_getloadavg();
+            return $load ? round($load[0] * 100, 2) : 0.0;
+        } catch (\Exception $e) {
+            return 0.0;
+        }
+    }
+
+    /**
+     * 获取系统负载平均值
+     *
+     * @return array
+     */
+    public function getLoadAverage(): array
+    {
+        if (function_exists('sys_getloadavg')) {
+            $load = sys_getloadavg();
+            return [
+                '1min' => round($load[0], 2),
+                '5min' => round($load[1], 2),
+                '15min' => round($load[2], 2),
+            ];
+        }
+        
+        return [
+            '1min' => 0,
+            '5min' => 0,
+            '15min' => 0,
+        ];
+    }
+
+    /**
+     * 获取系统运行时间
+     *
+     * @return string
+     */
+    public function getUptime(): string
+    {
+        if (PHP_OS_FAMILY === 'Linux') {
+            try {
+                $uptime = file_get_contents('/proc/uptime');
+                $seconds = (int) explode(' ', $uptime)[0];
+                
+                $days = floor($seconds / 86400);
+                $hours = floor(($seconds % 86400) / 3600);
+                $minutes = floor(($seconds % 3600) / 60);
+                
+                return "{$days}天 {$hours}小时 {$minutes}分钟";
+            } catch (\Exception $e) {
+                return 'Unknown';
+            }
+        }
+        
+        return 'Unknown';
+    }
+
+    /**
+     * 获取数据库状态
+     *
+     * @return array
+     */
+    public function getDatabaseStatus(): array
+    {
+        try {
+            $startTime = microtime(true);
+            DB::select('SELECT 1');
+            $responseTime = round((microtime(true) - $startTime) * 1000, 2);
+            
+            return [
+                'status' => 'healthy',
+                'response_time' => $responseTime . 'ms',
+            ];
+        } catch (\Exception $e) {
+            return [
+                'status' => 'error',
+                'error' => $e->getMessage(),
+            ];
+        }
+    }
+
+    /**
+     * 获取性能指标
+     *
+     * @return array
+     */
+    public function getPerformanceMetrics(): array
+    {
+        return [
+            'memory' => $this->getMemoryUsage(),
+            'disk' => $this->getDiskUsage(),
+            'cpu_usage' => $this->getCpuUsage(),
+            'load_average' => $this->getLoadAverage(),
+            'database' => $this->getDatabaseStatus(),
+        ];
+    }
+
+    /**
+     * 获取Laravel应用信息
+     *
+     * @return array
+     */
+    public function getApplicationInfo(): array
+    {
+        return [
+            'name' => config('app.name'),
+            'env' => config('app.env'),
+            'debug' => config('app.debug'),
+            'url' => config('app.url'),
+            'timezone' => config('app.timezone'),
+            'locale' => config('app.locale'),
+            'laravel_version' => app()->version(),
+            'php_version' => PHP_VERSION,
+        ];
+    }
+}

+ 26 - 5
app/Module/README.md

@@ -4,7 +4,7 @@
 
 ## 模块概览
 
-开心农场系统采用模块化架构设计,将不同的业务功能拆分为独立的模块,每个模块负责特定的业务领域。系统共包含 **32个模块**,分为核心业务模块、基础服务模块、工具模块和扩展模块四大类。
+开心农场系统采用模块化架构设计,将不同的业务功能拆分为独立的模块,每个模块负责特定的业务领域。系统共包含 **33个模块**,分为核心业务模块、基础服务模块、工具模块和扩展模块四大类。
 
 ## 模块分类
 
@@ -164,11 +164,24 @@
 - **状态**: ✅ 已完成
 - **特点**: 不实现具体游戏逻辑,提供暂存系统等统筹功能
 
-### 🔧 基础服务模块 (7个)
+### 🔧 基础服务模块 (8个)
 
 提供系统基础功能和服务:
 
-#### 15. **System** - 系统模块
+#### 15. **Admin** - 后台基础功能扩展模块
+- **路径**: `app/Module/Admin`
+- **功能**: 扩展后台基础功能,提供通用的后台管理组件和工具
+- **状态**: ✅ 已完成
+- **核心功能**:
+  - 仪表板功能(系统概览、性能监控、快捷操作)
+  - 缓存管理(状态查看、清理操作、预热功能)
+  - 日志管理(操作记录、查看筛选、导出清理)
+  - 系统信息(服务器信息、PHP环境、数据库状态)
+  - 通用组件(表格辅助、表单辅助、小部件组件)
+  - 系统维护(维护操作、备份管理、性能优化)
+- **特点**: 专注后台基础功能,不处理具体业务逻辑,为其他模块提供通用组件
+
+#### 16. **System** - 系统模块
 - **路径**: `app/Module/System`
 - **功能**: 系统基础功能
 - **状态**: ✅ 已完成
@@ -243,7 +256,7 @@
 
 提供开发和运维工具:
 
-#### 22. **LCache** - 本地缓存模块
+#### 23. **LCache** - 本地缓存模块
 - **路径**: `app/Module/LCache`
 - **功能**: 本地缓存系统
 - **状态**: ✅ 已完成
@@ -305,6 +318,13 @@
 - 🚧 **开发中**: 模块正在开发中
 - ⏸️ **暂停**: 模块开发暂停
 
+## 模块状态分布
+
+- ✅ 已完成: 26个模块 (79%)
+- 🔧 基础功能: 2个模块 (6%)
+- 📋 文档阶段: 2个模块 (6%)
+- 其他: 3个模块 (9%)
+
 ## 模块依赖关系
 
 ### 核心依赖链
@@ -317,10 +337,11 @@ Fund + Point + Mex (资金层)
 User + Friend + Game (用户层)
-System + File + Notification + Sms + Mail + Push + OAuth (基础服务层)
+Admin + System + File + Notification + Sms + Mail + Push + OAuth (基础服务层)
 ```
 
 ### 重要依赖关系
+- **Admin模块**: 为所有模块提供后台基础功能和通用组件,依赖System、File、User模块
 - **GameItems模块**: 被Farm、Pet、Shop、Activity、Task等模块依赖
 - **Fund模块**: 被Mex、Shop、Activity等模块依赖,提供资金管理
 - **Point模块**: 基于Fund模块架构,专门处理积分