1615 lines
62 KiB
PHP
1615 lines
62 KiB
PHP
<?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:1749258723;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1749281834;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1749170849;}*/ ?>
|
||
<!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>
|
||
</head>
|
||
|
||
<body>
|
||
<?php
|
||
/**
|
||
* 商业使用授权协议
|
||
*
|
||
* Copyright (c) 2025 [云泽网]. 保留所有权利.
|
||
*
|
||
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
|
||
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
|
||
*
|
||
* 授权购买请联系: 357099073@qq.com
|
||
* 官方网站: https://www.yunzer.cn
|
||
*
|
||
* 评估用户须知:
|
||
* 1. 禁止移除版权声明
|
||
* 2. 禁止用于生产环境
|
||
* 3. 禁止转售或分发
|
||
*/
|
||
|
||
// 获取当前登录状态
|
||
$isLoggedIn = false;
|
||
$userInfo = [
|
||
'is_login' => false,
|
||
'name' => '',
|
||
'avatar' => '/static/images/avatar.png' // 默认头像
|
||
];
|
||
|
||
// 检查cookie
|
||
$userAccount = cookie('user_account');
|
||
if ($userAccount) {
|
||
$isLoggedIn = true;
|
||
$userInfo = [
|
||
'is_login' => true,
|
||
'name' => cookie('user_name'),
|
||
'avatar' => cookie('user_avatar') ? cookie('user_avatar') : '/static/images/avatar.png'
|
||
];
|
||
}
|
||
|
||
// 添加一个隐藏的div来存储登录状态
|
||
$loginStatus = [
|
||
'isLoggedIn' => $isLoggedIn,
|
||
'userAccount' => $userAccount ?? ''
|
||
];
|
||
?>
|
||
|
||
<!-- 添加一个隐藏的div来存储登录状态 -->
|
||
<div id="loginStatus" style="display: none;" data-is-logged-in="<?php echo htmlentities((string) $isLoggedIn); ?>" data-user-account="<?php echo isset($userAccount) ? htmlentities((string) $userAccount) : ''; ?>">
|
||
</div>
|
||
|
||
<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="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="/"><img src="<?php echo htmlentities((string) $config['logo1']); ?>" width="186" alt="Logo"></a>
|
||
</div>
|
||
<div class="main-menu__nav">
|
||
<ul class="main-menu__list">
|
||
<li><a href="/">首页</a></li>
|
||
<li><a href="/index/articles/index?cateid=1">站点资讯</a></li>
|
||
<li><a href="/index/articles/index?cateid=3">技术文章</a></li>
|
||
<li><a href="/index/program/index?cateid=2">办公资源</a></li>
|
||
<li><a href="/index/program/index?cateid=1">程序下载</a></li>
|
||
<li><a href="/index/game/index?cateid=8">游戏下载</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="main-menu__search">
|
||
<i class="layui-icon layui-icon-search search-icon" id="mainSearchIcon"></i>
|
||
</div>
|
||
<!-- 搜索蒙版 -->
|
||
<div class="search-mask" id="searchMask" style="">
|
||
<div class="search-container">
|
||
<div class="search-box">
|
||
<select id="searchType" class="search-type">
|
||
<option value="articles">文章</option>
|
||
<option value="resources">资源</option>
|
||
</select>
|
||
<input type="text" id="searchInput" placeholder="请输入搜索关键词">
|
||
<button class="search-btn" id="searchBtn">搜索</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="main-menu__right">
|
||
<div class="username">
|
||
<?php if ($userInfo['is_login']): ?>
|
||
<span class="username-text"><?php echo htmlentities((string) $userInfo['name']); ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="layui-inline">
|
||
<!-- 根据登录状态显示不同的内容 -->
|
||
<?php if ($userInfo['is_login']): ?>
|
||
<div class="layui-inline" style="position: relative;margin-left:20px;">
|
||
<img src="<?php echo htmlentities((string) $userInfo['avatar']); ?>" 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>
|
||
<?php else: ?>
|
||
<div class="layui-inline">
|
||
<a href="/index/user/login" class="layui-btn layui-btn-normal">登录</a>
|
||
<a href="/index/user/register" class="layui-btn layui-btn-primary">注册</a>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="main-header">
|
||
<!-- Banner轮播 -->
|
||
<div class="layui-carousel" id="test10" lay-filter="test10">
|
||
<div carousel-item="">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 固定导航 -->
|
||
<div class="sticky-nav" style="display: none;">
|
||
<div class="container">
|
||
<div class="sticky-nav__logo">
|
||
<a href="/"><img src="<?php echo htmlentities((string) $config['logo1']); ?>" width="150" alt="Logo"></a>
|
||
</div>
|
||
<div class="sticky-nav__menu">
|
||
<ul>
|
||
<li><a href="/">首页</a></li>
|
||
<li><a href="/index/articles/index?cateid=1">站点资讯</a></li>
|
||
<li><a href="/index/articles/index?cateid=3">技术文章</a></li>
|
||
<li><a href="/index/program/index?cateid=2">办公资源</a></li>
|
||
<li><a href="/index/program/index?cateid=1">程序下载</a></li>
|
||
<li><a href="/index/game/index?cateid=8">游戏下载</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="sticky-nav__search">
|
||
<i class="layui-icon layui-icon-search search-icon" id="stickySearchIcon"></i>
|
||
</div>
|
||
<div class="sticky-nav__right">
|
||
<div class="main-menu__right">
|
||
<div class="username">
|
||
<?php if ($userInfo['is_login']): ?>
|
||
<span class="username-text"><?php echo htmlentities((string) $userInfo['name']); ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="layui-inline">
|
||
<!-- 根据登录状态显示不同的内容 -->
|
||
<?php if ($userInfo['is_login']): ?>
|
||
<div class="layui-inline" style="position: relative;margin-left:20px;">
|
||
<img src="<?php echo htmlentities((string) $userInfo['avatar']); ?>" 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>
|
||
<?php else: ?>
|
||
<div class="layui-inline">
|
||
<a href="/index/user/login" class="layui-btn layui-btn-normal">登录</a>
|
||
<a href="/index/user/register" class="layui-btn layui-btn-primary">注册</a>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
// 在页面加载时立即执行
|
||
(function () {
|
||
// 检查是否已经刷新过
|
||
if (sessionStorage.getItem('has_refreshed') === 'true') {
|
||
return;
|
||
}
|
||
|
||
// 检查localStorage中是否有用户账号
|
||
var userAccount = localStorage.getItem('user_account');
|
||
if (userAccount) {
|
||
// 同步到cookie
|
||
document.cookie = "user_account=" + userAccount + "; path=/";
|
||
|
||
// 如果有其他必要的数据,也同步到cookie
|
||
var userId = localStorage.getItem('user_id');
|
||
var userName = localStorage.getItem('user_name');
|
||
var userAvatar = localStorage.getItem('user_avatar');
|
||
|
||
if (userId) document.cookie = "user_id=" + userId + "; path=/";
|
||
if (userName) document.cookie = "user_name=" + userName + "; path=/";
|
||
if (userAvatar) document.cookie = "user_avatar=" + userAvatar + "; path=/";
|
||
|
||
// 刷新页面以应用新的cookie,并标记已刷新
|
||
if (!document.cookie.includes('user_id')) {
|
||
sessionStorage.setItem('has_refreshed', 'true');
|
||
window.location.reload();
|
||
}
|
||
}
|
||
})();
|
||
|
||
// 搜索功能相关代码
|
||
layui.use(['layer'], function () {
|
||
var layer = layui.layer;
|
||
var $ = layui.jquery;
|
||
|
||
// 执行搜索
|
||
function executeSearch() {
|
||
var searchInput = document.getElementById('searchInput');
|
||
if (!searchInput) {
|
||
layer.msg('搜索组件初始化失败');
|
||
return;
|
||
}
|
||
|
||
var keyword = searchInput.value.trim();
|
||
var type = document.getElementById('searchType').value;
|
||
|
||
if (!keyword) {
|
||
layer.msg('请输入搜索关键词');
|
||
return;
|
||
}
|
||
|
||
// 跳转到统一的搜索结果页面
|
||
window.location.href = '/index/search/index?keyword=' + encodeURIComponent(keyword) + '&type=' + type;
|
||
}
|
||
|
||
// 绑定事件
|
||
$(function() {
|
||
var searchMask = $('#searchMask');
|
||
var searchInput = $('#searchInput');
|
||
var searchBtn = $('#searchBtn');
|
||
var mainSearchIcon = $('#mainSearchIcon');
|
||
var stickySearchIcon = $('#stickySearchIcon');
|
||
|
||
// 显示搜索框
|
||
function showSearch() {
|
||
searchMask.addClass('show');
|
||
setTimeout(function() {
|
||
searchInput.focus();
|
||
}, 300);
|
||
}
|
||
|
||
// 隐藏搜索框
|
||
function hideSearch() {
|
||
searchMask.removeClass('show');
|
||
searchInput.val('');
|
||
}
|
||
|
||
// 绑定搜索图标点击事件
|
||
mainSearchIcon.on('click', showSearch);
|
||
stickySearchIcon.on('click', showSearch);
|
||
|
||
// 绑定搜索按钮点击事件
|
||
searchBtn.on('click', function(e) {
|
||
e.preventDefault();
|
||
executeSearch();
|
||
});
|
||
|
||
// 绑定回车键搜索
|
||
searchInput.on('keypress', function(e) {
|
||
if (e.which === 13) {
|
||
e.preventDefault();
|
||
executeSearch();
|
||
}
|
||
});
|
||
|
||
// 点击遮罩层关闭搜索框
|
||
searchMask.on('click', function(e) {
|
||
if ($(e.target).hasClass('search-mask')) {
|
||
hideSearch();
|
||
}
|
||
});
|
||
|
||
// 绑定ESC键关闭搜索框
|
||
$(document).on('keydown', function(e) {
|
||
if (e.keyCode === 27 && searchMask.hasClass('show')) {
|
||
hideSearch();
|
||
}
|
||
});
|
||
|
||
// 输入框获得焦点时选中所有文本
|
||
searchInput.on('focus', function() {
|
||
this.select();
|
||
});
|
||
});
|
||
});
|
||
|
||
// 其他功能相关代码
|
||
layui.use(['carousel', 'form'], function () {
|
||
var carousel = layui.carousel;
|
||
var form = layui.form;
|
||
var $ = layui.$;
|
||
|
||
// 检查本地存储并自动登录
|
||
function checkAutoLogin() {
|
||
// 如果已经登录,不再执行自动登录
|
||
if ($('#userAvatarMain').length > 0) {
|
||
return;
|
||
}
|
||
|
||
// 如果已经尝试过自动登录,不再执行
|
||
if (sessionStorage.getItem('auto_login_attempted') === 'true') {
|
||
return;
|
||
}
|
||
|
||
// 从localStorage获取用户账号
|
||
var userAccount = localStorage.getItem('user_account');
|
||
if (userAccount) {
|
||
// 标记已尝试自动登录
|
||
sessionStorage.setItem('auto_login_attempted', 'true');
|
||
|
||
// 发送自动登录请求
|
||
$.ajax({
|
||
url: '/index/user/login',
|
||
type: 'POST',
|
||
data: {
|
||
account: userAccount,
|
||
password: atob(localStorage.getItem('user_password'))
|
||
},
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.code === 0) {
|
||
// 设置cookie
|
||
document.cookie = "user_id=" + res.data.id + "; path=/";
|
||
document.cookie = "user_name=" + res.data.name + "; path=/";
|
||
document.cookie = "user_avatar=" + res.data.avatar + "; path=/";
|
||
document.cookie = "user_account=" + userAccount + "; path=/";
|
||
|
||
// 同时更新localStorage
|
||
localStorage.setItem('user_id', res.data.id);
|
||
localStorage.setItem('user_name', res.data.name);
|
||
localStorage.setItem('user_avatar', res.data.avatar);
|
||
|
||
// 登录成功,强制刷新页面
|
||
window.location.href = window.location.href + '?t=' + new Date().getTime();
|
||
} else {
|
||
// 登录失败,清除所有相关存储
|
||
localStorage.removeItem('user_account');
|
||
localStorage.removeItem('user_password');
|
||
sessionStorage.removeItem('auto_login_attempted');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
// 页面加载时检查自动登录
|
||
checkAutoLogin();
|
||
|
||
// 加载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 () {
|
||
// 先发送退出请求
|
||
$.ajax({
|
||
url: '/index/user/logout',
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.code === 0) {
|
||
// 清除localStorage
|
||
localStorage.removeItem('user_account');
|
||
localStorage.removeItem('user_password');
|
||
localStorage.removeItem('user_id');
|
||
localStorage.removeItem('user_name');
|
||
localStorage.removeItem('user_avatar');
|
||
|
||
// 清除sessionStorage
|
||
sessionStorage.removeItem('auto_login_attempted');
|
||
sessionStorage.removeItem('has_refreshed');
|
||
|
||
// 清除cookie
|
||
document.cookie = "user_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||
document.cookie = "user_name=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||
document.cookie = "user_avatar=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||
document.cookie = "user_account=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||
document.cookie = "user_password=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||
|
||
// 强制刷新页面,不使用缓存
|
||
window.location.href = window.location.href + '?t=' + new Date().getTime();
|
||
}
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
// 监听滚动事件
|
||
$(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';
|
||
});
|
||
|
||
form.on('submit(accountLogin)', function (data) {
|
||
$.ajax({
|
||
url: '<?php echo url("index/user/login"); ?>',
|
||
type: 'POST',
|
||
data: data.field,
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.code === 0) {
|
||
// 存储登录数据,设置7天过期
|
||
var expireTime = new Date().getTime() + 7 * 24 * 60 * 60 * 1000;
|
||
|
||
// 设置localStorage
|
||
localStorage.setItem('user_account', data.field.account);
|
||
localStorage.setItem('user_password', btoa(data.field.password));
|
||
localStorage.setItem('expire_time', expireTime);
|
||
localStorage.setItem('is_auto_login', 'true');
|
||
|
||
// 设置cookie
|
||
document.cookie = "user_id=" + res.data.id + "; path=/";
|
||
document.cookie = "user_name=" + res.data.name + "; path=/";
|
||
document.cookie = "user_avatar=" + res.data.avatar + "; path=/";
|
||
document.cookie = "expire_time=" + expireTime + "; path=/";
|
||
document.cookie = "is_auto_login=true; path=/";
|
||
document.cookie = "user_account=" + data.field.account + "; path=/";
|
||
document.cookie = "user_password=" + btoa(data.field.password) + "; path=/";
|
||
|
||
// 设置sessionStorage
|
||
sessionStorage.setItem('auto_login_attempted', 'true');
|
||
|
||
layer.msg('登录成功', {
|
||
icon: 1,
|
||
time: 2000,
|
||
shade: 0.3
|
||
}, function () {
|
||
// 获取当前页面URL,如果是从其他页面跳转来的,则返回上一页
|
||
var currentUrl = window.location.href;
|
||
var referrer = document.referrer;
|
||
|
||
// 如果是从登录页面跳转来的,则返回上一页
|
||
if (referrer && referrer.includes('/index/user/login')) {
|
||
window.location.href = referrer;
|
||
} else {
|
||
// 否则刷新当前页面
|
||
window.location.href = currentUrl + '?t=' + new Date().getTime();
|
||
}
|
||
});
|
||
layer.msg(res.msg, {
|
||
icon: 2,
|
||
time: 2000
|
||
});
|
||
}
|
||
}
|
||
});
|
||
return false;
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<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;
|
||
}
|
||
|
||
.main-menu__right {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.username {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.search-icon {
|
||
font-size: 20px;
|
||
cursor: pointer;
|
||
color: #333;
|
||
transition: color 0.3s ease;
|
||
}
|
||
|
||
.search-icon:hover {
|
||
color: #1e9fff;
|
||
}
|
||
|
||
.search-mask {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
background: rgba(0, 0, 0, 0.7);
|
||
z-index: 9999;
|
||
display: none;
|
||
opacity: 0;
|
||
transition: opacity 0.3s ease;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
|
||
.search-mask.show {
|
||
display: flex;
|
||
opacity: 1;
|
||
}
|
||
|
||
.search-container {
|
||
position: relative;
|
||
width: 80%;
|
||
padding: 20px;
|
||
background: #fff;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||
transform: translateY(-20px);
|
||
transition: transform 0.3s ease;
|
||
}
|
||
|
||
.search-mask.show .search-container {
|
||
transform: translateY(0);
|
||
}
|
||
|
||
.search-box {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 60px;
|
||
background: #fff;
|
||
border-radius: 30px;
|
||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||
overflow: hidden;
|
||
}
|
||
|
||
.search-box input {
|
||
flex: 1;
|
||
height: 100%;
|
||
padding: 0 20px;
|
||
border: none;
|
||
outline: none;
|
||
font-size: 16px;
|
||
}
|
||
|
||
.search-box button {
|
||
height: 100%;
|
||
padding: 0 30px;
|
||
border: none;
|
||
background: #1E9FFF;
|
||
color: #fff;
|
||
font-size: 16px;
|
||
cursor: pointer;
|
||
transition: background-color 0.3s;
|
||
}
|
||
|
||
.search-box button:hover {
|
||
background: #1a8fe6;
|
||
}
|
||
|
||
.search-type {
|
||
height: 100%;
|
||
padding: 0 15px;
|
||
border: none;
|
||
border-right: 1px solid #eee;
|
||
background: #f8f8f8;
|
||
color: #666;
|
||
font-size: 14px;
|
||
cursor: pointer;
|
||
outline: none;
|
||
appearance: none;
|
||
-webkit-appearance: none;
|
||
-moz-appearance: none;
|
||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
|
||
background-repeat: no-repeat;
|
||
background-position: right 10px center;
|
||
background-size: 12px;
|
||
padding-right: 30px;
|
||
}
|
||
|
||
.search-type:hover {
|
||
background-color: #f0f0f0;
|
||
}
|
||
|
||
.search-type:focus {
|
||
background-color: #fff;
|
||
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
|
||
}
|
||
</style>
|
||
<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="tab-container">
|
||
<div class="tab-header">
|
||
<div class="tab-item active" data-tab="all">全部</div>
|
||
<!-- 分类标签将通过JavaScript动态加载 -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=1', '_blank')">更多</div>
|
||
</div>
|
||
<div class="product-list" id="webArticlesList">
|
||
<!-- 文章将通过JavaScript动态加载 -->
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 技术文章模块 -->
|
||
<div class="core-block core-module" id="techArticles" style="order: 3;">
|
||
<div class="module-header">
|
||
<div>
|
||
<div class="ModuleTitle_titleWrapper">
|
||
<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" onclick="window.open('/index/articles/index?cateid=3', '_blank')">更多</div>
|
||
</div>
|
||
<div class="product-list" id="techArticlesList">
|
||
<!-- 文章将通过JavaScript动态加载 -->
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 资源下载模块 -->
|
||
<div class="core-block core-module" id="resourcesDownload" style="order: 3;">
|
||
<div class="module-header">
|
||
<div>
|
||
<div class="ModuleTitle_titleWrapper">
|
||
<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" onclick="window.open('/index/program/index?cateid=2', '_blank')">更多</div>
|
||
</div>
|
||
<div class="product-list" id="resourcesDownloadList">
|
||
<!-- 文章将通过JavaScript动态加载 -->
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 程序下载模块 -->
|
||
<div class="core-block core-module" id="programDownload" style="order: 3;">
|
||
<div class="module-header">
|
||
<div>
|
||
<div class="ModuleTitle_titleWrapper">
|
||
<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" onclick="window.open('/index/program/index?cateid=1', '_blank')">更多</div>
|
||
</div>
|
||
<div class="product-list" id="programDownloadList">
|
||
<!-- 程序将通过JavaScript动态加载 -->
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 游戏下载模块 -->
|
||
<div class="core-block core-module" id="gameDownload" style="order: 3;">
|
||
<div class="module-header">
|
||
<div>
|
||
<div class="ModuleTitle_titleWrapper">
|
||
<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" onclick="window.open('/index/game/index?cateid=8', '_blank')">更多</div>
|
||
</div>
|
||
<div class="product-list" id="gameDownloadList">
|
||
<!-- 游戏将通过JavaScript动态加载 -->
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</main>
|
||
|
||
<script>
|
||
// 加载站点新闻
|
||
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');
|
||
});
|
||
}
|
||
|
||
// 加载技术文章
|
||
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 loadResources() {
|
||
fetch('/index/index/resourcesList')
|
||
.then(response => response.json())
|
||
.then(result => {
|
||
if (result.code === 1) {
|
||
// 渲染分类标签
|
||
if (result.categories) {
|
||
renderCategoryTabs(result.categories, 'resourcesDownload');
|
||
}
|
||
// 渲染资源列表
|
||
if (result.resources && result.resources.length > 0) {
|
||
// 只取最新的8条
|
||
renderResources(result.resources.slice(0, 8), 'resourcesDownloadList');
|
||
} else {
|
||
showNoData('resourcesDownloadList');
|
||
}
|
||
} else {
|
||
showNoData('resourcesDownloadList');
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error('请求失败:', error);
|
||
showError('resourcesDownloadList');
|
||
});
|
||
}
|
||
|
||
// 加载程序下载
|
||
function loadPrograms() {
|
||
fetch('/index/index/programList')
|
||
.then(response => response.json())
|
||
.then(result => {
|
||
if (result.code === 1) {
|
||
// 渲染分类标签
|
||
if (result.categories) {
|
||
renderCategoryTabs(result.categories, 'programDownload');
|
||
}
|
||
// 渲染程序列表
|
||
if (result.programs && result.programs.length > 0) {
|
||
// 只取最新的8条
|
||
renderPrograms(result.programs.slice(0, 8), 'programDownloadList');
|
||
} else {
|
||
showNoData('programDownloadList');
|
||
}
|
||
} else {
|
||
showNoData('programDownloadList');
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error('请求失败:', error);
|
||
showError('programDownloadList');
|
||
});
|
||
}
|
||
|
||
// 加载游戏下载
|
||
function loadGames() {
|
||
fetch('/index/index/gameList')
|
||
.then(response => response.json())
|
||
.then(result => {
|
||
if (result.code === 0) {
|
||
// 渲染分类标签
|
||
if (result.data.categories) {
|
||
renderCategoryTabs(result.data.categories, 'gameDownload');
|
||
}
|
||
// 渲染游戏列表
|
||
if (result.data.games && result.data.games.length > 0) {
|
||
renderGames(result.data.games, 'gameDownloadList');
|
||
} else {
|
||
showNoData('gameDownloadList');
|
||
}
|
||
} else {
|
||
showNoData('gameDownloadList');
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error('请求失败:', error);
|
||
showError('gameDownloadList');
|
||
});
|
||
}
|
||
|
||
// 显示无数据提示
|
||
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 () {
|
||
// 移除所有active类
|
||
tabItems.forEach(item => item.classList.remove('active'));
|
||
// 添加active类到当前点击的tab
|
||
this.classList.add('active');
|
||
|
||
// 获取选中的分类ID
|
||
const selectedCategoryId = this.getAttribute('data-tab');
|
||
|
||
// 根据不同模块加载对应数据
|
||
switch (moduleId) {
|
||
case 'opencourse':
|
||
loadCategoryArticles(selectedCategoryId, 'webArticlesList');
|
||
break;
|
||
case 'techArticles':
|
||
loadCategoryArticles(selectedCategoryId, 'techArticlesList');
|
||
break;
|
||
case 'resourcesDownload':
|
||
loadCategoryResources(selectedCategoryId, 'resourcesDownloadList');
|
||
break;
|
||
case 'programDownload':
|
||
loadCategoryPrograms(selectedCategoryId, 'programDownloadList');
|
||
break;
|
||
case 'gameDownload':
|
||
loadCategoryGames(selectedCategoryId, 'gameDownloadList');
|
||
break;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
// 加载分类文章
|
||
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/articles/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>
|
||
`;
|
||
}
|
||
|
||
// 渲染资源列表
|
||
function renderResources(resources, containerId) {
|
||
const container = document.getElementById(containerId);
|
||
if (!container) return;
|
||
|
||
let html = '';
|
||
if (Array.isArray(resources)) {
|
||
resources.forEach(resource => {
|
||
html += createResourceHtml(resource);
|
||
});
|
||
}
|
||
|
||
container.innerHTML = html || '<div class="no-data">暂无数据</div>';
|
||
}
|
||
|
||
// 创建资源HTML
|
||
function createResourceHtml(resource) {
|
||
if (!resource) return '';
|
||
|
||
// 格式化日期
|
||
const uploadDate = new Date(resource.uploaddate * 1000);
|
||
const formattedDate = uploadDate.toLocaleDateString('zh-CN', {
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit'
|
||
});
|
||
|
||
// 格式化文件大小
|
||
const formatFileSize = (bytes) => {
|
||
if (bytes === 0) return '0 B';
|
||
const k = 1024;
|
||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||
};
|
||
|
||
return `
|
||
<div class="opencourse product-item" onclick="window.open('/index/resource/detail?id=${resource.id || ''}', '_blank')">
|
||
<div class="video">
|
||
<img src="${resource.thumbnail || '/static/images/default-resource.png'}" alt="" class="cover">
|
||
<div class="file-type">${resource.filetype || '未知类型'}</div>
|
||
</div>
|
||
<div class="introduction">
|
||
<div class="title">${resource.title || '无标题'}</div>
|
||
<div class="description">${resource.description || '暂无描述'}</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;">${resource.views || 0}</span></div>
|
||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">${resource.uploader || '未知作者'}</span></div>
|
||
</div>
|
||
</div>
|
||
`;
|
||
}
|
||
|
||
// 渲染程序列表
|
||
function renderPrograms(programs, containerId) {
|
||
const container = document.getElementById(containerId);
|
||
if (!container) return;
|
||
|
||
let html = '';
|
||
if (Array.isArray(programs)) {
|
||
programs.forEach(program => {
|
||
html += createProgramHtml(program);
|
||
});
|
||
}
|
||
|
||
container.innerHTML = html || '<div class="no-data">暂无数据</div>';
|
||
}
|
||
|
||
// 创建程序HTML
|
||
function createProgramHtml(program) {
|
||
if (!program) return '';
|
||
|
||
// 格式化日期
|
||
const createDate = new Date(program.create_time * 1000);
|
||
const formattedDate = createDate.toLocaleDateString('zh-CN', {
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit'
|
||
});
|
||
|
||
return `
|
||
<div class="opencourse product-item" onclick="window.open('/index/program/detail?id=${program.id || ''}', '_blank')">
|
||
<div class="video">
|
||
<img src="${program.icon || ''}" alt="" class="cover">
|
||
</div>
|
||
<div class="introduction">
|
||
<div class="title">${program.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;">${program.views || 0}</span></div>
|
||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">${program.uploader || '未知作者'}</span></div>
|
||
</div>
|
||
</div>
|
||
`;
|
||
}
|
||
|
||
// 加载分类资源
|
||
function loadCategoryResources(categoryId, containerId) {
|
||
fetch('/index/index/resourcesList')
|
||
.then(response => response.json())
|
||
.then(result => {
|
||
if (result.code === 1) {
|
||
if (categoryId === 'all') {
|
||
renderResources(result.resources.slice(0, 8), containerId);
|
||
} else {
|
||
const filteredResources = result.resources.filter(resource => resource.cate == categoryId);
|
||
renderResources(filteredResources, containerId);
|
||
}
|
||
} else {
|
||
showNoData(containerId);
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error('请求失败:', error);
|
||
showError(containerId);
|
||
});
|
||
}
|
||
|
||
// 加载分类程序
|
||
function loadCategoryPrograms(categoryId, containerId) {
|
||
fetch('/index/index/programList')
|
||
.then(response => response.json())
|
||
.then(result => {
|
||
if (result.code === 1) {
|
||
if (categoryId === 'all') {
|
||
renderPrograms(result.programs.slice(0, 8), containerId);
|
||
} else {
|
||
const filteredPrograms = result.programs.filter(program => program.cate == categoryId);
|
||
renderPrograms(filteredPrograms, containerId);
|
||
}
|
||
} else {
|
||
showNoData(containerId);
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error('请求失败:', error);
|
||
showError(containerId);
|
||
});
|
||
}
|
||
|
||
// 渲染游戏列表
|
||
function renderGames(games, containerId) {
|
||
const container = document.getElementById(containerId);
|
||
if (!container) return;
|
||
|
||
let html = '';
|
||
if (Array.isArray(games)) {
|
||
games.forEach(game => {
|
||
html += createGameHtml(game);
|
||
});
|
||
}
|
||
|
||
container.innerHTML = html || '<div class="no-data">暂无数据</div>';
|
||
}
|
||
|
||
// 创建游戏HTML
|
||
function createGameHtml(game) {
|
||
if (!game) return '';
|
||
|
||
return `
|
||
<div class="opencourse product-item" onclick="window.open('/index/game/detail?id=${game.id || ''}', '_blank')">
|
||
<div class="video">
|
||
<img src="${game.icon || '/static/images/default-game.png'}" alt="" class="cover">
|
||
</div>
|
||
<div class="introduction">
|
||
<div class="title">${game.title || '无标题'}</div>
|
||
<div class="publishdate">${game.create_time || ''}</div>
|
||
</div>
|
||
<div class="bottom">
|
||
<div class="views"><i class="fa-solid fa-eye"></i><span style="margin-left: 5px;">${game.views || 0}</span></div>
|
||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">${game.uploader || '未知作者'}</span></div>
|
||
</div>
|
||
</div>
|
||
`;
|
||
}
|
||
|
||
// 加载分类游戏
|
||
function loadCategoryGames(categoryId, containerId) {
|
||
fetch('/index/index/gameList')
|
||
.then(response => response.json())
|
||
.then(result => {
|
||
if (result.code === 0) {
|
||
if (categoryId === 'all') {
|
||
renderGames(result.data.games, containerId);
|
||
} else {
|
||
const filteredGames = result.data.games.filter(game => game.cate == categoryId);
|
||
renderGames(filteredGames, containerId);
|
||
}
|
||
} else {
|
||
showNoData(containerId);
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error('请求失败:', error);
|
||
showError(containerId);
|
||
});
|
||
}
|
||
|
||
// 页面加载完成后执行
|
||
document.addEventListener('DOMContentLoaded', function () {
|
||
loadWebArticles();
|
||
loadTechArticles();
|
||
loadResources();
|
||
loadPrograms();
|
||
loadGames();
|
||
});
|
||
</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="<?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="container wow fadeInUp animated" data-wow-delay="400ms"
|
||
style="visibility: visible; animation-delay: 400ms; animation-name: fadeInUp;">
|
||
<a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow"><?php echo htmlentities((string) $config['admin_icp']); ?></a>
|
||
</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>
|
||
|
||
</body>
|
||
|
||
</html>
|