first commit
This commit is contained in:
@@ -0,0 +1,712 @@
|
||||
{include file="component/head" /}
|
||||
{include file="component/header" /}
|
||||
<div class="main">
|
||||
<div class="location">
|
||||
<div class="container">
|
||||
<div class="location-item">
|
||||
<a href="/">首页</a>
|
||||
<span>></span>
|
||||
<a href="/index/articles/index">{$cateName}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="body-container">
|
||||
<div class="article-detail-container">
|
||||
<div class="article-header">
|
||||
<h1 class="article-title">{$article.title}</h1>
|
||||
{if $article.is_trans eq 1 && $article.transurl}
|
||||
<div class="trans">转载至:<span class="trans-url" data-url="{$article.transurl}">{$article.transurl}</span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="article-meta">
|
||||
<span class="article-author"><i class="fa fa-user"></i> <span>{$article.author}</span></span>
|
||||
<span class="article-date"><i class="fa fa-calendar"></i>
|
||||
<span>{$article.create_time|date="Y-m-d"}</span></span>
|
||||
<span class="article-views"><i class="fa-solid fa-eye"></i> <span>{$article.views}</span> 阅读</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-content">
|
||||
{$article.content|raw}
|
||||
</div>
|
||||
|
||||
<div class="disclaimers">
|
||||
<div class="disclaimer-item">
|
||||
<div class="disclaimer-title">免责声明:</div>
|
||||
<div class="disclaimer-content">
|
||||
<?php echo $config['disclaimers'] ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-tags">
|
||||
<span class="tag-label">标签:</span>
|
||||
<div>
|
||||
{if $article.tags}
|
||||
{volist name="article.tags|explode=',',','" id="tag"}
|
||||
<span class="tag-item">{$tag}</span>
|
||||
{/volist}
|
||||
{else}
|
||||
<span class="no-tags">暂无标签</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-actions">
|
||||
<div class="action-item like-btn" data-id="{$article.id}">
|
||||
<i class="fa fa-thumbs-up"></i>
|
||||
<span class="action-text">点赞</span>
|
||||
<span class="action-count">{$article.likes}</span>
|
||||
</div>
|
||||
<div class="action-item share-btn">
|
||||
<i class="fa fa-share-alt"></i>
|
||||
<span class="action-text">分享</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-navigation">
|
||||
<div class="prev-article">
|
||||
{if $prevArticle}
|
||||
<a href="/index/articles/detail?id={$prevArticle.id}">
|
||||
<i class="fa fa-arrow-left"></i> 上一篇:{$prevArticle.title}
|
||||
</a>
|
||||
{else}
|
||||
<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="next-article">
|
||||
{if $nextArticle}
|
||||
<a href="/index/articles/detail?id={$nextArticle.id}">
|
||||
下一篇:{$nextArticle.title} <i class="fa fa-arrow-right"></i>
|
||||
</a>
|
||||
{else}
|
||||
<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="related-articles">
|
||||
<h3 class="related-title">相关推荐</h3>
|
||||
<div class="related-list">
|
||||
{volist name="relatedArticles" id="related"}
|
||||
<div class="related-item">
|
||||
<a href="/index/articles/detail?id={$related.id}">
|
||||
<div class="related-image">
|
||||
<img src="{$related.image}" alt="{$related.title}">
|
||||
</div>
|
||||
<div class="related-info">
|
||||
<div class="related-item-title">{$related.title}</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="article-detail-right">
|
||||
<div class="aboutauthor">
|
||||
<div class="aboutauthor-title">关于作者</div>
|
||||
<div class="aboutauthor-main">
|
||||
<div class="aboutauthor-main-top">
|
||||
<div class="aboutauthor-avatar">
|
||||
<img src="{$authorInfo.avatar}" alt="作者头像">
|
||||
</div>
|
||||
<div class="aboutauthor-info">
|
||||
<div class="author-name">{$authorInfo.name}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aboutauthor-main-middle">
|
||||
<div class="author-stats">
|
||||
|
||||
<div class="author-stats-item">
|
||||
<h6>资源</h6>
|
||||
<span class="count">{$authorInfo.resource_count}</span>
|
||||
</div>
|
||||
<div class="author-stats-item">
|
||||
<h6>文章</h6>
|
||||
<span class="count">{$authorInfo.article_count}</span>
|
||||
</div>
|
||||
<div class="author-stats-item">
|
||||
<h6>粉丝</h6>
|
||||
<span class="count">
|
||||
0
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aboutauthor-btn">
|
||||
<button class="follow-btn">
|
||||
<i class="fa fa-user-plus"></i> 关注他
|
||||
</button>
|
||||
<button class="message-btn">
|
||||
<i class="fa fa-envelope"></i> 发私信
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 返回顶部按钮 -->
|
||||
<div class="go-to-top">
|
||||
<i class="layui-icon-up"></i>
|
||||
</div>
|
||||
|
||||
{include file="component/footer" /}
|
||||
|
||||
<script>
|
||||
// 更新访问次数
|
||||
async function updateArticleViews(articleId) {
|
||||
try {
|
||||
await fetch('/index/articles/updateViews', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ id: articleId })
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('更新访问次数失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后执行
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const articleId = '{$article.id}';
|
||||
|
||||
// 更新访问次数
|
||||
updateArticleViews(articleId);
|
||||
|
||||
// 点赞功能
|
||||
document.querySelector('.like-btn').addEventListener('click', async function () {
|
||||
try {
|
||||
const response = await fetch('/index/articles/like?id=' + articleId, {
|
||||
method: 'POST',
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||
});
|
||||
const result = await response.json();
|
||||
|
||||
if (result.code === 1) {
|
||||
const countElement = this.querySelector('.action-count');
|
||||
countElement.textContent = parseInt(countElement.textContent) + 1;
|
||||
this.classList.add('liked');
|
||||
this.querySelector('i').style.color = '#f57005';
|
||||
layer.msg('点赞成功', { icon: 1 });
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 });
|
||||
}
|
||||
} catch (error) {
|
||||
layer.msg('点赞失败,请稍后重试', { icon: 2 });
|
||||
}
|
||||
});
|
||||
|
||||
// 分享功能
|
||||
document.querySelector('.share-btn').addEventListener('click', function () {
|
||||
const url = window.location.href;
|
||||
navigator.clipboard.writeText(url).then(() => {
|
||||
layer.msg('链接已复制到剪贴板', { icon: 1 });
|
||||
}).catch(() => {
|
||||
layer.msg('复制失败,请手动复制', { icon: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
// 转载链接点击
|
||||
document.querySelector('.trans-url')?.addEventListener('click', function () {
|
||||
const url = this.dataset.url;
|
||||
if (url) {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
});
|
||||
|
||||
// 返回顶部
|
||||
const goToTop = document.querySelector('.go-to-top');
|
||||
window.addEventListener('scroll', function () {
|
||||
if (window.scrollY > 300) {
|
||||
goToTop.classList.add('show');
|
||||
} else {
|
||||
goToTop.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
goToTop.addEventListener('click', function () {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.location {
|
||||
max-width: 1200px;
|
||||
margin: 30px auto;
|
||||
}
|
||||
|
||||
.main .body-container {
|
||||
display: flex;
|
||||
max-width: 1200px;
|
||||
margin: 30px auto;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.article-detail-container {
|
||||
padding: 50px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor {
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-title {
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 20px !important;
|
||||
padding: 20px 0;
|
||||
border-bottom: 1px solid #efefef;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-top .aboutauthor-avatar {
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-top .aboutauthor-info .author-name {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-top .aboutauthor-avatar img {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
margin: 0px;
|
||||
min-width: 0px;
|
||||
max-width: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-middle {
|
||||
/* margin-left: 20px; */
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-middle .author-stats {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-middle .author-stats .author-stats-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-main .aboutauthor-main-middle .author-stats .author-stats-item .count {
|
||||
/* font-size: 30px; */
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-btn {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-btn .follow-btn {
|
||||
background-color: #0081ff;
|
||||
color: #fff;
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.main .body-container .article-detail-right .aboutauthor-btn .message-btn {
|
||||
color: #0081ff;
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
|
||||
.article-header {
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.article-title {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin-bottom: 15px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.article-meta span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.article-meta i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.article-content {
|
||||
line-height: 1.8;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.article-content img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
margin: 15px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.article-tags {
|
||||
margin: 20px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.tag-label {
|
||||
font-weight: bold;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.tag-item {
|
||||
background: #f2f2f2;
|
||||
padding: 4px 10px;
|
||||
border-radius: 15px;
|
||||
font-size: 12px;
|
||||
margin-right: 8px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.article-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
margin: 30px 0;
|
||||
padding: 20px 0;
|
||||
border-top: 1px solid #eee;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.action-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.action-item i {
|
||||
font-size: 24px;
|
||||
color: #666;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.action-text {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.action-count {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.article-navigation {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
.prev-article,
|
||||
.next-article {
|
||||
max-width: 45%;
|
||||
}
|
||||
|
||||
.prev-article a,
|
||||
.next-article a {
|
||||
color: #333 !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.prev-article a:hover,
|
||||
.next-article a:hover {
|
||||
color: #f57005 !important;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.related-articles {
|
||||
margin: 40px 0;
|
||||
}
|
||||
|
||||
.related-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.related-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.related-item {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.related-item:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.related-item a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.related-image img {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.related-info {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.related-item-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.related-item-desc {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.article-comments {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.comments-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.comment-form {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.comment-textarea {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
resize: none;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.comment-submit {
|
||||
background: #f57005;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.comment-item {
|
||||
display: flex;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.comment-avatar img {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.comment-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.comment-user {
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.comment-text {
|
||||
line-height: 1.6;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.comment-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.comment-reply {
|
||||
cursor: pointer;
|
||||
color: #f57005;
|
||||
}
|
||||
|
||||
.no-comments,
|
||||
.no-related,
|
||||
.no-tags {
|
||||
color: #999;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.article-title {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.related-list {
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 返回顶部按钮样式 */
|
||||
.go-to-top {
|
||||
position: fixed;
|
||||
right: 30px;
|
||||
bottom: 30px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #f57005;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.go-to-top.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.go-to-top:hover {
|
||||
background: #e66600;
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
.go-to-top i {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.go-to-top {
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.location-item a {
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
.disclaimers {
|
||||
color: #b1b1b1;
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.disclaimer-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.disclaimer-content {
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.disclaimer-content p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
{include file="component/foot" /}
|
||||
@@ -0,0 +1,562 @@
|
||||
{include file="component/head" /}
|
||||
{include file="component/header" /}
|
||||
|
||||
<!-- 简约现代文章中心 -->
|
||||
<div class="modern-articles-page">
|
||||
<!-- 简约标题区 -->
|
||||
<div class="modern-header">
|
||||
<div class="container">
|
||||
<h1 class="modern-title">文章中心</h1>
|
||||
<p class="modern-subtitle">探索知识与洞见</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主要内容区 -->
|
||||
<div class="container">
|
||||
<div class="modern-layout">
|
||||
<!-- 侧边分类导航 -->
|
||||
<aside class="modern-sidebar">
|
||||
<div class="sidebar-card">
|
||||
<h3 class="sidebar-title">
|
||||
<i class="layui-icon layui-icon-list"></i>
|
||||
<span>分类导航</span>
|
||||
</h3>
|
||||
<ul class="category-menu">
|
||||
{volist name="cate.subCategories" id="subCategory"}
|
||||
<li class="menu-item {$cate.id == $subCategory.id ? 'active' : ''}"
|
||||
data-cateid="{$subCategory.id}">
|
||||
<span>{$subCategory.name}</span>
|
||||
<i class="layui-icon layui-icon-right"></i>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- 文章内容区 -->
|
||||
<main class="modern-main">
|
||||
<!-- 文章列表 -->
|
||||
<div class="article-grid" id="articleList">
|
||||
{volist name="cate.subCategories" id="subCategory"}
|
||||
{if $cate.id == $subCategory.id}
|
||||
{if !empty($subCategory.list)}
|
||||
{volist name="subCategory.list" id="article"}
|
||||
<article class="article-card">
|
||||
<div class="card-image">
|
||||
<img src="{$article.image}" alt="{$article.title}">
|
||||
<div class="image-overlay"></div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="meta-info">
|
||||
<!-- <span class="category-tag">${article.category_name || '未分类'}</span> -->
|
||||
<time class="publish-date">{:date('Y-m-d', $article['create_time'])}</time>
|
||||
</div>
|
||||
|
||||
<a href="/index/articles/detail?id=${article.id}">
|
||||
<h3 class="article-title">${article.title}</h3>
|
||||
</a>
|
||||
<div class="card-footer">
|
||||
<div class="stats">
|
||||
<span class="views"><i class="layui-icon layui-icon-eye"></i> ${article.views ||
|
||||
0}</span>
|
||||
<span class="likes"><i class="layui-icon layui-icon-praise"></i> ${article.likes ||
|
||||
0}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{/volist}
|
||||
{else}
|
||||
<div class="empty-state">
|
||||
<div class="empty-icon">
|
||||
<i class="layui-icon layui-icon-template-1"></i>
|
||||
</div>
|
||||
<h4>暂无文章</h4>
|
||||
<p>当前分类下没有找到相关文章</p>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/volist}
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="modern-pagination" id="pagination"></div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['laypage', 'jquery'], function () {
|
||||
var laypage = layui.laypage;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// 分类切换
|
||||
$('.menu-item').on('click', function () {
|
||||
var cateid = $(this).data('cateid');
|
||||
var $menuItems = $('.menu-item');
|
||||
|
||||
// 更新选中状态
|
||||
$menuItems.removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
// 加载文章
|
||||
loadArticles(cateid, 1);
|
||||
});
|
||||
|
||||
// 页面加载完成后,自动触发第一个分类的点击事件
|
||||
$(document).ready(function () {
|
||||
var $firstMenuItem = $('.menu-item').first();
|
||||
if ($firstMenuItem.length > 0) {
|
||||
$firstMenuItem.click();
|
||||
}
|
||||
});
|
||||
|
||||
// 加载文章函数
|
||||
function loadArticles(cateid, page) {
|
||||
$.ajax({
|
||||
url: '/index/articles/list',
|
||||
type: 'POST',
|
||||
data: {
|
||||
cate: cateid,
|
||||
page: page
|
||||
},
|
||||
beforeSend: function () {
|
||||
$('#articleList').html('<div class="loading-state"><i class="layui-icon layui-icon-loading"></i>加载中...</div>');
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
var html = '';
|
||||
if (res.data.articles && res.data.articles.length > 0) {
|
||||
res.data.articles.forEach(function (article) {
|
||||
html += `<article class="article-card">
|
||||
<div class="card-image">
|
||||
<img src="${article.image}" alt="${article.title}">
|
||||
<div class="image-overlay"></div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="meta-info">
|
||||
|
||||
</div>
|
||||
<a href="/index/articles/detail?id=${article.id}" class="read-more">
|
||||
<h3 class="article-title">${article.title}</h3>
|
||||
</a>
|
||||
<div class="card-footer">
|
||||
<div class="stats">
|
||||
<span class="views"><i class="layui-icon layui-icon-eye"></i> ${article.views || 0}</span>
|
||||
<span class="likes"><i class="layui-icon layui-icon-praise"></i> ${article.likes || 0}</span>
|
||||
</div>
|
||||
<div class="times">
|
||||
<time class="publish-date">${article.create_time ? new Date(article.create_time * 1000).toLocaleDateString() : ''}</time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>`;
|
||||
});
|
||||
} else {
|
||||
html = `<div class="empty-state">
|
||||
<div class="empty-icon">
|
||||
<i class="layui-icon layui-icon-template-1"></i>
|
||||
</div>
|
||||
<h4>暂无文章</h4>
|
||||
<p>当前分类下没有找到相关文章</p>
|
||||
</div>`;
|
||||
}
|
||||
$('#articleList').html(html);
|
||||
|
||||
// 渲染分页
|
||||
laypage.render({
|
||||
elem: 'pagination',
|
||||
count: res.data.total || 0,
|
||||
limit: res.data.per_page || 12,
|
||||
curr: res.data.current_page || 1,
|
||||
theme: '#1E9FFF',
|
||||
layout: ['prev', 'page', 'next'],
|
||||
jump: function (obj, first) {
|
||||
if (!first) {
|
||||
loadArticles(cateid, obj.curr);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{include file="component/footer" /}
|
||||
|
||||
<style>
|
||||
/* 基础样式重置 */
|
||||
.modern-articles-page {
|
||||
font-family: 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
background-color: #f9fafc;
|
||||
padding-bottom: 60px;
|
||||
}
|
||||
|
||||
/* 标题区样式 */
|
||||
.modern-header {
|
||||
background: linear-gradient(135deg, #1E9FFF 0%, #0d8aff 100%);
|
||||
color: white;
|
||||
padding: 80px 0 60px;
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.modern-title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 300;
|
||||
margin-bottom: 15px;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.modern-subtitle {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 300;
|
||||
opacity: 0.9;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* 布局结构 */
|
||||
.modern-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 260px 1fr;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
/* 侧边栏样式 */
|
||||
.modern-sidebar {
|
||||
position: sticky;
|
||||
top: 30px;
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
.sidebar-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
padding: 20px;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #555;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.sidebar-title i {
|
||||
margin-right: 10px;
|
||||
font-size: 1.2rem;
|
||||
color: #1E9FFF;
|
||||
}
|
||||
|
||||
.category-menu {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
padding: 15px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.menu-item:hover {
|
||||
background-color: #f8fafd;
|
||||
color: #1E9FFF;
|
||||
}
|
||||
|
||||
.menu-item.active {
|
||||
background-color: #f0f7ff;
|
||||
border-left-color: #1E9FFF;
|
||||
color: #1E9FFF;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.menu-item i {
|
||||
font-size: 0.9rem;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.menu-item.active i,
|
||||
.menu-item:hover i {
|
||||
color: #1E9FFF;
|
||||
}
|
||||
|
||||
/* 主内容区样式 */
|
||||
.modern-main {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* 文章网格布局 */
|
||||
.article-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 25px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
/* 文章卡片样式 */
|
||||
.article-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 3px 15px rgba(0, 0, 0, 0.03);
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.article-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 5px 25px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.card-image {
|
||||
height: 135px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.5s ease;
|
||||
}
|
||||
|
||||
.image-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(to top, rgba(0, 0, 0, 0.3), transparent);
|
||||
}
|
||||
|
||||
.article-card:hover .card-image img {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding: 20px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.card-content .read-more h3:hover {
|
||||
color: #1E9FFF !important;
|
||||
transition: all ease .5s;
|
||||
font-weight:700;
|
||||
}
|
||||
|
||||
.meta-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
/* margin-bottom: 12px; */
|
||||
font-size: 0.85rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.category-tag {
|
||||
background: #f0f7ff;
|
||||
color: #1E9FFF;
|
||||
padding: 3px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.article-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
margin: 0 0 10px;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.article-excerpt {
|
||||
font-size: 0.9rem;
|
||||
color: #666;
|
||||
margin: 0 0 20px;
|
||||
flex: 1;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.times,
|
||||
.stats {
|
||||
font-size: 0.85rem;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.stats i {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
.read-more {
|
||||
color: #1E9FFF;
|
||||
font-size: 0.9rem;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.read-more:hover {
|
||||
color: #0d8aff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* 分页样式 */
|
||||
.modern-pagination {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.layui-laypage a,
|
||||
.layui-laypage span {
|
||||
border-radius: 4px !important;
|
||||
margin: 0 3px !important;
|
||||
}
|
||||
|
||||
.layui-laypage a {
|
||||
color: #666 !important;
|
||||
}
|
||||
|
||||
.layui-laypage .layui-laypage-curr .layui-laypage-em {
|
||||
background-color: #1E9FFF !important;
|
||||
}
|
||||
|
||||
/* 空状态样式 */
|
||||
.empty-state {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 3px 15px rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 3rem;
|
||||
color: #ddd;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.empty-icon i {
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.empty-state h4 {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 400;
|
||||
color: #666;
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
color: #999;
|
||||
font-size: 0.95rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* 加载状态 */
|
||||
.loading-state {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.loading-state i {
|
||||
font-size: 1.5rem;
|
||||
margin-right: 10px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 992px) {
|
||||
.modern-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.modern-sidebar {
|
||||
position: static;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.article-grid {
|
||||
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.modern-header {
|
||||
padding: 60px 0 40px;
|
||||
}
|
||||
|
||||
.modern-title {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.article-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.modern-title {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
|
||||
.modern-subtitle {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
{include file="component/foot" /}
|
||||
@@ -0,0 +1,76 @@
|
||||
<div class="container py-5">
|
||||
<div class="row g-4">
|
||||
<!-- 左侧分类列表 -->
|
||||
<div class="col-lg-3">
|
||||
<div class="category-sidebar">
|
||||
<div class="sidebar-header">
|
||||
<i class="layui-icon layui-icon-app"></i>
|
||||
<span>文章分类</span>
|
||||
</div>
|
||||
<div class="category-list">
|
||||
{volist name="categories" id="cate"}
|
||||
<div class="category-item {$category.id == $cate.id ? 'active' : ''}" data-cateid="{$cate.id}">{$cate.name}</div>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧文章列表 -->
|
||||
<div class="col-lg-9">
|
||||
{if $category}
|
||||
<div class="category-header mb-4">
|
||||
<h2 class="category-title">{$category.name}</h2>
|
||||
<p class="category-desc">{$category.desc|default=''}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="article-list">
|
||||
{volist name="articles" id="article"}
|
||||
<div class="article-item">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
<div class="article-image">
|
||||
<img src="{$article.image|default='/static/images/default.jpg'}" alt="{$article.title}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="article-content">
|
||||
<h3 class="article-title">
|
||||
<a href="/index/articles/detail?id={$article.id}">{$article.title}</a>
|
||||
</h3>
|
||||
<p class="article-desc">{$article.desc|default=''}</p>
|
||||
<div class="article-meta">
|
||||
<div class="article-stats">
|
||||
<span><i class="layui-icon layui-icon-eye"></i> {$article.views|default=0}</span>
|
||||
<span><i class="layui-icon layui-icon-praise"></i> {$article.likes|default=0}</span>
|
||||
<span><i class="layui-icon layui-icon-date"></i> {$article.create_time|date="Y-m-d"}</span>
|
||||
</div>
|
||||
<a href="/index/articles/detail?id={$article.id}" class="btn-detail">查看详情</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="mt-5">
|
||||
{$articles|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['layer'], function () {
|
||||
var layer = layui.layer;
|
||||
var $ = layui.$;
|
||||
|
||||
// 分类切换
|
||||
$('.category-item').on('click', function() {
|
||||
var cateid = $(this).data('cateid');
|
||||
window.location.href = '/index/articles/list?cate=' + cateid;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user