From 29e364f74a19b74efc410492afa75bf2628c374e Mon Sep 17 00:00:00 2001 From: leon <916117771@qq.com> Date: Wed, 22 Apr 2026 00:01:20 +0800 Subject: [PATCH] feat: add comprehensive dashboard showing all analysis metrics in one view --- application/admin/controller/History.php | 21 +++- application/admin/lang/zh-cn/history.php | 1 + application/admin/model/History.php | 16 +++ application/admin/view/history/index.html | 1 + public/assets/js/backend/history.js | 142 ++++++++++++++++++++++ 5 files changed, 180 insertions(+), 1 deletion(-) diff --git a/application/admin/controller/History.php b/application/admin/controller/History.php index f640245..dc1f0b0 100644 --- a/application/admin/controller/History.php +++ b/application/admin/controller/History.php @@ -22,7 +22,7 @@ class History extends Backend * 无需额外权限检查的方法(但仍在 admin 模块内,需要 admin 登录) * @var array */ - protected $noNeedRight = ['missingNum', 'trendData', 'hotColdNumbers', 'colorWaveAnalysis', 'zodiacAnalysis', 'oddEvenAnalysis', 'bigSmallAnalysis', 'sumAnalysis', 'consecutiveNumbers', 'tailNumbers']; + protected $noNeedRight = ['missingNum', 'trendData', 'hotColdNumbers', 'colorWaveAnalysis', 'zodiacAnalysis', 'oddEvenAnalysis', 'bigSmallAnalysis', 'sumAnalysis', 'consecutiveNumbers', 'tailNumbers', 'dashboard']; public function _initialize() { @@ -217,5 +217,24 @@ class History extends Backend } } + /** + * 综合统计面板 + */ + public function dashboard() + { + if ($this->request->isAjax()) { + $periods = $this->request->get('periods', 30, 'intval'); + if ($periods < 10 || $periods > 100) { + $this->error('期数范围必须在 10-100 之间'); + } + $type = $this->request->get('type', 'all'); + if (!in_array($type, ['all', 'special'])) { + $this->error('查询类型不正确'); + } + $result = $this->model->getDashboardData($periods, $type); + $this->success('查询成功', null, $result); + } + } + } diff --git a/application/admin/lang/zh-cn/history.php b/application/admin/lang/zh-cn/history.php index 5d2cbd0..84a9f1a 100644 --- a/application/admin/lang/zh-cn/history.php +++ b/application/admin/lang/zh-cn/history.php @@ -25,4 +25,5 @@ return [ 'Sum Chart' => '和值分析', 'Consecutive' => '连号分析', 'Tail Numbers' => '尾数分析', + 'Dashboard' => '综合统计面板', ]; diff --git a/application/admin/model/History.php b/application/admin/model/History.php index 5d7b4c1..6b2827a 100644 --- a/application/admin/model/History.php +++ b/application/admin/model/History.php @@ -446,5 +446,21 @@ class History extends Model return ['all' => $all]; } + /** + * 综合统计面板 + */ + public function getDashboardData($periods = 30, $type = 'all') + { + return [ + 'hotcold' => $this->getHotColdNumbers($periods, $type), + 'colorwave' => $this->getColorWaveAnalysis($periods, $type), + 'zodiac' => $this->getZodiacAnalysis($periods, $type), + 'oddeven' => $this->getOddEvenAnalysis($periods, $type), + 'bigsmall' => $this->getBigSmallAnalysis($periods, $type), + 'sum' => $this->getSumAnalysis($periods), + 'tailnumbers' => $this->getTailNumbers($periods, $type) + ]; + } + } diff --git a/application/admin/view/history/index.html b/application/admin/view/history/index.html index 55c09d0..44ff12c 100644 --- a/application/admin/view/history/index.html +++ b/application/admin/view/history/index.html @@ -17,6 +17,7 @@ {:__('Sum Chart')} {:__('Consecutive')} {:__('Tail Numbers')} + {:__('Dashboard')} ' + + ' ' + + ' ' + + ' ' + + '' + + '
' + + ''; + + Layer.open({ + type: 1, + title: __('Dashboard'), + area: ['90%', '90%'], + content: html, + shadeClose: false, + maxmin: true, + success: function (layero, index) { + $('#btn-dash-query', layero).on('click', function () { + var periods = parseInt($('#dash-periods', layero).val()) || 30; + Controller.api.queryDashboard(periods, layero); + }); + } + }); + }, + + queryDashboard: function (periods, layero) { + var $btn = $('#btn-dash-query', layero); + $btn.prop('disabled', true); + $('#dash-result', layero).html('
' + __('Loading') + '
'); + $.ajax({ + url: 'history/dashboard', + type: 'GET', + data: {periods: periods}, + dataType: 'json', + success: function (ret) { + if (ret.code == 1) { + Controller.api.renderDashboard(ret.data, layero); + } else { + $('#dash-result', layero).html('
' + (ret.msg || __('Query failed')) + '
'); + } + }, + error: function () { + $('#dash-result', layero).html('
' + __('Query failed') + '
'); + }, + complete: function () { + $btn.prop('disabled', false); + } + }); + }, + + renderDashboard: function (data, layero) { + var getColor = function (color) { + if (!color) return '#95a5a6'; + if (color.indexOf('红') !== -1) return '#e74c3c'; + if (color.indexOf('蓝') !== -1) return '#3498db'; + if (color.indexOf('绿') !== -1) return '#2ecc71'; + return '#95a5a6'; + }; + + var hc = data.hotcold; + var cw = data.colorwave; + var zo = data.zodiac; + var oe = data.oddeven; + var bs = data.bigsmall; + var sm = data.sum; + var tn = data.tailnumbers; + + var ballHtml = function (item) { + return '
' + item.num + '
' + item.count + '
'; + }; + + var html = '
'; + + // 冷热号码 + html += '

