更新数据
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1746796639;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1746985804;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1746796639;}*/ ?>
|
||||
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1746796639;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1746986804;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1746796639;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -235,7 +235,8 @@ layui.use(['carousel', 'form'], function(){
|
||||
}
|
||||
// 渲染文章列表
|
||||
if (result.articles && result.articles.length > 0) {
|
||||
renderWebArticles(result.articles, 'webArticlesList');
|
||||
// 只取最新的4条
|
||||
renderWebArticles(result.articles.slice(0, 4), 'webArticlesList');
|
||||
} else {
|
||||
showNoData('webArticlesList');
|
||||
}
|
||||
@@ -260,8 +261,17 @@ layui.use(['carousel', 'form'], function(){
|
||||
renderCategoryTabs(result.categories, 'techArticles');
|
||||
}
|
||||
// 渲染文章列表
|
||||
if (result.articles && result.articles.length > 0) {
|
||||
renderWebArticles(result.articles, 'techArticlesList');
|
||||
if (result.articles && Object.keys(result.articles).length > 0) {
|
||||
// 合并所有分类的文章
|
||||
let allArticles = [];
|
||||
Object.values(result.articles).forEach(arr => {
|
||||
allArticles = allArticles.concat(arr);
|
||||
});
|
||||
// 按发布时间排序(降序)
|
||||
allArticles.sort((a, b) => b.publishdate - a.publishdate);
|
||||
// 只取最新的12条
|
||||
allArticles = allArticles.slice(0, 12);
|
||||
renderWebArticles(allArticles, 'techArticlesList');
|
||||
} else {
|
||||
showNoData('techArticlesList');
|
||||
}
|
||||
@@ -340,13 +350,36 @@ layui.use(['carousel', 'form'], function(){
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 1) {
|
||||
if (categoryId === 'all') {
|
||||
// 显示所有文章
|
||||
renderWebArticles(result.articles, containerId);
|
||||
if (containerId === 'techArticlesList') {
|
||||
if (categoryId === 'all') {
|
||||
// 合并所有分类的文章
|
||||
let allArticles = [];
|
||||
if (typeof result.articles === 'object') {
|
||||
Object.values(result.articles).forEach(arr => {
|
||||
allArticles = allArticles.concat(arr);
|
||||
});
|
||||
}
|
||||
// 按发布时间排序(降序)
|
||||
allArticles.sort((a, b) => b.publishdate - a.publishdate);
|
||||
// 只取最新的12条
|
||||
allArticles = allArticles.slice(0, 12);
|
||||
renderWebArticles(allArticles, containerId);
|
||||
} else {
|
||||
// 只显示选中分类的文章
|
||||
let filteredArticles = [];
|
||||
if (typeof result.articles === 'object' && result.articles[categoryId]) {
|
||||
filteredArticles = result.articles[categoryId];
|
||||
}
|
||||
renderWebArticles(filteredArticles, containerId);
|
||||
}
|
||||
} else {
|
||||
// 过滤显示选中分类的文章
|
||||
const filteredArticles = result.articles.filter(article => article.cate == categoryId);
|
||||
renderWebArticles(filteredArticles, containerId);
|
||||
// 站点资讯部分逻辑不变
|
||||
if (categoryId === 'all') {
|
||||
renderWebArticles(result.articles.slice(0, 4), containerId);
|
||||
} else {
|
||||
const filteredArticles = result.articles.filter(article => article.cate == categoryId);
|
||||
renderWebArticles(filteredArticles, containerId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showNoData(containerId);
|
||||
|
||||
Reference in New Issue
Block a user