1168 lines
36 KiB
PHP
1168 lines
36 KiB
PHP
<?php /*a:5:{s:53:"E:\Demo\PHP\yunzer\app\index\view\articles\detail.php";i:1747754938;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747754938;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
|
<link rel="stylesheet" href="/static/layui/css/layui.css">
|
|
<link rel="stylesheet" href="/static/css/style.css">
|
|
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/static/css/fontawesome.css">
|
|
|
|
<script src="/static/layui/layui.js" charset="utf-8"></script>
|
|
<script src="/static/js/bootstrap.bundle.js"></script>
|
|
<script charset="UTF-8" id="LA_COLLECT" src="//www.yunzer.cn/plugins/js-sdk-pro.min.js"></script>
|
|
<script>LA.init({ id: "KoyzaWWEcLvPzkQn", ck: "KoyzaWWEcLvPzkQn", autoTrack: true, prefix: 'event' })</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div style="display: flex;flex-direction: column;">
|
|
<div class="topbar-one">
|
|
<div class="container">
|
|
<div style="width: 70%;">
|
|
<ul class="list-unstyled topbar-one__info">
|
|
<li class="topbar-one__info__item">
|
|
<span class="topbar-one__info__icon fas fa-phone-alt" style="margin-right: 10px;"></span>
|
|
<a href="<?php echo htmlentities((string) $config['admin_phone']); ?>"><?php echo htmlentities((string) $config['admin_phone']); ?></a>
|
|
</li>
|
|
<li class="topbar-one__info__item">
|
|
<span class="topbar-one__info__icon fas fa-envelope" style="margin-right: 10px;"></span>
|
|
<a href="mailto:<?php echo htmlentities((string) $config['admin_email']); ?>"><?php echo htmlentities((string) $config['admin_email']); ?></a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="topbar-one__social" style="width: 30%;">
|
|
<a href="/index/user/login" class="mr-10"><i class="layui-icon layui-icon-username"></i> 登录</a>
|
|
<a href="/index/user/register" class="mr-10"><i class="layui-icon layui-icon-user"></i> 注册</a>
|
|
<a href="javascript:;" class="qrcode-trigger"><i class="layui-icon layui-icon-qrcode"></i> 公众号</a>
|
|
<div class="qrcode-popup"
|
|
style="display:none;position:absolute;right:54px;top:32px;background:#fff;padding:10px;box-shadow:0 0 10px rgba(0,0,0,0.1); z-index: 1000;">
|
|
<img src="<?php echo htmlentities((string) $config['admin_wechat']); ?>" alt="公众号二维码" style="width:180px;height:180px;">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 导航栏 -->
|
|
<div class="main-menu">
|
|
<div class="container">
|
|
<div class="main-menu__logo">
|
|
<a href="index.html"><img src="/static/images/logo1.png" width="186" alt="Logo"></a>
|
|
</div>
|
|
<div class="main-menu__nav">
|
|
<ul class="main-menu__list">
|
|
<li><a href="/index.html">首页</a></li>
|
|
<li><a href="/about.html">关于我们</a></li>
|
|
<li><a href="/products.html">产品服务</a></li>
|
|
<li><a href="/contact.html">联系我们</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="main-menu__right">
|
|
<div class="layui-inline">
|
|
<div class="layui-inline" style="position: relative;">
|
|
<img src="/static/images/avatar.webp" class="layui-circle"
|
|
style="width: 40px; height: 40px; cursor: pointer;" id="userAvatarMain">
|
|
<div class="user-dropdown" id="userDropdownMain">
|
|
<ul>
|
|
<li>
|
|
<a href="/index/user/profile"><i
|
|
class="layui-icon layui-icon-user"></i><span>个人中心</span></a>
|
|
</li>
|
|
<li>
|
|
<a href="/index/user/settings"><i
|
|
class="layui-icon layui-icon-set"></i><span>账号管理</span></a>
|
|
</li>
|
|
<li>
|
|
<a href="javascript:;" class="logout-btn"><i
|
|
class="layui-icon layui-icon-logout"></i><span>退出登录</span></a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 固定导航 -->
|
|
<div class="sticky-nav" style="display: none;">
|
|
<div class="container">
|
|
<div class="sticky-nav__logo">
|
|
<a href="index.html"><img src="/static/images/logo1.png" width="150" alt="Logo"></a>
|
|
</div>
|
|
<div class="sticky-nav__menu">
|
|
<ul>
|
|
<li><a href="/index.html">首页</a></li>
|
|
<li><a href="/about.html">关于我们</a></li>
|
|
<li><a href="/products.html">产品服务</a></li>
|
|
<li><a href="/contact.html">联系我们</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="sticky-nav__right">
|
|
<div class="main-menu__right">
|
|
<div class="layui-inline">
|
|
<div class="layui-inline" style="position: relative;">
|
|
<img src="/static/images/avatar.webp" class="layui-circle"
|
|
style="width: 40px; height: 40px; cursor: pointer;" id="userAvatarSticky">
|
|
<div class="user-dropdown" id="userDropdownSticky">
|
|
<ul>
|
|
<li>
|
|
<a href="/index/user/profile"><i
|
|
class="layui-icon layui-icon-user"></i><span>个人中心</span></a>
|
|
</li>
|
|
<li>
|
|
<a href="/index/user/settings"><i
|
|
class="layui-icon layui-icon-set"></i><span>账号管理</span></a>
|
|
</li>
|
|
<li>
|
|
<a href="javascript:;" class="logout-btn"><i
|
|
class="layui-icon layui-icon-logout"></i><span>退出登录</span></a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
/* 用户头像样式 */
|
|
#userAvatar {
|
|
width: 40px;
|
|
height: 40px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
#userAvatar:hover {
|
|
transform: scale(1.05);
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
/* 下拉菜单容器 */
|
|
.user-dropdown {
|
|
position: absolute;
|
|
top: 50px;
|
|
right: 0;
|
|
width: 160px;
|
|
background: #fff;
|
|
border-radius: 4px;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
opacity: 0;
|
|
visibility: hidden;
|
|
transform: translateY(-10px);
|
|
transition: all 0.3s ease;
|
|
z-index: 9999;
|
|
}
|
|
|
|
.user-dropdown.show {
|
|
opacity: 1;
|
|
visibility: visible;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
/* 下拉菜单列表 */
|
|
.user-dropdown ul {
|
|
margin: 0;
|
|
padding: 5px 0;
|
|
list-style: none;
|
|
}
|
|
|
|
/* 下拉菜单项 */
|
|
.user-dropdown li {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
/* 下拉菜单链接 */
|
|
.user-dropdown li a {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 10px 15px;
|
|
color: #333;
|
|
text-decoration: none;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
/* 下拉菜单图标 */
|
|
.user-dropdown li a i {
|
|
margin-right: 10px;
|
|
font-size: 16px;
|
|
color: #666;
|
|
}
|
|
|
|
/* 下拉菜单文字 */
|
|
.user-dropdown li a span {
|
|
font-size: 14px;
|
|
}
|
|
|
|
/* 下拉菜单悬停效果 */
|
|
.user-dropdown li a:hover {
|
|
background: #f5f5f5;
|
|
color: #1E9FFF;
|
|
}
|
|
|
|
.user-dropdown li a:hover i {
|
|
color: #1E9FFF;
|
|
}
|
|
|
|
/* 分隔线 */
|
|
.user-dropdown li:not(:last-child) {
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
#userDropdownSticky a {
|
|
color: #0d6efd !important;
|
|
}
|
|
|
|
/* Banner样式 */
|
|
.banner-content {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.banner-image {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.banner-image img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
object-position: center;
|
|
}
|
|
|
|
.banner-text {
|
|
position: absolute;
|
|
top: 40%;
|
|
left: 10%;
|
|
z-index: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
color: #fff;
|
|
}
|
|
|
|
.banner-text a {
|
|
text-decoration: none;
|
|
margin-top: 30px;
|
|
}
|
|
|
|
.banner-title {
|
|
font-size: 4em;
|
|
font-weight: 600;
|
|
margin-bottom: 10px;
|
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.banner-desc {
|
|
font-size: 2em;
|
|
font-weight: 400;
|
|
max-width: 800px;
|
|
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.banner-btn {
|
|
background: #fff;
|
|
color: #000;
|
|
padding: 10px 20px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.banner-btn:hover {
|
|
background: #000;
|
|
color: #fff;
|
|
}
|
|
|
|
.banner-slider {
|
|
width: 100%;
|
|
height: 86vh;
|
|
overflow: hidden;
|
|
position: relative;
|
|
}
|
|
|
|
.banner-container {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.banner-slide {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.banner-slide img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
/* 关键:等比缩放并铺满 */
|
|
display: block;
|
|
}
|
|
|
|
.layui-carousel {
|
|
background: #f8f8f8;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
/* 确保轮播容器和项目的高度正确 */
|
|
#test10,
|
|
#test10 [carousel-item],
|
|
#test10 [carousel-item]>* {
|
|
height: 86vh !important;
|
|
}
|
|
|
|
#test10 [carousel-item]>* {
|
|
background: none !important;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
layui.use(['carousel', 'form', 'layer'], function () {
|
|
var carousel = layui.carousel, form = layui.form, layer = layui.layer, $ = layui.$;
|
|
|
|
// 加载banner数据
|
|
$.ajax({
|
|
url: '/index/index/bannerlist',
|
|
type: 'GET',
|
|
success: function (res) {
|
|
if (res.code === 1) {
|
|
var bannerHtml = '';
|
|
res.banner.forEach(function (banner) {
|
|
bannerHtml += '<div>' +
|
|
'<div class="banner-content">' +
|
|
'<div class="banner-image">' +
|
|
'<img src="' + banner.image + '" alt="' + (banner.title || '') + '">' +
|
|
'</div>' +
|
|
'<div class="banner-text">' +
|
|
'<span class="banner-title">' + (banner.title || '') + '</span>' +
|
|
'<span class="banner-desc">' + (banner.desc || '') + '</span>' +
|
|
'<a href="' + (banner.url || 'javascript:;') + '" class="banner-slide">' +
|
|
'<span class="banner-btn">查看详情</span>' +
|
|
'</a>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</div>';
|
|
});
|
|
$('#test10 div[carousel-item]').html(bannerHtml);
|
|
|
|
// 图片轮播
|
|
carousel.render({
|
|
elem: '#test10',
|
|
width: '100%',
|
|
height: '100vh',
|
|
interval: 4000,
|
|
anim: 'fade',
|
|
autoplay: true,
|
|
full: false,
|
|
arrow: 'hover'
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
// 主导航头像
|
|
$("#userAvatarMain").click(function (e) {
|
|
e.stopPropagation();
|
|
$("#userDropdownMain").toggleClass("show");
|
|
$("#userDropdownSticky").removeClass("show"); // 保证只显示一个
|
|
});
|
|
// 固定导航头像
|
|
$("#userAvatarSticky").click(function (e) {
|
|
e.stopPropagation();
|
|
$("#userDropdownSticky").toggleClass("show");
|
|
$("#userDropdownMain").removeClass("show"); // 保证只显示一个
|
|
});
|
|
|
|
// 点击页面其他地方隐藏所有菜单
|
|
$(document).click(function (e) {
|
|
if (!$(e.target).closest('.user-dropdown, #userAvatarMain, #userAvatarSticky').length) {
|
|
$("#userDropdownMain, #userDropdownSticky").removeClass("show");
|
|
}
|
|
});
|
|
|
|
// 点击菜单项时隐藏菜单
|
|
$("#userDropdownMain li a, #userDropdownSticky li a").click(function () {
|
|
$("#userDropdownMain, #userDropdownSticky").removeClass("show");
|
|
});
|
|
});
|
|
|
|
// 退出登录
|
|
$('.logout-btn').on('click', function () {
|
|
layer.confirm('确定要退出登录吗?', {
|
|
btn: ['确定', '取消']
|
|
}, function () {
|
|
window.location.href = '/index/user/logout';
|
|
});
|
|
});
|
|
|
|
// 监听滚动事件
|
|
$(window).scroll(function () {
|
|
var scrollTop = $(window).scrollTop();
|
|
if (scrollTop > 150) { // 当滚动超过150px时显示固定导航
|
|
$('.sticky-nav').fadeIn();
|
|
} else {
|
|
$('.sticky-nav').fadeOut();
|
|
}
|
|
});
|
|
|
|
// 公众号二维码
|
|
const trigger = document.querySelector('.qrcode-trigger');
|
|
const popup = document.querySelector('.qrcode-popup');
|
|
|
|
// 鼠标移入显示二维码
|
|
trigger.addEventListener('mouseenter', function () {
|
|
popup.style.display = 'block';
|
|
});
|
|
|
|
// 鼠标移出隐藏二维码
|
|
trigger.addEventListener('mouseleave', function () {
|
|
popup.style.display = 'none';
|
|
});
|
|
|
|
// 鼠标移入二维码区域时保持显示
|
|
popup.addEventListener('mouseenter', function () {
|
|
popup.style.display = 'block';
|
|
});
|
|
|
|
// 鼠标移出二维码区域时隐藏
|
|
popup.addEventListener('mouseleave', function () {
|
|
popup.style.display = 'none';
|
|
});
|
|
});
|
|
</script>
|
|
<div class="main">
|
|
<div class="location">
|
|
<div class="container">
|
|
<div class="location-item">
|
|
<a href="/">首页</a>
|
|
<span>></span>
|
|
<a href="/index/articles/index" id="cateLink"></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="article-detail-container">
|
|
<div class="article-header">
|
|
<h1 class="article-title" id="articleTitle"></h1>
|
|
<div class="article-meta">
|
|
<span class="article-author"><i class="fa fa-user"></i> <span id="articleAuthor"></span></span>
|
|
<span class="article-date"><i class="fa fa-calendar"></i> <span id="articleDate"></span></span>
|
|
<span class="article-views"><i class="fa-solid fa-eye"></i> <span id="articleViews"></span> 阅读</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="article-content" id="articleContent">
|
|
</div>
|
|
|
|
<div class="article-tags">
|
|
<span class="tag-label">标签:</span>
|
|
<div id="articleTags"></div>
|
|
</div>
|
|
|
|
<div class="article-actions">
|
|
<div class="action-item like-btn" id="likeBtn">
|
|
<i class="fa fa-thumbs-up"></i>
|
|
<span class="action-text">点赞</span>
|
|
<span class="action-count" id="articleLikes">0</span>
|
|
</div>
|
|
<div class="action-item share-btn" id="shareBtn">
|
|
<i class="fa fa-share-alt"></i>
|
|
<span class="action-text">分享</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="article-navigation">
|
|
<div class="prev-article" id="prevArticle">
|
|
</div>
|
|
<div class="next-article" id="nextArticle">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="related-articles">
|
|
<h3 class="related-title">相关推荐</h3>
|
|
<div class="related-list" id="relatedArticles">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 返回顶部按钮 -->
|
|
<div class="go-to-top" id="goToTop">
|
|
<i class="layui-icon-up"></i>
|
|
</div>
|
|
|
|
<footer class="footer" style="background-image: url(/static/images/footer-bg-1.png)">
|
|
<div class="container">
|
|
<div class="row" style="width: 100%;">
|
|
<div class="row-main">
|
|
<div class="mr-20">
|
|
<img src="<?php echo htmlentities((string) $config['logo']); ?>" alt="" height="70">
|
|
<p class="text-white-50 my-4 f18" style="width: 400px;">美天智能科技,这里是介绍!</p>
|
|
</div>
|
|
<div style="display: flex; justify-content: space-between;width: 100%;margin-right: 200px;">
|
|
<div>
|
|
<h4 class="text-white f-20 font-weight-normal mb-3">关于我们</h4>
|
|
<ul class="list-unstyled footer-sub-menu">
|
|
<li><a href="#" class="footer-link">概况</a></li>
|
|
<li><a href="#" class="footer-link">资讯</a></li>
|
|
<li><a href="#" class="footer-link">加入我们</a></li>
|
|
<li><a href="#" class="footer-link">联系我们</a></li>
|
|
</ul>
|
|
</div>
|
|
<div>
|
|
<h4 class="text-white f-20 font-weight-normal mb-3">商务合作</h4>
|
|
<ul class="list-unstyled footer-sub-menu">
|
|
<li><a href="#" class="footer-link">商务合作</a></li>
|
|
</ul>
|
|
</div>
|
|
<div>
|
|
<h4 class="text-white f-20 font-weight-normal mb-3">服务支持</h4>
|
|
<ul class="list-unstyled footer-sub-menu">
|
|
<li><a href="#" class="footer-link">常见问答</a></li>
|
|
<li><a href="#" class="footer-link">软件下载</a></li>
|
|
<li><a href="#" class="footer-link">服务政策</a></li>
|
|
<li><a href="#" class="footer-link">投诉建议</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="text-center">
|
|
<img src="<?php echo htmlentities((string) $config['admin_wechat']); ?>" alt="微信二维码" class="img-fluid" style="max-width: 150px;">
|
|
<p class="text-white-50 mt-2">微信公众号</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
<section class="copyright text-center">
|
|
<div class="container wow fadeInUp animated" data-wow-delay="400ms"
|
|
style="visibility: visible; animation-delay: 400ms; animation-name: fadeInUp;">
|
|
<p class="copyright__text">Copyright <span class="dynamic-year">2025</span> | All Rights By <a
|
|
href="http://www.yunzer.cn">Yunzer</a></p>
|
|
</div>
|
|
<div class="tongji">
|
|
<script id="LA-DATA-WIDGET" crossorigin="anonymous" charset="UTF-8"
|
|
src="https://v6-widget.51.la/v6/KoyzaWWEcLvPzkQn/quote.js?theme=#1690FF,#FFFFFF,#999999,#FFFFFF,#FFFFFF,#1690FF,12&f=12"></script>
|
|
</div>
|
|
</section>
|
|
|
|
<style>
|
|
.location {
|
|
max-width: 1000px;
|
|
margin: 30px auto;
|
|
}
|
|
|
|
|
|
.article-detail-container {
|
|
max-width: 1000px;
|
|
margin: 30px auto;
|
|
padding: 50px;
|
|
background: #fff;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
// 格式化日期
|
|
function formatDate(timestamp) {
|
|
const date = new Date(timestamp * 1000);
|
|
return date.toLocaleDateString('zh-CN', {
|
|
year: 'numeric',
|
|
month: '2-digit',
|
|
day: '2-digit'
|
|
});
|
|
}
|
|
|
|
// 渲染文章详情
|
|
function renderArticleDetail(data) {
|
|
// 渲染分类链接
|
|
document.getElementById('cateLink').textContent = data.cateName;
|
|
|
|
// 渲染文章标题
|
|
document.getElementById('articleTitle').textContent = data.article.title;
|
|
|
|
// 渲染文章元信息
|
|
document.getElementById('articleAuthor').textContent = data.article.author;
|
|
document.getElementById('articleDate').textContent = formatDate(data.article.create_time);
|
|
document.getElementById('articleViews').textContent = data.article.views;
|
|
|
|
// 渲染文章内容
|
|
document.getElementById('articleContent').innerHTML = data.article.content;
|
|
|
|
// 渲染标签
|
|
const tagsContainer = document.getElementById('articleTags');
|
|
if (data.article.tags && data.article.tags.length > 0) {
|
|
tagsContainer.innerHTML = data.article.tags.map(tag =>
|
|
`<span class="tag-item">${tag}</span>`
|
|
).join('');
|
|
} else {
|
|
tagsContainer.innerHTML = '<span class="no-tags">暂无标签</span>';
|
|
}
|
|
|
|
// 渲染点赞数
|
|
document.getElementById('articleLikes').textContent = data.article.likes || 0;
|
|
|
|
// 渲染上一篇
|
|
const prevArticle = document.getElementById('prevArticle');
|
|
if (data.prevArticle) {
|
|
prevArticle.innerHTML = `
|
|
<a href="/index/articles/detail?id=${data.prevArticle.id}">
|
|
<i class="fa fa-arrow-left"></i> 上一篇:${data.prevArticle.title}
|
|
</a>
|
|
`;
|
|
} else {
|
|
prevArticle.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>';
|
|
}
|
|
|
|
// 渲染下一篇
|
|
const nextArticle = document.getElementById('nextArticle');
|
|
if (data.nextArticle) {
|
|
nextArticle.innerHTML = `
|
|
<a href="/index/articles/detail?id=${data.nextArticle.id}">
|
|
下一篇:${data.nextArticle.title} <i class="fa fa-arrow-right"></i>
|
|
</a>
|
|
`;
|
|
} else {
|
|
nextArticle.innerHTML = '<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>';
|
|
}
|
|
|
|
// 渲染相关文章
|
|
const relatedArticles = document.getElementById('relatedArticles');
|
|
if (data.relatedArticles && data.relatedArticles.length > 0) {
|
|
relatedArticles.innerHTML = data.relatedArticles.map(article => `
|
|
<div class="related-item">
|
|
<a href="/index/articles/detail?id=${article.id}">
|
|
<div class="related-image">
|
|
<img src="${article.image}" alt="${article.title}">
|
|
</div>
|
|
<div class="related-info">
|
|
<div class="related-item-title">${article.title}</div>
|
|
<div class="related-item-desc">${article.desc || ''}</div>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
`).join('');
|
|
} else {
|
|
relatedArticles.innerHTML = '<div class="no-related">暂无相关文章</div>';
|
|
}
|
|
}
|
|
|
|
// 页面加载完成后执行
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// 获取文章ID
|
|
const articleId = new URLSearchParams(window.location.search).get('id');
|
|
if (!articleId) {
|
|
alert('文章ID不存在');
|
|
return;
|
|
}
|
|
|
|
// 获取文章详情
|
|
fetch(`/index/articles/detail?id=${articleId}`, {
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
}
|
|
})
|
|
.then(response => {
|
|
// console.log('Response status:', response.status);
|
|
// console.log('Response headers:', response.headers);
|
|
return response.json();
|
|
})
|
|
.then(result => {
|
|
// console.log('API response:', result);
|
|
if (result.code === 1) {
|
|
renderArticleDetail(result.data);
|
|
// 更新访问次数
|
|
updateArticleViews(articleId);
|
|
} else {
|
|
console.error('API error:', result.msg);
|
|
alert(result.msg || '获取文章详情失败');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('获取文章详情失败:', error);
|
|
console.error('Error details:', {
|
|
message: error.message,
|
|
stack: error.stack
|
|
});
|
|
alert('获取文章详情失败,请检查网络连接或刷新页面重试');
|
|
});
|
|
|
|
// 点赞功能
|
|
const likeBtn = document.getElementById('likeBtn');
|
|
if (likeBtn) {
|
|
// 检查是否已经点赞
|
|
if (likeBtn.classList.contains('liked')) {
|
|
likeBtn.style.pointerEvents = 'none'; // 禁用点击
|
|
likeBtn.style.cursor = 'default'; // 改变鼠标样式
|
|
return;
|
|
}
|
|
|
|
likeBtn.addEventListener('click', function () {
|
|
// 立即禁用按钮,防止重复点击
|
|
likeBtn.style.pointerEvents = 'none';
|
|
likeBtn.style.cursor = 'default';
|
|
|
|
fetch('/index/articles/like?id=' + articleId, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.code === 1) {
|
|
const countElement = document.getElementById('articlesLikes');
|
|
if (countElement) {
|
|
let count = parseInt(countElement.textContent) || 0;
|
|
countElement.textContent = count + 1;
|
|
}
|
|
// 添加点赞状态
|
|
likeBtn.classList.add('liked');
|
|
likeBtn.querySelector('i').style.color = '#f57005';
|
|
layer.msg('点赞成功', {icon: 1});
|
|
} else {
|
|
// 如果请求失败,恢复按钮状态
|
|
likeBtn.style.pointerEvents = 'auto';
|
|
likeBtn.style.cursor = 'pointer';
|
|
layer.msg('点赞失败:' + data.msg, {icon: 2});
|
|
}
|
|
})
|
|
.catch(error => {
|
|
// 如果请求失败,恢复按钮状态
|
|
likeBtn.style.pointerEvents = 'auto';
|
|
likeBtn.style.cursor = 'pointer';
|
|
console.error('点赞请求失败:', error);
|
|
layer.msg('点赞失败,请稍后重试', {icon: 2});
|
|
});
|
|
});
|
|
}
|
|
|
|
// 返回顶部功能
|
|
const goToTop = document.getElementById('goToTop');
|
|
|
|
// 监听滚动事件
|
|
window.addEventListener('scroll', function () {
|
|
if (window.pageYOffset > 300) {
|
|
goToTop.classList.add('show');
|
|
} else {
|
|
goToTop.classList.remove('show');
|
|
}
|
|
});
|
|
|
|
// 点击返回顶部
|
|
goToTop.addEventListener('click', function () {
|
|
window.scrollTo({
|
|
top: 0,
|
|
behavior: 'smooth'
|
|
});
|
|
});
|
|
});
|
|
|
|
// 更新文章访问次数
|
|
function updateArticleViews(articleId) {
|
|
fetch('/index/articles/updateViews', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
id: articleId
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(result => {
|
|
if (result.code === 1) {
|
|
// 更新成功,更新页面上的访问次数显示
|
|
const viewsElement = document.getElementById('articleViews');
|
|
if (viewsElement) {
|
|
viewsElement.textContent = result.data.views;
|
|
}
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('更新访问次数失败:', error);
|
|
});
|
|
}
|
|
|
|
// 分享功能
|
|
const shareBtn = document.getElementById('shareBtn');
|
|
if (shareBtn) {
|
|
shareBtn.addEventListener('click', function () {
|
|
// 获取当前页面URL
|
|
const currentUrl = window.location.href;
|
|
|
|
// 创建临时输入框
|
|
const tempInput = document.createElement('input');
|
|
tempInput.value = currentUrl;
|
|
document.body.appendChild(tempInput);
|
|
|
|
// 选择并复制文本
|
|
tempInput.select();
|
|
document.execCommand('copy');
|
|
|
|
// 移除临时输入框
|
|
document.body.removeChild(tempInput);
|
|
|
|
// 提示用户复制成功
|
|
alert('链接已复制到剪贴板');
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|