From 074aa4d677ea6a9a7b66cd4c99e1cc44d605daa2 Mon Sep 17 00:00:00 2001 From: leon <916117771@qq.com> Date: Wed, 22 Apr 2026 00:07:10 +0800 Subject: [PATCH] fix: rewrite dashboard JS as proper RequireJS module, remove inline script --- application/admin/view/dashboard/index.html | 123 -------------- public/assets/js/backend/dashboard.js | 173 ++++++++++++-------- 2 files changed, 105 insertions(+), 191 deletions(-) diff --git a/application/admin/view/dashboard/index.html b/application/admin/view/dashboard/index.html index 215e172..977aa53 100644 --- a/application/admin/view/dashboard/index.html +++ b/application/admin/view/dashboard/index.html @@ -30,126 +30,3 @@ - diff --git a/public/assets/js/backend/dashboard.js b/public/assets/js/backend/dashboard.js index ab8409c..75d468e 100644 --- a/public/assets/js/backend/dashboard.js +++ b/public/assets/js/backend/dashboard.js @@ -1,78 +1,115 @@ -define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) { - +define(['jquery'], function ($) { var Controller = { index: function () { - // 基于准备好的dom,初始化echarts实例 - var myChart = Echarts.init(document.getElementById('echart'), 'walden'); - - // 指定图表的配置项和数据 - var option = { - title: { - text: '', - subtext: '' - }, - color: [ - "#18d1b1", - "#3fb1e3", - "#626c91", - "#a0a7e6", - "#c4ebad", - "#96dee8" - ], - tooltip: { - trigger: 'axis' - }, - legend: { - data: [__('Register user')] - }, - toolbox: { - show: false, - feature: { - magicType: {show: true, type: ['stack', 'tiled']}, - saveAsImage: {show: true} - } - }, - xAxis: { - type: 'category', - boundaryGap: false, - data: Config.column - }, - yAxis: {}, - grid: [{ - left: 'left', - top: 'top', - right: '10', - bottom: 30 - }], - series: [{ - name: __('Register user'), - type: 'line', - smooth: true, - areaStyle: { - normal: {} - }, - lineStyle: { - normal: { - width: 1.5 - } - }, - data: Config.userdata - }] + var getColor = function (color) { + if (!color || color === '—') return '#95a5a6'; + if (color.indexOf('红') !== -1) return '#e74c3c'; + if (color.indexOf('蓝') !== -1) return '#3498db'; + if (color.indexOf('绿') !== -1) return '#2ecc71'; + return '#95a5a6'; }; - // 使用刚指定的配置项和数据显示图表。 - myChart.setOption(option); + var ball = function (num, color) { + return '' + num + ''; + }; - $(window).resize(function () { - myChart.resize(); - }); + function loadData() { + var periods = parseInt($('#dash-periods').val()) || 30; + if (periods < 10) periods = 10; + if (periods > 100) periods = 100; + $('#dash-content').html('