批量更新

This commit is contained in:
云泽网
2025-05-19 21:51:21 +08:00
parent 7bd072add9
commit 07b3bd5eff
86 changed files with 1768 additions and 18426 deletions
+101 -18
View File
@@ -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 @@
<div class="activity-list">
{volist name="recentActivities" id="activity"}
<div class="activity-item">
<div class="activity-icon">{$activity.icon}</div>
<div class="activity-icon">{$activity.icon|default='📌'}</div>
<div class="activity-content">
<div class="activity-title">{$activity.title}</div>
<div class="activity-time">{$activity.time}</div>
<div class="activity-title">{$activity.content}</div>
</div>
</div>
{/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
}
}
]