🔥❄️ 冷热号码

'; + html += '
热号 Top5
'; + for (var i = 0; i < 5; i++) html += ballHtml(hc.hot[i]); + html += '
冷号 Top5
'; + for (var i = 0; i < 5; i++) html += ballHtml(hc.cold[i]); + html += '
'; + + // 波色分析 + html += '

🎨 波色比例

'; + html += '
'; + html += '
' + cw.red + '
红波 ' + cw.red_pct + '%
'; + html += '
' + cw.blue + '
蓝波 ' + cw.blue_pct + '%
'; + html += '
' + cw.green + '
绿波 ' + cw.green_pct + '%
'; + html += '
'; + + // 生肖分析 + html += '

⭐ 生肖排名

'; + html += '
'; + for (var i = 0; i < Math.min(zo.list.length, 12); i++) { + var z = zo.list[i]; + html += '
' + z.animal + '
' + z.count + ' (' + z.percent + '%)
'; + } + html += '
'; + + // 奇偶分析 + html += '

⚖️ 奇偶分析

'; + html += '
'; + html += '
' + oe.odd + ' (' + oe.odd_pct + '%)
奇数
'; + html += '
' + oe.even + ' (' + oe.even_pct + '%)
偶数
'; + html += '
'; + + // 大小分析 + html += '

📊 大小分析

'; + html += '
'; + html += '
' + bs.big + ' (' + bs.big_pct + '%)
大数(25-49)
'; + html += '
' + bs.small + ' (' + bs.small_pct + '%)
小数(1-24)
'; + html += '
'; + + // 和值 + html += '

📈 和值统计

'; + html += '
'; + html += '
' + sm.avg + '
平均
'; + html += '
' + sm.max + '
最大
'; + html += '
' + sm.min + '
最小
'; + html += '
'; + + // 尾数 + html += '

🔢 尾数频率

'; + html += '
'; + for (var i = 0; i < tn.all.length; i++) { + var t = tn.all[i]; + html += '
' + t.tail + '
' + t.count + ' (' + t.percent + '%)
'; + } + html += '
'; + + html += '
'; + $('#dash-result', layero).html(html); } } };