更新前后端标签代码
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1746709977;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1746868512;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1746709977;}*/ ?>
|
||||
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1747361734;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1747033370;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747360756;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -21,17 +21,24 @@
|
||||
<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"></span><a
|
||||
href="tel:629-555-0129">(629) 555-0129</a></li>
|
||||
<li class="topbar-one__info__item"><span class="topbar-one__info__icon fas fa-envelope"></span><a
|
||||
href="mailto:info@example.com">info@example.com</a></li>
|
||||
<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="https://facebook.com"><i class="fab fa-facebook-f"></i></a>
|
||||
<a href="https://twitter.com"><i class="fab fa-twitter"></i></a>
|
||||
<a href="https://instagram.com"><i class="fab fa-instagram"></i></a>
|
||||
<a href="https://www.youtube.com/"><i class="fab fa-linkedin"></i></a>
|
||||
<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>
|
||||
@@ -39,7 +46,7 @@
|
||||
<div class="main-menu">
|
||||
<div class="container">
|
||||
<div class="main-menu__logo">
|
||||
<a href="index.html"><img src="/static/images/logo.png" width="186" alt="Logo"></a>
|
||||
<a href="index.html"><img src="<?php echo htmlentities((string) $config['logo1']); ?>" width="186" alt="Logo"></a>
|
||||
</div>
|
||||
<div class="main-menu__nav">
|
||||
<ul class="main-menu__list">
|
||||
@@ -50,8 +57,28 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="main-menu__right">
|
||||
<a href="#" class="main-menu__search"><i class="layui-icon layui-icon-search"></i></a>
|
||||
<a href="login.html" class="main-menu__login"><i class="layui-icon layui-icon-username"></i></a>
|
||||
<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>
|
||||
@@ -105,7 +132,7 @@
|
||||
<div class="sticky-nav" style="display: none;">
|
||||
<div class="container">
|
||||
<div class="sticky-nav__logo">
|
||||
<a href="index.html"><img src="/static/images/logo.png" width="150" alt="Logo"></a>
|
||||
<a href="index.html"><img src="<?php echo htmlentities((string) $config['logo1']); ?>" width="150" alt="Logo"></a>
|
||||
</div>
|
||||
<div class="sticky-nav__menu">
|
||||
<ul>
|
||||
@@ -116,137 +143,257 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="sticky-nav__right">
|
||||
<a href="#" class="main-menu__search"><i class="layui-icon layui-icon-search"></i></a>
|
||||
<a href="login.html" class="main-menu__login"><i class="layui-icon layui-icon-username"></i></a>
|
||||
<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>
|
||||
|
||||
<script>
|
||||
layui.use(['carousel', 'form'], function(){
|
||||
var carousel = layui.carousel
|
||||
,form = layui.form;
|
||||
|
||||
//图片轮播
|
||||
carousel.render({
|
||||
elem: '#test10'
|
||||
,width: '100%'
|
||||
,height: '86vh'
|
||||
,interval: 4000
|
||||
});
|
||||
|
||||
var $ = layui.$, active = {
|
||||
set: function(othis){
|
||||
var THIS = 'layui-bg-normal'
|
||||
,key = othis.data('key')
|
||||
,options = {};
|
||||
|
||||
othis.css('background-color', '#5FB878').siblings().removeAttr('style');
|
||||
options[key] = othis.data('value');
|
||||
ins3.reload(options);
|
||||
<style>
|
||||
/* 用户头像样式 */
|
||||
#userAvatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
};
|
||||
|
||||
//监听开关
|
||||
form.on('switch(autoplay)', function(){
|
||||
ins3.reload({
|
||||
autoplay: this.checked
|
||||
});
|
||||
});
|
||||
|
||||
$('.demoSet').on('keyup', function(){
|
||||
var value = this.value
|
||||
,options = {};
|
||||
if(!/^\d+$/.test(value)) return;
|
||||
|
||||
options[this.name] = value;
|
||||
ins3.reload(options);
|
||||
});
|
||||
|
||||
// 监听滚动事件
|
||||
$(window).scroll(function() {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > 150) { // 当滚动超过150px时显示固定导航
|
||||
$('.sticky-nav').fadeIn();
|
||||
} else {
|
||||
$('.sticky-nav').fadeOut();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
|
||||
#userDropdownSticky a {
|
||||
color: #0d6efd !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['carousel', 'form', 'layer'], function () {
|
||||
var carousel = layui.carousel,
|
||||
form = layui.form,
|
||||
layer = layui.layer,
|
||||
$ = layui.$;
|
||||
|
||||
//图片轮播
|
||||
carousel.render({
|
||||
elem: '#test10',
|
||||
width: '100%',
|
||||
height: '86vh',
|
||||
interval: 4000
|
||||
});
|
||||
|
||||
$(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>
|
||||
<main class="main-content">
|
||||
<div class="container">
|
||||
<!-- 文章模块 -->
|
||||
<!-- 站点资讯模块 -->
|
||||
<div class="core-block core-module" id="opencourse" style="order: 3;">
|
||||
<div class="module-header">
|
||||
<div>
|
||||
<div class="ModuleTitle_titleWrapper">
|
||||
<h3 class="ModuleTitle_title">站点新闻</h3>
|
||||
<div class="ModuleTitle_subtitle">新鲜资讯 尽在掌握</div>
|
||||
<h3 class="ModuleTitle_title">站点资讯</h3>
|
||||
<div class="tab-container">
|
||||
<div class="tab-header">
|
||||
<div class="tab-item active" data-tab="all">全部</div>
|
||||
<!-- 分类标签将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
</div>
|
||||
<div class="product-list">
|
||||
<div class="opencourse product-item">
|
||||
<div class="video"><img data-v-4477fdbc=""
|
||||
src="https://static001.geekbang.org/resource/image/ff/b8/ff18d73bec1040abf3d7bc7bffb532b8.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
|
||||
alt="" class="cover"><!----></div>
|
||||
<div class="introduction">
|
||||
<div class="title">闪客 · 怎么理解 AI?</div>
|
||||
<div class="subtitle">闪客 | B 站知名科普 UP 主</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="desc">1025人学过</div>
|
||||
<!-- <div class="btn">观看: 123人</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="opencourse product-item">
|
||||
<div class="video"><img data-v-4477fdbc=""
|
||||
src="https://static001.geekbang.org/resource/image/76/cd/762ee7f34a76fbff61d20aae313833cd.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
|
||||
alt="" class="cover">
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<div class="title">多模态对话引擎实战</div>
|
||||
<div class="subtitle">吴桐 | 网易云信音视频技术负责人,流媒体首席架构师</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="desc">380人学过</div>
|
||||
<!-- <div class="btn">观看: 123人</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="opencourse product-item">
|
||||
<div class="video"><img data-v-4477fdbc=""
|
||||
src="https://static001.geekbang.org/resource/image/4y/da/4yyfb232bfbfbdcc6ed827c16b04a9da.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
|
||||
alt="" class="cover"><!----></div>
|
||||
<div class="introduction">
|
||||
<div class="title">极客视点</div>
|
||||
<div class="subtitle">极客时间 | 编辑部</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="desc">12.4w人学过</div>
|
||||
<!-- <div class="btn">观看: 123人</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="opencourse product-item">
|
||||
<div class="video"><img data-v-4477fdbc=""
|
||||
src="https://static001.geekbang.org/resource/image/0f/69/0f95b62cf7yy6d6yy674f090d063b669.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
|
||||
alt="" class="cover"><!----></div>
|
||||
<div class="introduction">
|
||||
<div class="title">周志明的软件架构课</div>
|
||||
<div class="subtitle">周志明 | 博士,远光软件研究院院长,《深入理解Java虚拟机》《凤凰架构》等书作者</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="desc">6.0w人学过</div>
|
||||
<!-- <div class="btn">观看: 123人</div>d -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="product-list" id="webArticlesList">
|
||||
<!-- 文章将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 文章模块 -->
|
||||
<div class="core-block core-module" id="opencourse" style="order: 3;">
|
||||
<!-- 技术文章模块 -->
|
||||
<div class="core-block core-module" id="techArticles" style="order: 3;">
|
||||
<div class="module-header">
|
||||
<div>
|
||||
<div class="ModuleTitle_titleWrapper">
|
||||
@@ -254,104 +401,246 @@ layui.use(['carousel', 'form'], function(){
|
||||
<div class="tab-container">
|
||||
<div class="tab-header">
|
||||
<div class="tab-item active" data-tab="all">全部</div>
|
||||
<?php foreach($articleList as $cateName => $articles): ?>
|
||||
<div class="tab-item" data-tab="<?php echo htmlentities((string) $cateName); ?>"><?php echo htmlentities((string) $cateName); ?></div>
|
||||
<?php endforeach; ?>
|
||||
<!-- 分类标签将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
</div>
|
||||
<div class="product-list">
|
||||
<!-- 全部文章 -->
|
||||
<div class="tab-content active" data-tab="all">
|
||||
<?php foreach($articleList as $cateName => $articles): foreach($articles as $article): ?>
|
||||
<div class="opencourse product-item"
|
||||
onclick="window.open('<?php echo url('article/detail'); ?>?id=<?php echo htmlentities((string) $article['id']); ?>', '_blank')">
|
||||
<div class="video">
|
||||
<img src="<?php echo htmlentities((string) $article['image']); ?>" alt="" class="cover">
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<div class="title"><?php echo htmlentities((string) $article['title']); ?></div>
|
||||
<div class="publishdate"><?php echo htmlentities((string) $article['publishdate']); ?></div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="views"><i class="fa-solid fa-eye "></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['views']); ?></span></div>
|
||||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['author']); ?></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<!-- 分类文章 -->
|
||||
<?php foreach($articleList as $cateName => $articles): ?>
|
||||
<div class="tab-content" data-tab="<?php echo htmlentities((string) $cateName); ?>">
|
||||
<?php foreach($articles as $article): ?>
|
||||
<div class="opencourse product-item"
|
||||
onclick="window.open('<?php echo url('article/detail'); ?>?id=<?php echo htmlentities((string) $article['id']); ?>', '_blank')">
|
||||
<div class="video">
|
||||
<img src="<?php echo htmlentities((string) $article['image']); ?>" alt="" class="cover">
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<div class="title"><?php echo htmlentities((string) $article['title']); ?></div>
|
||||
<div class="publishdate"><?php echo htmlentities((string) $article['publishdate']); ?></div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="views"><i class="fa-solid fa-eye "></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['views']); ?></span></div>
|
||||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['author']); ?></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="product-list" id="techArticlesList">
|
||||
<!-- 文章将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// 获取所有tab项和内容
|
||||
const tabItems = document.querySelectorAll('.tab-item');
|
||||
const tabContents = document.querySelectorAll('.tab-content');
|
||||
// 加载站点新闻
|
||||
function loadWebArticles() {
|
||||
fetch('/index/index/siteNewslist')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 1) {
|
||||
// 渲染分类标签
|
||||
if (result.categories) {
|
||||
renderCategoryTabs(result.categories, 'opencourse');
|
||||
}
|
||||
// 渲染文章列表
|
||||
if (result.articles && result.articles.length > 0) {
|
||||
// 只取最新的4条
|
||||
renderWebArticles(result.articles.slice(0, 4), 'webArticlesList');
|
||||
} else {
|
||||
showNoData('webArticlesList');
|
||||
}
|
||||
} else {
|
||||
showNoData('webArticlesList');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError('webArticlesList');
|
||||
});
|
||||
}
|
||||
|
||||
// 为每个tab项添加点击事件
|
||||
// 加载技术文章
|
||||
function loadTechArticles() {
|
||||
fetch('/index/index/technicalArticleslist')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 1) {
|
||||
// 渲染分类标签
|
||||
if (result.categories) {
|
||||
renderCategoryTabs(result.categories, 'techArticles');
|
||||
}
|
||||
// 渲染文章列表
|
||||
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');
|
||||
}
|
||||
} else {
|
||||
showNoData('techArticlesList');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError('techArticlesList');
|
||||
});
|
||||
}
|
||||
|
||||
// 显示无数据提示
|
||||
function showNoData(containerId) {
|
||||
document.getElementById(containerId).innerHTML = '<div class="no-data">暂无数据</div>';
|
||||
}
|
||||
|
||||
// 显示错误提示
|
||||
function showError(containerId) {
|
||||
document.getElementById(containerId).innerHTML = '<div class="error-message">网络请求失败</div>';
|
||||
}
|
||||
|
||||
// 渲染分类标签
|
||||
function renderCategoryTabs(categories, moduleId) {
|
||||
const tabHeader = document.querySelector(`#${moduleId} .tab-header`);
|
||||
if (!tabHeader) return;
|
||||
|
||||
// 保留"全部"标签
|
||||
const allTab = tabHeader.querySelector('.tab-item[data-tab="all"]');
|
||||
tabHeader.innerHTML = '';
|
||||
tabHeader.appendChild(allTab);
|
||||
|
||||
// 添加分类标签
|
||||
if (Array.isArray(categories)) {
|
||||
categories.forEach(category => {
|
||||
const tabItem = document.createElement('div');
|
||||
tabItem.className = 'tab-item';
|
||||
tabItem.setAttribute('data-tab', category.id);
|
||||
tabItem.textContent = category.name;
|
||||
tabHeader.appendChild(tabItem);
|
||||
});
|
||||
}
|
||||
|
||||
// 重新绑定点击事件
|
||||
bindTabEvents(moduleId);
|
||||
}
|
||||
|
||||
// 绑定标签点击事件
|
||||
function bindTabEvents(moduleId) {
|
||||
const tabItems = document.querySelectorAll(`#${moduleId} .tab-item`);
|
||||
tabItems.forEach(tab => {
|
||||
tab.addEventListener('click', function () {
|
||||
tab.addEventListener('click', function() {
|
||||
// 移除所有active类
|
||||
tabItems.forEach(item => item.classList.remove('active'));
|
||||
tabContents.forEach(content => content.classList.remove('active'));
|
||||
|
||||
// 添加active类到当前点击的tab
|
||||
this.classList.add('active');
|
||||
|
||||
// 显示对应的内容
|
||||
const tabName = this.getAttribute('data-tab');
|
||||
const activeContent = document.querySelector(`.tab-content[data-tab="${tabName}"]`);
|
||||
if (activeContent) {
|
||||
activeContent.classList.add('active');
|
||||
|
||||
// 获取选中的分类ID
|
||||
const selectedCategoryId = this.getAttribute('data-tab');
|
||||
|
||||
// 重新加载对应分类的文章
|
||||
if (moduleId === 'opencourse') {
|
||||
loadCategoryArticles(selectedCategoryId, 'webArticlesList');
|
||||
} else {
|
||||
loadCategoryArticles(selectedCategoryId, 'techArticlesList');
|
||||
}
|
||||
|
||||
// 添加切换动画效果
|
||||
activeContent.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
activeContent.style.opacity = '1';
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 加载分类文章
|
||||
function loadCategoryArticles(categoryId, containerId) {
|
||||
const url = containerId === 'webArticlesList' ? '/index/index/siteNewslist' : '/index/index/technicalArticleslist';
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 1) {
|
||||
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 {
|
||||
// 站点资讯部分逻辑不变
|
||||
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);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError(containerId);
|
||||
});
|
||||
}
|
||||
|
||||
// 渲染文章列表
|
||||
function renderWebArticles(articles, containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (!container) return;
|
||||
|
||||
let html = '';
|
||||
if (Array.isArray(articles)) {
|
||||
articles.forEach(article => {
|
||||
html += createArticleHtml(article);
|
||||
});
|
||||
}
|
||||
|
||||
container.innerHTML = html || '<div class="no-data">暂无数据</div>';
|
||||
}
|
||||
|
||||
// 创建文章HTML
|
||||
function createArticleHtml(article) {
|
||||
if (!article) return '';
|
||||
|
||||
// 格式化日期
|
||||
const publishDate = new Date(article.publishdate * 1000);
|
||||
const formattedDate = publishDate.toLocaleDateString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
});
|
||||
|
||||
return `
|
||||
<div class="opencourse product-item" onclick="window.open('/index/article/detail?id=${article.id || ''}', '_blank')">
|
||||
<div class="video">
|
||||
<img src="${article.image || ''}" alt="" class="cover">
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<div class="title">${article.title || '无标题'}</div>
|
||||
<div class="publishdate">${formattedDate}</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="views"><i class="fa-solid fa-eye"></i><span style="margin-left: 5px;">${article.views || 0}</span></div>
|
||||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">${article.author || '未知作者'}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// 页面加载完成后执行
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadWebArticles();
|
||||
loadTechArticles();
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
<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="/static/images/logo-l-w.png" alt="" height="70">
|
||||
<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;">
|
||||
@@ -383,7 +672,7 @@ layui.use(['carousel', 'form'], function(){
|
||||
|
||||
<div>
|
||||
<div class="text-center">
|
||||
<img src="/static/images/code.png" alt="微信二维码" class="img-fluid" style="max-width: 150px;">
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user