diff --git a/app/admin/controller/Article.php b/app/admin/controller/ArticlesController.php similarity index 86% rename from app/admin/controller/Article.php rename to app/admin/controller/ArticlesController.php index f6c1053..bcdee73 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/ArticlesController.php @@ -11,7 +11,7 @@ use think\facade\Request; use app\admin\controller\Log; use app\admin\controller\BaseController; -class Article extends BaseController +class ArticlesController extends BaseController { /** * 获取控制器名称 @@ -428,16 +428,64 @@ class Article extends BaseController //统计文章数量 public function counts() { - $total = Articles::where('delete_time', null) - ->where('status', '<>', 3) - ->count(); + try { + // 获取文章总数 + $total = Articles::where('delete_time', null) + ->where('status', '<>', 3) + ->count(); + + // 获取今日新增文章数 + $today = strtotime(date('Y-m-d')); + $todayNew = Articles::where('delete_time', null) + ->where('status', '<>', 3) + ->where('create_time', '>=', $today) + ->count(); + + // 获取最近7天的文章数据 + $dates = []; + $counts = []; + $totalCounts = []; // 存储每天的总文章数 + $totalSoFar = 0; // 用于累计总文章数 - return json([ - 'code' => 0, - 'msg' => '获取成功', - 'data' => [ - 'total' => $total - ] - ]); + for ($i = 6; $i >= 0; $i--) { + $date = date('Y-m-d', strtotime("-$i days")); + $start = strtotime($date); + $end = $start + 86400; + + // 获取当天新增文章数 + $count = Articles::where('delete_time', null) + ->where('status', '<>', 3) + ->where('create_time', '>=', $start) + ->where('create_time', '<', $end) + ->count(); + + // 获取截至当天的总文章数 + $totalCount = Articles::where('delete_time', null) + ->where('status', '<>', 3) + ->where('create_time', '<', $end) + ->count(); + + $dates[] = $date; + $counts[] = $count; + $totalCounts[] = $totalCount; + } + + return json([ + 'code' => 0, + 'msg' => '获取成功', + 'data' => [ + 'total' => $total, + 'todayNew' => $todayNew, + 'dates' => $dates, + 'counts' => $counts, + 'totalCounts' => $totalCounts + ] + ]); + } catch (\Exception $e) { + return json([ + 'code' => 1, + 'msg' => '获取失败:' . $e->getMessage() + ]); + } } } \ No newline at end of file diff --git a/app/admin/controller/Index.php b/app/admin/controller/IndexController.php similarity index 84% rename from app/admin/controller/Index.php rename to app/admin/controller/IndexController.php index 4f29bb4..994cfb2 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/IndexController.php @@ -4,18 +4,25 @@ */ namespace app\admin\controller; use app\admin\controller\Base; +use app\admin\model\DailyStats; +use app\admin\model\Log\LogsOperation; +use app\index\model\Attachments; use think\facade\Db; use think\facade\View; use think\facade\Env; use think\facade\Config; +use app\admin\controller\Log; -class Index extends Base{ +use app\admin\model\AdminUserGroup; +use app\admin\model\AdminSysMenu; + +class IndexController extends Base{ # 首页 public function index(){ $menus = []; $menu = []; $where = ['group_id'=>$this->aUser['group_id']]; - $role = Db::name('admin_user_group')->where($where)->find(); + $role = AdminUserGroup::where($where)->find(); if($role){ $role['rights'] = (isset($role['rights']) && $role['rights']) ? json_decode($role['rights'],true) : []; } @@ -25,7 +32,7 @@ class Index extends Base{ ['status','=',1] ]; // 获取所有菜单 - $menus = Db::name('admin_sys_menu')->order('type,sort desc')->where($where)->select()->toArray(); + $menus = AdminSysMenu::order('type,sort desc')->where($where)->select()->toArray(); // 构建树形结构菜单 $menuTree = []; @@ -63,21 +70,18 @@ class Index extends Base{ public function welcome(){ // 获取今日统计数据 $today = date('Y-m-d'); - $todayStats = Db::name('daily_stats') - ->where('date', $today) + $todayStats = DailyStats::where('date', $today) ->find(); // 获取最近7天的访问趋势 - $last7Days = Db::name('daily_stats') - ->where('date', '>=', date('Y-m-d', strtotime('-7 days'))) + $last7Days = DailyStats::where('date', '>=', date('Y-m-d', strtotime('-7 days'))) ->where('date', '<=', $today) ->order('date', 'asc') ->select() ->toArray(); // 获取用户增长趋势 - $userGrowth = Db::name('daily_stats') - ->where('date', '>=', date('Y-m-d', strtotime('-30 days'))) + $userGrowth = DailyStats::where('date', '>=', date('Y-m-d', strtotime('-30 days'))) ->where('date', '<=', $today) ->field('date, new_users, total_users') ->order('date', 'asc') @@ -85,8 +89,7 @@ class Index extends Base{ ->toArray(); // 获取资源下载统计 - $resourceStats = Db::name('daily_stats') - ->where('date', '>=', date('Y-m-d', strtotime('-7 days'))) + $resourceStats = DailyStats::where('date', '>=', date('Y-m-d', strtotime('-7 days'))) ->where('date', '<=', $today) ->field('date, daily_resources, resource_downloads') ->order('date', 'asc') @@ -94,16 +97,26 @@ class Index extends Base{ ->toArray(); // 获取文章访问统计 - $articleStats = Db::name('daily_stats') - ->where('date', '>=', date('Y-m-d', strtotime('-7 days'))) + $articleStats = DailyStats::where('date', '>=', date('Y-m-d', strtotime('-7 days'))) ->where('date', '<=', $today) ->field('date, daily_articles, article_views') ->order('date', 'asc') ->select() ->toArray(); - // 获取最近的活动记录 - $recentActivities = $this->getRecentActivities(); + // 获取最近的操作日志 + $recentActivities = LogsOperation::field('operation_time, module, operation') + ->order('operation_time desc') + ->limit(10) + ->select() + ->each(function($item) { + // 格式化时间 + $item['time'] = date('Y年m月d日 H:i:s', strtotime($item['operation_time'])); + // 格式化操作内容 + $item['content'] = date('Y年m月d日 H:i:s', strtotime($item['operation_time'])) . '在【' . $item['module'] . '】模块进行操作:' . $item['operation']; + return $item; + }); + // 准备图表数据 $chartData = [ @@ -129,50 +142,21 @@ class Index extends Base{ } /** - * 获取最近的活动记录 + * 根据操作类型获取对应的图标 */ - private function getRecentActivities() + private function getActivityIcon($type) { - $today = date('Y-m-d'); - $activities = []; - - // 获取今日新用户 - $newUsers = Db::name('daily_stats') - ->where('date', $today) - ->value('new_users'); - if ($newUsers > 0) { - $activities[] = [ - 'icon' => '👥', - 'title' => '新增用户 ' . $newUsers . ' 人', - 'time' => '今日' - ]; - } - - // 获取今日文章 - $newArticles = Db::name('daily_stats') - ->where('date', $today) - ->value('daily_articles'); - if ($newArticles > 0) { - $activities[] = [ - 'icon' => '📝', - 'title' => '发布文章 ' . $newArticles . ' 篇', - 'time' => '今日' - ]; - } - - // 获取今日资源 - $newResources = Db::name('daily_stats') - ->where('date', $today) - ->value('daily_resources'); - if ($newResources > 0) { - $activities[] = [ - 'icon' => '📦', - 'title' => '上传资源 ' . $newResources . ' 个', - 'time' => '今日' - ]; - } - - return $activities; + $icons = [ + '用户管理' => '👥', + '文章管理' => '📝', + '资源管理' => '📦', + '系统设置' => '⚙️', + '登录' => '🔑', + '退出' => '🚪', + '其他' => '📌' + ]; + + return $icons[$type] ?? '📌'; } /** @@ -280,7 +264,7 @@ class Index extends Base{ 'create_time' => time(), 'update_time' => time() ]; - return Db::name('attachments')->insertGetId($data); + return Attachments::insertGetId($data); } # 图片上传 diff --git a/app/admin/controller/Log.php b/app/admin/controller/LogController.php similarity index 99% rename from app/admin/controller/Log.php rename to app/admin/controller/LogController.php index cf491fb..60c0c62 100644 --- a/app/admin/controller/Log.php +++ b/app/admin/controller/LogController.php @@ -9,7 +9,7 @@ use think\facade\Cookie; use app\admin\model\Log\LogsLogin; use app\admin\model\Log\LogsOperation; -class Log extends Base +class LogController extends Base { /** * 登录日志列表 diff --git a/app/admin/controller/Login.php b/app/admin/controller/LoginController.php similarity index 95% rename from app/admin/controller/Login.php rename to app/admin/controller/LoginController.php index 472249b..b3ae2a6 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/LoginController.php @@ -13,10 +13,10 @@ use app\admin\model\YzAdminConfig; use app\admin\model\AdminUser; use app\admin\model\Log\LogsLogin; -class Login +class LoginController extends Base { - protected $app; - protected $config; + public $app; + public $config; public function __construct(App $app) { @@ -36,7 +36,7 @@ class Login } // 记录登录日志 - protected function recordLoginLog($username, $status, $reason = '') + public function recordLoginLog($username, $status, $reason = '') { $data = [ 'username' => $username, @@ -52,14 +52,14 @@ class Login } // 获取IP地址位置 - protected function getLocation($ip) + public function getLocation($ip) { // 这里可以接入IP地址库或第三方API return '未知'; } // 获取设备类型 - protected function getDeviceType() + public function getDeviceType() { $agent = Request::header('user-agent'); if (preg_match('/(iPhone|iPod|Android|ios|iPad|Mobile)/i', $agent)) { diff --git a/app/admin/controller/Resources.php b/app/admin/controller/ResourcesController.php similarity index 86% rename from app/admin/controller/Resources.php rename to app/admin/controller/ResourcesController.php index 9e29b2c..cb618e1 100644 --- a/app/admin/controller/Resources.php +++ b/app/admin/controller/ResourcesController.php @@ -12,7 +12,7 @@ use think\facade\Db; use app\admin\controller\Log; use think\App; -class Resources extends BaseController +class ResourcesController extends BaseController { // 资源列表 public function lists() @@ -370,16 +370,64 @@ class Resources extends BaseController //统计资源数量 public function counts() { - $total = Resource::where('delete_time', null) - ->where('status', '<>', 3) - ->count(); - return json([ - 'code' => 0, - 'msg' => '获取成功', - 'data' => [ - 'total' => $total - ] - ]); + try { + // 获取资源总数 + $total = Resource::where('delete_time', null) + ->where('status', '<>', 3) + ->count(); + + // 获取今日新增资源数 + $today = strtotime(date('Y-m-d')); + $todayNew = Resource::where('delete_time', null) + ->where('status', '<>', 3) + ->where('create_time', '>=', $today) + ->count(); + + // 获取最近7天的资源数据 + $dates = []; + $counts = []; + $totalCounts = []; // 存储每天的总资源数 + + for ($i = 6; $i >= 0; $i--) { + $date = date('Y-m-d', strtotime("-$i days")); + $start = strtotime($date); + $end = $start + 86400; + + // 获取当天新增资源数 + $count = Resource::where('delete_time', null) + ->where('status', '<>', 3) + ->where('create_time', '>=', $start) + ->where('create_time', '<', $end) + ->count(); + + // 获取截至当天的总资源数 + $totalCount = Resource::where('delete_time', null) + ->where('status', '<>', 3) + ->where('create_time', '<', $end) + ->count(); + + $dates[] = $date; + $counts[] = $count; + $totalCounts[] = $totalCount; + } + + return json([ + 'code' => 0, + 'msg' => '获取成功', + 'data' => [ + 'total' => $total, + 'todayNew' => $todayNew, + 'dates' => $dates, + 'counts' => $counts, + 'totalCounts' => $totalCounts + ] + ]); + } catch (\Exception $e) { + return json([ + 'code' => 1, + 'msg' => '获取失败:' . $e->getMessage() + ]); + } } // 构建树形结构 diff --git a/app/admin/controller/UsersController.php b/app/admin/controller/UsersController.php new file mode 100644 index 0000000..7e8feb6 --- /dev/null +++ b/app/admin/controller/UsersController.php @@ -0,0 +1,81 @@ +where('status', 1) + ->count(); + + // 获取今日新增用户数 + $today = strtotime(date('Y-m-d')); + $todayNew = Users::where('delete_time', 0) + ->where('status', 1) + ->where('create_time', '>=', $today) + ->count(); + + // 获取最近7天的用户数据 + $dates = []; + $counts = []; + $totalCounts = []; // 存储每天的总用户数 + + for ($i = 6; $i >= 0; $i--) { + $date = date('Y-m-d', strtotime("-$i days")); + $start = strtotime($date); + $end = $start + 86400; + + // 获取当天新增用户数 + $count = Users::where('delete_time', 0) + ->where('status', 1) + ->where('create_time', '>=', $start) + ->where('create_time', '<', $end) + ->count(); + + // 获取截至当天的总用户数 + $totalCount = Users::where('delete_time', 0) + ->where('status', 1) + ->where('create_time', '<', $end) + ->count(); + + $dates[] = $date; + $counts[] = $count; + $totalCounts[] = $totalCount; + } + + return json([ + 'code' => 0, + 'msg' => '获取成功', + 'data' => [ + 'total' => $total, + 'todayNew' => $todayNew, + 'dates' => $dates, + 'counts' => $counts, + 'totalCounts' => $totalCounts + ] + ]); + } catch (\Exception $e) { + return json([ + 'code' => 1, + 'msg' => '获取失败:' . $e->getMessage() + ]); + } + } +} \ No newline at end of file diff --git a/app/admin/controller/Yunzer.php b/app/admin/controller/YunzerController.php similarity index 99% rename from app/admin/controller/Yunzer.php rename to app/admin/controller/YunzerController.php index 08ace06..34dbf24 100644 --- a/app/admin/controller/Yunzer.php +++ b/app/admin/controller/YunzerController.php @@ -14,7 +14,7 @@ use app\admin\model\AdminUserGroup; use app\admin\model\AdminConfig; use app\admin\model\ZIconfont; -class Yunzer extends Base{ +class YunzerController extends Base{ # 菜单列表 public function menuinfo(){ $lists = AdminSysMenu::where('parent_id', 0)->order('sort DESC,smid DESC')->select(); diff --git a/app/admin/controller/Yunzeradmin.php b/app/admin/controller/YunzeradminController.php similarity index 99% rename from app/admin/controller/Yunzeradmin.php rename to app/admin/controller/YunzeradminController.php index 1df2918..53431c2 100644 --- a/app/admin/controller/Yunzeradmin.php +++ b/app/admin/controller/YunzeradminController.php @@ -11,7 +11,7 @@ use app\admin\model\AdminUser; use app\admin\model\Banner; -class Yunzeradmin extends Base +class YunzeradminController extends Base { // 角色列表 public function groupinfo() diff --git a/app/admin/model/ApiKey.php b/app/admin/model/ApiKey.php new file mode 100644 index 0000000..35a0f93 --- /dev/null +++ b/app/admin/model/ApiKey.php @@ -0,0 +1,8 @@ +顶级分类'); // 获取所有分类作为父级选项 $.ajax({ - url: '/admin/article/articlecate', + url: '/admin/articles/articlecate', type: 'POST', async: false, success: function (res) { @@ -472,7 +472,7 @@ // 监听表单提交 form.on('submit(saveCategory)', function (data) { - var url = data.field.id ? '/admin/article/cateedit' : '/admin/article/cateadd'; + var url = data.field.id ? '/admin/articles/cateedit' : '/admin/articles/cateadd'; $.post(url, data.field, function (res) { if (res.code === 0) { layer.msg(res.msg, { icon: 1 }); @@ -490,7 +490,7 @@ if (!id) return; layer.confirm('确定要删除该分类吗?', function (index) { - $.post('/admin/article/catedel', { id: id }, function (res) { + $.post('/admin/articles/catedel', { id: id }, function (res) { if (res.code === 0) { layer.msg(res.msg, { icon: 1 }); that.initCategoryList(); diff --git a/app/admin/view/article/articlelist.php b/app/admin/view/articles/articlelist.php similarity index 96% rename from app/admin/view/article/articlelist.php rename to app/admin/view/articles/articlelist.php index 88cb3da..4477daa 100644 --- a/app/admin/view/article/articlelist.php +++ b/app/admin/view/articles/articlelist.php @@ -87,7 +87,7 @@ // 初始化表格 table.render({ elem: '#articleTable', - url: '/admin/article/articlelist', + url: '/admin/articles/articlelist', method: 'post', cols: [[ { field: 'id', title: 'ID', align: 'center', width: 80 }, @@ -174,18 +174,18 @@ } function add() { - window.location.href = '/admin/article/add'; + window.location.href = '/admin/articles/add'; } function edit(id) { - window.location.href = '/admin/article/edit?id=' + id; + window.location.href = '/admin/articles/edit?id=' + id; } function del(id) { layer.confirm('确定要删除该文章吗?', { btn: ['确定', '取消'] }, function () { - $.post('/admin/article/delete', { id: id }, function (res) { + $.post('/admin/articles/delete', { id: id }, function (res) { if (res.code == 0) { layer.msg(res.msg, { icon: 1 }); setTimeout(function () { diff --git a/app/admin/view/article/cateadd.php b/app/admin/view/articles/cateadd.php similarity index 100% rename from app/admin/view/article/cateadd.php rename to app/admin/view/articles/cateadd.php diff --git a/app/admin/view/article/cateedit.php b/app/admin/view/articles/cateedit.php similarity index 100% rename from app/admin/view/article/cateedit.php rename to app/admin/view/articles/cateedit.php diff --git a/app/admin/view/article/edit.php b/app/admin/view/articles/edit.php similarity index 100% rename from app/admin/view/article/edit.php rename to app/admin/view/articles/edit.php diff --git a/app/admin/view/index/welcome.php b/app/admin/view/index/welcome.php index 2fd19bf..45efed5 100644 --- a/app/admin/view/index/welcome.php +++ b/app/admin/view/index/welcome.php @@ -161,8 +161,7 @@ } .activity-title { font-weight: 500; - color: #1e293b; - margin-bottom: 4px; + color: #9b9b9b; } .activity-time { font-size: 12px; @@ -258,10 +257,9 @@
{volist name="recentActivities" id="activity"}
-
{$activity.icon}
+
{$activity.icon|default='📌'}
-
{$activity.title}
-
{$activity.time}
+
{$activity.content}
{/volist} @@ -314,6 +312,42 @@ function updateTime() { document.getElementById('current-time').innerHTML = timeString; } +// 获取用户统计数据 +function getUserCounts() { + fetch('{:url("users/counts")}') + .then(response => response.json()) + .then(res => { + console.log('用户统计接口返回数据:', res); + if (res.code === 0 && res.data) { + // 更新用户总数 + document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = res.data.total.toLocaleString(); + + // 更新用户增长图表 + if (window.userChart) { + window.userChart.setOption({ + xAxis: { + data: res.data.dates + }, + series: [{ + name: '新增用户', + data: res.data.counts + }, { + name: '总用户数', + data: res.data.totalCounts + }] + }); + } + } else { + console.warn('用户统计接口返回异常:', res); + document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = '0'; + } + }) + .catch(error => { + console.error('获取用户统计失败:', error); + document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = '0'; + }); +} + // 获取文章统计数据 function getArticleCounts() { fetch('{:url("articles/counts")}') @@ -323,12 +357,30 @@ function getArticleCounts() { if (res.code === 0 && res.data) { // 更新文章总数 document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = res.data.total.toLocaleString(); + + // 更新文章统计图表 + if (window.articleChart) { + window.articleChart.setOption({ + xAxis: { + data: res.data.dates + }, + series: [{ + name: '新增文章', + data: res.data.counts + }, { + name: '总文章数', + data: res.data.totalCounts + }] + }); + } } else { console.warn('文章统计接口返回异常:', res); + document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = '0'; } }) .catch(error => { console.error('获取文章统计失败:', error); + document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = '0'; }); } @@ -341,12 +393,30 @@ function getResourcesCounts() { if (res.code === 0 && res.data) { // 更新资源总数 document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = res.data.total.toLocaleString(); + + // 更新资源统计图表 + if (window.resourceChart) { + window.resourceChart.setOption({ + xAxis: { + data: res.data.dates + }, + series: [{ + name: '新增资源', + data: res.data.counts + }, { + name: '总资源数', + data: res.data.totalCounts + }] + }); + } } else { console.warn('资源统计接口返回异常:', res); + document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = '0'; } }) .catch(error => { console.error('获取资源统计失败:', error); + document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = '0'; }); } @@ -355,6 +425,7 @@ setInterval(updateTime, 1000); // 页面加载完成后获取统计数据 document.addEventListener('DOMContentLoaded', function() { + getUserCounts(); getArticleCounts(); getResourcesCounts(); }); @@ -433,6 +504,7 @@ function initVisitTrend() { // 用户增长图表 function initUserGrowth() { var chart = echarts.init(document.getElementById('userGrowth')); + window.userChart = chart; var option = { tooltip: { trigger: 'axis', @@ -455,7 +527,7 @@ function initUserGrowth() { xAxis: { type: 'category', boundaryGap: false, - data: {$chartData.userGrowth.dates|json_encode} + data: [] }, yAxis: { type: 'value' @@ -464,7 +536,7 @@ function initUserGrowth() { { name: '新增用户', type: 'bar', - data: {$chartData.userGrowth.newUsers|json_encode}, + data: [], itemStyle: { color: '#3881fd' } @@ -473,9 +545,12 @@ function initUserGrowth() { name: '总用户数', type: 'line', smooth: true, - data: {$chartData.userGrowth.totalUsers|json_encode}, + data: [], itemStyle: { color: '#10b981' + }, + lineStyle: { + width: 3 } } ] @@ -486,6 +561,7 @@ function initUserGrowth() { // 资源统计图表 function initResourceStats() { var chart = echarts.init(document.getElementById('resourceStats')); + window.resourceChart = chart; var option = { tooltip: { trigger: 'axis', @@ -497,7 +573,7 @@ function initResourceStats() { } }, legend: { - data: ['新增资源', '下载量'] + data: ['新增资源', '总资源数'] }, grid: { left: '3%', @@ -508,7 +584,7 @@ function initResourceStats() { xAxis: { type: 'category', boundaryGap: false, - data: {$chartData.resourceStats.dates|json_encode} + data: [] }, yAxis: { type: 'value' @@ -517,18 +593,21 @@ function initResourceStats() { { name: '新增资源', type: 'bar', - data: {$chartData.resourceStats.resources|json_encode}, + data: [], itemStyle: { color: '#3881fd' } }, { - name: '下载量', + name: '总资源数', type: 'line', smooth: true, - data: {$chartData.resourceStats.downloads|json_encode}, + data: [], itemStyle: { color: '#10b981' + }, + lineStyle: { + width: 3 } } ] @@ -539,6 +618,7 @@ function initResourceStats() { // 文章统计图表 function initArticleStats() { var chart = echarts.init(document.getElementById('articleStats')); + window.articleChart = chart; var option = { tooltip: { trigger: 'axis', @@ -550,7 +630,7 @@ function initArticleStats() { } }, legend: { - data: ['新增文章', '访问量'] + data: ['新增文章', '总文章数'] }, grid: { left: '3%', @@ -561,7 +641,7 @@ function initArticleStats() { xAxis: { type: 'category', boundaryGap: false, - data: {$chartData.articleStats.dates|json_encode} + data: [] }, yAxis: { type: 'value' @@ -570,18 +650,21 @@ function initArticleStats() { { name: '新增文章', type: 'bar', - data: {$chartData.articleStats.articles|json_encode}, + data: [], itemStyle: { color: '#3881fd' } }, { - name: '访问量', + name: '总文章数', type: 'line', smooth: true, - data: {$chartData.articleStats.views|json_encode}, + data: [], itemStyle: { color: '#10b981' + }, + lineStyle: { + width: 3 } } ] diff --git a/app/service/VisitStatsService.php b/app/service/VisitStatsService.php new file mode 100644 index 0000000..6800b53 --- /dev/null +++ b/app/service/VisitStatsService.php @@ -0,0 +1,133 @@ +redis = Cache::store('redis')->handler(); + } + + /** + * 记录访问并更新统计数据 + */ + public function recordVisit(string $page = 'home', string $userId = null): array + { + $date = date('Y-m-d'); + $hour = date('H'); + $userId = $userId ?? Request::ip(); + + // 使用管道提高性能 + $pipe = $this->redis->multi(); + + // 总访问量(PV) + $pipe->incr($this->prefix.'total_visits'); + + // 每日访问量 + $pipe->incr($this->prefix.'daily:'.$date); + + // 页面统计 + $pipe->zIncrBy($this->prefix.'page_views', 1, $page); + + // UV统计(使用HyperLogLog节省内存) + $pipe->pfAdd($this->prefix.'uv:'.$date, [$userId]); + + // 时段统计 + $pipe->hIncrBy($this->prefix.'hourly:'.$date, $hour, 1); + + // 执行所有命令 + $result = $pipe->exec(); + + // 更新数据库统计 + $this->updateDailyStats($date, [ + 'total_visits' => $result[0], + 'daily_visits' => $result[1], + 'unique_visitors' => $this->getUniqueVisitors($date) + ]); + + return [ + 'total' => $result[0], + 'daily' => $result[1], + 'page' => $result[2], + 'uv' => $result[3], + 'hourly'=> $result[4] + ]; + } + + /** + * 更新每日统计数据 + */ + protected function updateDailyStats(string $date, array $stats) + { + // 获取其他统计数据 + $otherStats = [ + 'total_users' => Db::name('users')->where('delete_time', null)->count(), + 'new_users' => Db::name('users')->whereDay('create_time', $date)->count(), + 'total_articles' => Db::name('articles')->where('delete_time', null)->count(), + 'daily_articles' => Db::name('articles')->whereDay('create_time', $date)->count(), + 'article_views' => Db::name('articles')->whereDay('update_time', $date)->sum('views'), + 'total_resources' => Db::name('resources')->where('delete_time', null)->count(), + 'daily_resources' => Db::name('resources')->whereDay('create_time', $date)->count(), + 'resource_downloads' => Db::name('resources')->whereDay('update_time', $date)->sum('downloads') + ]; + + // 合并统计数据 + $stats = array_merge($stats, $otherStats); + + // 更新或插入统计数据 + Db::name('daily_stats')->insertOrUpdate([ + 'date' => $date, + 'total_users' => $stats['total_users'], + 'new_users' => $stats['new_users'], + 'total_visits' => $stats['total_visits'], + 'daily_visits' => $stats['daily_visits'], + 'unique_visitors' => $stats['unique_visitors'], + 'total_articles' => $stats['total_articles'], + 'daily_articles' => $stats['daily_articles'], + 'article_views' => $stats['article_views'], + 'total_resources' => $stats['total_resources'], + 'daily_resources' => $stats['daily_resources'], + 'resource_downloads' => $stats['resource_downloads'] + ], ['date']); + } + + /** + * 获取总访问量 + */ + public function getTotalVisits(): int + { + return (int)$this->redis->get($this->prefix.'total_visits'); + } + + /** + * 获取当日访问量 + */ + public function getDailyVisits(string $date = null): int + { + $date = $date ?? date('Y-m-d'); + return (int)$this->redis->get($this->prefix.'daily:'.$date); + } + + /** + * 获取独立访客数(UV) + */ + public function getUniqueVisitors(string $date = null): int + { + $date = $date ?? date('Y-m-d'); + return $this->redis->pfCount($this->prefix.'uv:'.$date); + } + + /** + * 获取热门页面 + \ No newline at end of file diff --git a/config/cache.php b/config/cache.php index a8d69d2..d4c2158 100644 --- a/config/cache.php +++ b/config/cache.php @@ -14,9 +14,9 @@ return [ // 驱动方式 'type' => 'File', // 缓存保存目录 - 'path' => '', + 'path' => runtime_path() . 'cache', // 缓存前缀 - 'prefix' => '', + 'prefix' => 'cache_', // 缓存有效期 0表示永久缓存 'expire' => 0, // 缓存标签前缀 @@ -25,5 +25,23 @@ return [ 'serialize' => [], ], // 更多的缓存连接 + 'redis' => [ + // 驱动方式 + 'type' => 'redis', + // 服务器地址 + 'host' => env('redis.host', '127.0.0.1'), + // 端口 + 'port' => env('redis.port', 6379), + // 密码 + 'password' => env('redis.password', ''), + // 数据库索引 + 'select' => env('redis.select', 0), + // 连接超时时间 + 'timeout' => 0, + // 是否持久化连接 + 'persistent' => true, + // 缓存前缀 + 'prefix' => 'yz_:', + ], ], ]; diff --git a/runtime/admin/temp/02890b205219b043551566c44acd91e7.php b/runtime/admin/temp/02890b205219b043551566c44acd91e7.php deleted file mode 100644 index 689dbe2..0000000 --- a/runtime/admin/temp/02890b205219b043551566c44acd91e7.php +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - 后台管理系统 - - - - - - - - - -
- -
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/03e4ab61ce303403afa76cd64a82b52f.php b/runtime/admin/temp/03e4ab61ce303403afa76cd64a82b52f.php deleted file mode 100644 index bf53eec..0000000 --- a/runtime/admin/temp/03e4ab61ce303403afa76cd64a82b52f.php +++ /dev/null @@ -1,311 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - - - -
-
- 站点配置 - -
- -
- -
- -
- -
-
-
- -
- -
- -
-
-
-
- -
-
- -
- - -
- -
-
-
- - -
- -
- -
-
- - -
- -
- -
-
- - - - - \ No newline at end of file diff --git a/runtime/admin/temp/0bb846ef0dc9844f59dd163e5d6fca56.php b/runtime/admin/temp/0bb846ef0dc9844f59dd163e5d6fca56.php deleted file mode 100644 index 9d613fc..0000000 --- a/runtime/admin/temp/0bb846ef0dc9844f59dd163e5d6fca56.php +++ /dev/null @@ -1,49 +0,0 @@ - - - - - 跳转提示 - - - - -
- -

- -

- -

-
- - \ No newline at end of file diff --git a/runtime/admin/temp/0ca4cf5d689610e0c0dc92d8689bc694.php b/runtime/admin/temp/0ca4cf5d689610e0c0dc92d8689bc694.php deleted file mode 100644 index cb6d686..0000000 --- a/runtime/admin/temp/0ca4cf5d689610e0c0dc92d8689bc694.php +++ /dev/null @@ -1,205 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - - -
- 图标 -
-
-
-	
-	
-	
-	
-	
-	
-
- - - - - \ No newline at end of file diff --git a/runtime/admin/temp/0d3b17806247be3f9294dd993f5ff7bf.php b/runtime/admin/temp/0d3b17806247be3f9294dd993f5ff7bf.php deleted file mode 100644 index 8dee733..0000000 --- a/runtime/admin/temp/0d3b17806247be3f9294dd993f5ff7bf.php +++ /dev/null @@ -1,343 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - - -
- -
-
- - Banner管理 -
-
-
- - -
-
-
- -
-
-
-
-
-
-
- - - - -
- - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/10e05e3d82b5fc92954f2eaa74fca286.php b/runtime/admin/temp/10e05e3d82b5fc92954f2eaa74fca286.php deleted file mode 100644 index c17bc89..0000000 --- a/runtime/admin/temp/10e05e3d82b5fc92954f2eaa74fca286.php +++ /dev/null @@ -1,316 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- 演示列表-方法渲染 -
-
-
- -
- -
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/15ce02ee4fbe4bcbe1b70cd1c4c479ed.php b/runtime/admin/temp/15ce02ee4fbe4bcbe1b70cd1c4c479ed.php deleted file mode 100644 index 2e1a403..0000000 --- a/runtime/admin/temp/15ce02ee4fbe4bcbe1b70cd1c4c479ed.php +++ /dev/null @@ -1,277 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- -
- -
-
-
-
-
-
-
-
菜单结构
- -
-
-
- - - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - - - -
排序类型按钮名图标状态操作
- - 功能模块 - 超链接 - - - - 开启 - - 禁用 - - -
- - -
-
-
-
-
-
- - - - - \ No newline at end of file diff --git a/runtime/admin/temp/19f310fa6c5fb9bf679d1f5703436071.php b/runtime/admin/temp/19f310fa6c5fb9bf679d1f5703436071.php deleted file mode 100644 index e8818c3..0000000 --- a/runtime/admin/temp/19f310fa6c5fb9bf679d1f5703436071.php +++ /dev/null @@ -1,409 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - - - -
-
- 站点管理 - -
- - -
-
- - - -
-
-
-
- - - - - \ No newline at end of file diff --git a/runtime/admin/temp/1c825d7302c9198f86d61f24e6c74d99.php b/runtime/admin/temp/1c825d7302c9198f86d61f24e6c74d99.php deleted file mode 100644 index 64be6c3..0000000 --- a/runtime/admin/temp/1c825d7302c9198f86d61f24e6c74d99.php +++ /dev/null @@ -1,732 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - - - - -
-
-

欢迎使用

-

今天是 ,祝您工作愉快

-
- -
-
-
用户总数
-
-
👥
-
-
-
今日访问
-
-
📊
-
-
-
文章总数
-
-
📝
-
-
-
资源总数
-
-
📦
-
-
- - - -
-

最近动态

-
- $activity): $mod = ($i % 2 );++$i;?> -
-
-
-
-
-
-
- -
-
-
-
-

访问趋势

-
-
-
-

用户增长

-
-
-
-

资源统计

-
-
-
-

文章统计

-
-
-
-
- - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/223471353fa834ae2baca5b39cf40267.php b/runtime/admin/temp/223471353fa834ae2baca5b39cf40267.php deleted file mode 100644 index 82f2004..0000000 --- a/runtime/admin/temp/223471353fa834ae2baca5b39cf40267.php +++ /dev/null @@ -1,227 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- 演示列表-静态表格 - -
-
- - - - - - - - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - - - - - - - - -
ID文本富文本百度文本图片参照时间戳日期日期时间网址链接操作
- - - - 开启 - - 关闭 - - - - -
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/3233de1b9d870d17c8b51c0d13088c4b.php b/runtime/admin/temp/3233de1b9d870d17c8b51c0d13088c4b.php deleted file mode 100644 index 0dc2aae..0000000 --- a/runtime/admin/temp/3233de1b9d870d17c8b51c0d13088c4b.php +++ /dev/null @@ -1,177 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- -
- -
- -
-
-
- -
- > - > -
-
-
- - $vo): $mod = ($i % 2 );++$i;?> -
-
- > -
- $cvo): $mod = ($i % 2 );++$i;?> - > - -
- -
-
-
-
- -
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/33fe660e71fd18dda768b12bc1ec5aac.php b/runtime/admin/temp/33fe660e71fd18dda768b12bc1ec5aac.php deleted file mode 100644 index 96e57b2..0000000 --- a/runtime/admin/temp/33fe660e71fd18dda768b12bc1ec5aac.php +++ /dev/null @@ -1,379 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- 编辑文章 -
-
- -
-
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
-
-
-
- -
-
-
- -
- -
-
-
-
-
-
-
- -
-
- - - -
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/34d283a1bcbe58ecbdbcd3d1f0e36700.php b/runtime/admin/temp/34d283a1bcbe58ecbdbcd3d1f0e36700.php deleted file mode 100644 index 97841dd..0000000 --- a/runtime/admin/temp/34d283a1bcbe58ecbdbcd3d1f0e36700.php +++ /dev/null @@ -1,310 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
- 操作日志 -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - -
-
-
- -
-
-
- - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/3577c54c0ca6a5033f6739658aed0574.php b/runtime/admin/temp/3577c54c0ca6a5033f6739658aed0574.php deleted file mode 100644 index 1861d29..0000000 --- a/runtime/admin/temp/3577c54c0ca6a5033f6739658aed0574.php +++ /dev/null @@ -1,170 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - - \ No newline at end of file diff --git a/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php b/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php deleted file mode 100644 index 3222f65..0000000 --- a/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php +++ /dev/null @@ -1,426 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- 编辑资源 -
-
- -
-
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
-
-
-
- -
-
建议尺寸:128px * 128px
-
-
- -
- -
- -
- -
点击上传,或将文件拖拽到此处
-
-
-
- - - -
-
-
-
-
-
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- - -
-
-
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/413d41632850e6a39f16abf9573c9dfd.php b/runtime/admin/temp/413d41632850e6a39f16abf9573c9dfd.php deleted file mode 100644 index a85d64d..0000000 --- a/runtime/admin/temp/413d41632850e6a39f16abf9573c9dfd.php +++ /dev/null @@ -1,177 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- -
- -
- -
-
-
- -
- > - > -
-
-
- - $vo): $mod = ($i % 2 );++$i;?> -
-
- > -
- $cvo): $mod = ($i % 2 );++$i;?> - > - -
- -
-
-
-
- -
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php b/runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php deleted file mode 100644 index b597f10..0000000 --- a/runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php +++ /dev/null @@ -1,304 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- -
-
- - 资源列表 -
-
-
- -
-
- -
-
- -
-
- -
- - -
-
-
- - -
-
-
- -
-
- - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/4a16c5a5006908b0b790472a2898d2bf.php b/runtime/admin/temp/4a16c5a5006908b0b790472a2898d2bf.php deleted file mode 100644 index 40bde98..0000000 --- a/runtime/admin/temp/4a16c5a5006908b0b790472a2898d2bf.php +++ /dev/null @@ -1,368 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- 添加文章 -
-
- -
-
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
-
-
-
- -
-
-
- -
- -
-
-
-
-
-
-
- -
-
- - - -
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/533c54f343e8a61c5a95c12da17f30ac.php b/runtime/admin/temp/533c54f343e8a61c5a95c12da17f30ac.php deleted file mode 100644 index 1a3b501..0000000 --- a/runtime/admin/temp/533c54f343e8a61c5a95c12da17f30ac.php +++ /dev/null @@ -1,171 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- -
-
-
-
- - \ No newline at end of file diff --git a/runtime/admin/temp/57d210b0392c6ab0bf9a8c64d5dcfe4b.php b/runtime/admin/temp/57d210b0392c6ab0bf9a8c64d5dcfe4b.php deleted file mode 100644 index 0a59d76..0000000 --- a/runtime/admin/temp/57d210b0392c6ab0bf9a8c64d5dcfe4b.php +++ /dev/null @@ -1,241 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- -
-
- - 菜单管理 -
-
-
- - -
-
-
- -
- - - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - - - -
类型菜单名图标排序状态操作
- - 功能模块: - 超链接: - 顶级 - - 禁用'; ?> - - - - - -
- -
- - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/59fe0658cc9cd89331c4634f2d4b0bed.php b/runtime/admin/temp/59fe0658cc9cd89331c4634f2d4b0bed.php deleted file mode 100644 index 9359f02..0000000 --- a/runtime/admin/temp/59fe0658cc9cd89331c4634f2d4b0bed.php +++ /dev/null @@ -1,284 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- 添加资源 -
-
- -
-
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
-
-
-
- -
-
建议尺寸:128px * 128px
-
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- - -
-
-
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/5fcc0e440c64e4a69fa6ab9d4849f68a.php b/runtime/admin/temp/5fcc0e440c64e4a69fa6ab9d4849f68a.php deleted file mode 100644 index 2e17de5..0000000 --- a/runtime/admin/temp/5fcc0e440c64e4a69fa6ab9d4849f68a.php +++ /dev/null @@ -1,217 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
- -
- -
-
-
- -
- - -
-
-
-
-
- -
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/638faa80cf1298b7198f7a359b25bb22.php b/runtime/admin/temp/638faa80cf1298b7198f7a359b25bb22.php deleted file mode 100644 index 38095db..0000000 --- a/runtime/admin/temp/638faa80cf1298b7198f7a359b25bb22.php +++ /dev/null @@ -1,348 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- 添加资源 -
-
- -
-
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
-
-
-
- -
-
建议尺寸:128px * 128px
-
-
- -
- -
-
- -
点击上传,或将文件拖拽到此处
-
-
-
- - - -
-
-
-
-
-
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- - -
-
-
-
- - - - \ No newline at end of file diff --git a/runtime/admin/temp/6d989ddcae31ded7beac469198045d10.php b/runtime/admin/temp/6d989ddcae31ded7beac469198045d10.php deleted file mode 100644 index 20a0e26..0000000 --- a/runtime/admin/temp/6d989ddcae31ded7beac469198045d10.php +++ /dev/null @@ -1,409 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - - - -
-
- 站点管理 - -
- - -
-
- - - -
-
-
-
- - - - - \ No newline at end of file diff --git a/runtime/admin/temp/6f472d37a02e7e3b8a4ad0660ee03e89.php b/runtime/admin/temp/6f472d37a02e7e3b8a4ad0660ee03e89.php deleted file mode 100644 index 328d939..0000000 --- a/runtime/admin/temp/6f472d37a02e7e3b8a4ad0660ee03e89.php +++ /dev/null @@ -1,223 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
- -
-
- - 角色列表 -
-
-
- - -
-
-
- - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - -
角色名状态添加时间操作
禁用'; ?> - - -
- -
- - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/7013e3bcaaaa1c5a1494af79f99ce42f.php b/runtime/admin/temp/7013e3bcaaaa1c5a1494af79f99ce42f.php deleted file mode 100644 index 72987fd..0000000 --- a/runtime/admin/temp/7013e3bcaaaa1c5a1494af79f99ce42f.php +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
-
-
- -
- - -
-
- -
-
- - - -
-
- -
-
- -
- -
- -
-
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/705995d2a8e3fb66a54834e54543f090.php b/runtime/admin/temp/705995d2a8e3fb66a54834e54543f090.php deleted file mode 100644 index 9e2a71d..0000000 --- a/runtime/admin/temp/705995d2a8e3fb66a54834e54543f090.php +++ /dev/null @@ -1,252 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    -
    - 文章列表 -
    - -
    -
    - -
    -
    -
    -
    -
    - - -
    -
    - -
    -
    - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/766d6e3eeeea6e24fe0ab12371e8dfbf.php b/runtime/admin/temp/766d6e3eeeea6e24fe0ab12371e8dfbf.php deleted file mode 100644 index 36a33ca..0000000 --- a/runtime/admin/temp/766d6e3eeeea6e24fe0ab12371e8dfbf.php +++ /dev/null @@ -1,248 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - - \ No newline at end of file diff --git a/runtime/admin/temp/792969fb591a0f355761a1b3bf3d1226.php b/runtime/admin/temp/792969fb591a0f355761a1b3bf3d1226.php index 611a2bd..08fac6e 100644 --- a/runtime/admin/temp/792969fb591a0f355761a1b3bf3d1226.php +++ b/runtime/admin/temp/792969fb591a0f355761a1b3bf3d1226.php @@ -1,4 +1,4 @@ - + @@ -255,8 +255,7 @@ } .activity-title { font-weight: 500; - color: #1e293b; - margin-bottom: 4px; + color: #9b9b9b; } .activity-time { font-size: 12px; @@ -352,10 +351,9 @@
    $activity): $mod = ($i % 2 );++$i;?>
    -
    +
    -
    -
    +
    @@ -408,21 +406,75 @@ function updateTime() { document.getElementById('current-time').innerHTML = timeString; } +// 获取用户统计数据 +function getUserCounts() { + fetch('') + .then(response => response.json()) + .then(res => { + console.log('用户统计接口返回数据:', res); + if (res.code === 0 && res.data) { + // 更新用户总数 + document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = res.data.total.toLocaleString(); + + // 更新用户增长图表 + if (window.userChart) { + window.userChart.setOption({ + xAxis: { + data: res.data.dates + }, + series: [{ + name: '新增用户', + data: res.data.counts + }, { + name: '总用户数', + data: res.data.totalCounts + }] + }); + } + } else { + console.warn('用户统计接口返回异常:', res); + document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = '0'; + } + }) + .catch(error => { + console.error('获取用户统计失败:', error); + document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = '0'; + }); +} + // 获取文章统计数据 function getArticleCounts() { - fetch('') + fetch('') .then(response => response.json()) .then(res => { console.log('文章统计接口返回数据:', res); if (res.code === 0 && res.data) { // 更新文章总数 document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = res.data.total.toLocaleString(); + + // 更新文章统计图表 + if (window.articleChart) { + window.articleChart.setOption({ + xAxis: { + data: res.data.dates + }, + series: [{ + name: '新增文章', + data: res.data.counts + }, { + name: '总文章数', + data: res.data.totalCounts + }] + }); + } } else { console.warn('文章统计接口返回异常:', res); + document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = '0'; } }) .catch(error => { console.error('获取文章统计失败:', error); + document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = '0'; }); } @@ -435,12 +487,30 @@ function getResourcesCounts() { if (res.code === 0 && res.data) { // 更新资源总数 document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = res.data.total.toLocaleString(); + + // 更新资源统计图表 + if (window.resourceChart) { + window.resourceChart.setOption({ + xAxis: { + data: res.data.dates + }, + series: [{ + name: '新增资源', + data: res.data.counts + }, { + name: '总资源数', + data: res.data.totalCounts + }] + }); + } } else { console.warn('资源统计接口返回异常:', res); + document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = '0'; } }) .catch(error => { console.error('获取资源统计失败:', error); + document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = '0'; }); } @@ -449,6 +519,7 @@ setInterval(updateTime, 1000); // 页面加载完成后获取统计数据 document.addEventListener('DOMContentLoaded', function() { + getUserCounts(); getArticleCounts(); getResourcesCounts(); }); @@ -527,6 +598,7 @@ function initVisitTrend() { // 用户增长图表 function initUserGrowth() { var chart = echarts.init(document.getElementById('userGrowth')); + window.userChart = chart; var option = { tooltip: { trigger: 'axis', @@ -549,7 +621,7 @@ function initUserGrowth() { xAxis: { type: 'category', boundaryGap: false, - data: + data: [] }, yAxis: { type: 'value' @@ -558,7 +630,7 @@ function initUserGrowth() { { name: '新增用户', type: 'bar', - data: , + data: [], itemStyle: { color: '#3881fd' } @@ -567,9 +639,12 @@ function initUserGrowth() { name: '总用户数', type: 'line', smooth: true, - data: , + data: [], itemStyle: { color: '#10b981' + }, + lineStyle: { + width: 3 } } ] @@ -580,6 +655,7 @@ function initUserGrowth() { // 资源统计图表 function initResourceStats() { var chart = echarts.init(document.getElementById('resourceStats')); + window.resourceChart = chart; var option = { tooltip: { trigger: 'axis', @@ -591,7 +667,7 @@ function initResourceStats() { } }, legend: { - data: ['新增资源', '下载量'] + data: ['新增资源', '总资源数'] }, grid: { left: '3%', @@ -602,7 +678,7 @@ function initResourceStats() { xAxis: { type: 'category', boundaryGap: false, - data: + data: [] }, yAxis: { type: 'value' @@ -611,18 +687,21 @@ function initResourceStats() { { name: '新增资源', type: 'bar', - data: , + data: [], itemStyle: { color: '#3881fd' } }, { - name: '下载量', + name: '总资源数', type: 'line', smooth: true, - data: , + data: [], itemStyle: { color: '#10b981' + }, + lineStyle: { + width: 3 } } ] @@ -633,6 +712,7 @@ function initResourceStats() { // 文章统计图表 function initArticleStats() { var chart = echarts.init(document.getElementById('articleStats')); + window.articleChart = chart; var option = { tooltip: { trigger: 'axis', @@ -644,7 +724,7 @@ function initArticleStats() { } }, legend: { - data: ['新增文章', '访问量'] + data: ['新增文章', '总文章数'] }, grid: { left: '3%', @@ -655,7 +735,7 @@ function initArticleStats() { xAxis: { type: 'category', boundaryGap: false, - data: + data: [] }, yAxis: { type: 'value' @@ -664,18 +744,21 @@ function initArticleStats() { { name: '新增文章', type: 'bar', - data: , + data: [], itemStyle: { color: '#3881fd' } }, { - name: '访问量', + name: '总文章数', type: 'line', smooth: true, - data: , + data: [], itemStyle: { color: '#10b981' + }, + lineStyle: { + width: 3 } } ] diff --git a/runtime/admin/temp/7e7ad1a7e6ed8cb4133dc183d9d8fb6e.php b/runtime/admin/temp/7e7ad1a7e6ed8cb4133dc183d9d8fb6e.php deleted file mode 100644 index 72da750..0000000 --- a/runtime/admin/temp/7e7ad1a7e6ed8cb4133dc183d9d8fb6e.php +++ /dev/null @@ -1,199 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - > - > -
    -
    -
    - -
    - > - > -
    -
    -
    -
    -
    - -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/84edc0bba962f694a2d0f88ed9174143.php b/runtime/admin/temp/84edc0bba962f694a2d0f88ed9174143.php deleted file mode 100644 index 22ad554..0000000 --- a/runtime/admin/temp/84edc0bba962f694a2d0f88ed9174143.php +++ /dev/null @@ -1,298 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    -
    - - 文章列表 -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - - -
    -
    -
    - - -
    -
    -
    - -
    -
    - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/8f74a562a9b39596b131b5ce2a04e10e.php b/runtime/admin/temp/8f74a562a9b39596b131b5ce2a04e10e.php deleted file mode 100644 index f72cb12..0000000 --- a/runtime/admin/temp/8f74a562a9b39596b131b5ce2a04e10e.php +++ /dev/null @@ -1,267 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - 操作日志 -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - - -
    -
    -
    - -
    -
    -
    - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/8fd05746d9f4d337d2b8ead74b013673.php b/runtime/admin/temp/8fd05746d9f4d337d2b8ead74b013673.php deleted file mode 100644 index c0bdb2f..0000000 --- a/runtime/admin/temp/8fd05746d9f4d337d2b8ead74b013673.php +++ /dev/null @@ -1,181 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - > - > -
    -
    -
    -
    -
    - -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/95be89451b9d20c113b1e9b89d74e7ed.php b/runtime/admin/temp/95be89451b9d20c113b1e9b89d74e7ed.php deleted file mode 100644 index 235defc..0000000 --- a/runtime/admin/temp/95be89451b9d20c113b1e9b89d74e7ed.php +++ /dev/null @@ -1,260 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - 登录日志 -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - - -
    -
    -
    - -
    -
    -
    - - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/98d1caa8565d62f428819a17e93f072b.php b/runtime/admin/temp/98d1caa8565d62f428819a17e93f072b.php deleted file mode 100644 index 0378b95..0000000 --- a/runtime/admin/temp/98d1caa8565d62f428819a17e93f072b.php +++ /dev/null @@ -1,176 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - -
    - -
    -
    -
    - -
    - - -
    -
    -
    - - $vo): $mod = ($i % 2 );++$i;?> -
    -
    - -
    - $cvo): $mod = ($i % 2 );++$i;?> - - -
    - -
    -
    -
    -
    - -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/9d1675bab256bcb1262f747ef7d94459.php b/runtime/admin/temp/9d1675bab256bcb1262f747ef7d94459.php deleted file mode 100644 index c29589e..0000000 --- a/runtime/admin/temp/9d1675bab256bcb1262f747ef7d94459.php +++ /dev/null @@ -1,619 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    -
    - - 文章分类管理 -
    -
    -
    - - -
    -
    -
    - - -
    -
    - -
    -
    -
    - 分类列表 - 支持两级分类结构 -
    -
    -
    -
    -
    -
    - - -
    -
    -
    - 分类信息 -
    -
    - -
    - -

    请选择左侧分类或点击新增按钮

    -
    - - - -
    -
    -
    -
    -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/a4422e18098f908e0359a72e8b02a77c.php b/runtime/admin/temp/a4422e18098f908e0359a72e8b02a77c.php deleted file mode 100644 index 1b750d6..0000000 --- a/runtime/admin/temp/a4422e18098f908e0359a72e8b02a77c.php +++ /dev/null @@ -1,298 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    -
    - - 文章列表 -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - - -
    -
    -
    - - -
    -
    -
    - -
    -
    - - - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/a7bfd508279dfa35c2e6ff0e3f27da40.php b/runtime/admin/temp/a7bfd508279dfa35c2e6ff0e3f27da40.php deleted file mode 100644 index 3bc8a50..0000000 --- a/runtime/admin/temp/a7bfd508279dfa35c2e6ff0e3f27da40.php +++ /dev/null @@ -1,619 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    -
    - - 文章分类管理 -
    -
    -
    - - -
    -
    -
    - - -
    -
    - -
    -
    -
    - 分类列表 - 支持两级分类结构 -
    -
    -
    -
    -
    -
    - - -
    -
    -
    - 分类信息 -
    -
    - -
    - -

    请选择左侧分类或点击新增按钮

    -
    - - - -
    -
    -
    -
    -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/a9d67e4df562a7a96e64c14bb80c557f.php b/runtime/admin/temp/a9d67e4df562a7a96e64c14bb80c557f.php deleted file mode 100644 index a6dc072..0000000 --- a/runtime/admin/temp/a9d67e4df562a7a96e64c14bb80c557f.php +++ /dev/null @@ -1,218 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    -
    - -
    - - -
    -
    -
    -
    -
    - -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/afa4276487a18a3dcb5f95a687b90882.php b/runtime/admin/temp/afa4276487a18a3dcb5f95a687b90882.php deleted file mode 100644 index 36140ef..0000000 --- a/runtime/admin/temp/afa4276487a18a3dcb5f95a687b90882.php +++ /dev/null @@ -1,223 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    -
    - - 角色列表 -
    -
    -
    - - -
    -
    -
    - - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - -
    角色名状态添加时间操作
    禁用'; ?> - - -
    - -
    - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/afdc7ba517f0eba6675e7ddb71a0cccf.php b/runtime/admin/temp/afdc7ba517f0eba6675e7ddb71a0cccf.php deleted file mode 100644 index 2b59e6d..0000000 --- a/runtime/admin/temp/afdc7ba517f0eba6675e7ddb71a0cccf.php +++ /dev/null @@ -1,218 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    -
    - -
    - - -
    -
    -
    -
    -
    - -
    -
    - - - - \ No newline at end of file diff --git a/runtime/admin/temp/b2b7ed878a16cded7916ccc3ff270d4b.php b/runtime/admin/temp/b2b7ed878a16cded7916ccc3ff270d4b.php deleted file mode 100644 index 2f96b94..0000000 --- a/runtime/admin/temp/b2b7ed878a16cded7916ccc3ff270d4b.php +++ /dev/null @@ -1,248 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - - \ No newline at end of file diff --git a/runtime/admin/temp/b2c576f05dfebea99c813402f4da2e92.php b/runtime/admin/temp/b2c576f05dfebea99c813402f4da2e92.php deleted file mode 100644 index a9d55ec..0000000 --- a/runtime/admin/temp/b2c576f05dfebea99c813402f4da2e92.php +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - 重置密码 - - - - - - - - - -
    - -
    - - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/b742557fe5ab4483e3082140659f1f68.php b/runtime/admin/temp/b742557fe5ab4483e3082140659f1f68.php deleted file mode 100644 index b7dcd99..0000000 --- a/runtime/admin/temp/b742557fe5ab4483e3082140659f1f68.php +++ /dev/null @@ -1,239 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    - -
    -
    - - 用户列表 -
    -
    -
    - - -
    -
    -
    - - - - - - - - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - - - - - - - -
    真实姓名账户手机QQ角色性别状态登陆次数登陆时间操作
    - - - - - - 未知 - - 禁用'; ?> - - -
    -
    - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/b7a371608e8ada2d05d443e9741070b7.php b/runtime/admin/temp/b7a371608e8ada2d05d443e9741070b7.php deleted file mode 100644 index 09e1875..0000000 --- a/runtime/admin/temp/b7a371608e8ada2d05d443e9741070b7.php +++ /dev/null @@ -1,277 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    -
    -
    菜单结构
    - -
    -
    -
    - - - - - - - - - - - - - $vo): $mod = ($i % 2 );++$i;?> - - - - - - - - - - -
    排序类型按钮名图标状态操作
    - - 功能模块 - 超链接 - - - - 开启 - - 禁用 - - -
    - - -
    -
    -
    -
    -
    -
    - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/c4cb272f04d884533b2554471a2dc765.php b/runtime/admin/temp/c4cb272f04d884533b2554471a2dc765.php deleted file mode 100644 index 36079f6..0000000 --- a/runtime/admin/temp/c4cb272f04d884533b2554471a2dc765.php +++ /dev/null @@ -1,211 +0,0 @@ - - - - - <?php echo htmlentities((string) $config['admin_name']); ?> - - - - - - - - - - - -
    -
    - 登录日志 -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - - -
    -
    -
    - -
    -
    -
    - - - - - \ No newline at end of file diff --git a/runtime/admin/temp/c5f36a7772c20379b8b97ddafceff134.php b/runtime/admin/temp/c5f36a7772c20379b8b97ddafceff134.php index d591b8d..70c4480 100644 --- a/runtime/admin/temp/c5f36a7772c20379b8b97ddafceff134.php +++ b/runtime/admin/temp/c5f36a7772c20379b8b97ddafceff134.php @@ -1,4 +1,4 @@ - + @@ -100,10 +100,10 @@
    -