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 = '
| 操作 | '; $html .= '管理员 | '; $html .= '时间 | '; $html .= 'IP地址 | '; $html .= '
|---|---|---|---|
| {$action['description']} | "; $html .= "{$action['admin_name']} | "; $html .= "{$action['timestamp']} | "; $html .= "{$action['ip_address']} | "; $html .= '