批量更新

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
@@ -322,7 +322,7 @@
// 初始化分类列表
that.initCategoryList = function () {
$.ajax({
url: '/admin/article/articlecate',
url: '/admin/articles/articlecate',
type: 'POST',
success: function (res) {
if (res.code === 0) {
@@ -387,7 +387,7 @@
// 加载分类信息
that.loadCategoryInfo = function (id) {
$.get('/admin/article/cateedit?id=' + id, function (res) {
$.get('/admin/articles/cateedit?id=' + id, function (res) {
if (res.code === 0) {
that.showCategoryForm(0, res.data);
}
@@ -413,7 +413,7 @@
$select.empty().append('<option value="0">顶级分类</option>');
// 获取所有分类作为父级选项
$.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();
@@ -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 () {
+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
}
}
]