优化接口

This commit is contained in:
2025-12-25 23:16:10 +08:00
parent acf9bc0952
commit 3e9a3731e5
13 changed files with 2860 additions and 1145 deletions
@@ -1,4 +1,4 @@
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1749125154;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1748359853;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1749138336;}*/ ?>
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1766587447;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1766587447;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1766587447;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1766587447;}*/ ?>
<!DOCTYPE html>
<html>
@@ -10,13 +10,32 @@
<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">
<link rel="stylesheet" href="/static/css/all.min.css">
<script src="/static/layui/layui.js" charset="utf-8"></script>
<script src="/static/js/bootstrap.bundle.js"></script>
<script src="/static/js/all.min.js"></script>
</head>
<body>
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
// 获取当前登录状态
$isLoggedIn = false;
$userInfo = [
@@ -87,6 +106,22 @@ $loginStatus = [
<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']): ?>
@@ -143,14 +178,17 @@ $loginStatus = [
</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>
<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">
@@ -193,217 +231,6 @@ $loginStatus = [
</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;
}
.main-menu__right {
display: flex;
align-items: center;
}
.username {
display: flex;
align-items: center;
}
</style>
<script>
// 在页面加载时立即执行
(function () {
@@ -435,8 +262,97 @@ $loginStatus = [
}
})();
layui.use(['carousel', 'form', 'layer'], function () {
var carousel = layui.carousel, form = layui.form, layer = layui.layer, $ = layui.$;
// 搜索功能相关代码
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() {
@@ -690,6 +606,326 @@ $loginStatus = [
});
});
</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">
<!-- 站点资讯模块 -->
@@ -706,7 +942,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=1', '_blank')">更多</div>
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=3', '_blank')">更多</div>
</div>
<div class="product-list" id="webArticlesList">
<!-- 文章将通过JavaScript动态加载 -->
@@ -748,7 +984,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn" onclick="window.open('/index/program/index?cateid=2', '_blank')">更多</div>
<div class="more-btn" onclick="window.open('/index/resources/index?cateid=2', '_blank')">更多</div>
</div>
<div class="product-list" id="resourcesDownloadList">
<!-- 文章将通过JavaScript动态加载 -->
@@ -769,7 +1005,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn" onclick="window.open('/index/program/index?cateid=1', '_blank')">更多</div>
<div class="more-btn" onclick="window.open('/index/resources/index?cateid=1', '_blank')">更多</div>
</div>
<div class="product-list" id="programDownloadList">
<!-- 程序将通过JavaScript动态加载 -->
@@ -790,7 +1026,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn" onclick="window.open('/index/game/index?cateid=8', '_blank')">更多</div>
<div class="more-btn" onclick="window.open('/index/resources/index?cateid=8', '_blank')">更多</div>
</div>
<div class="product-list" id="gameDownloadList">
<!-- 游戏将通过JavaScript动态加载 -->
@@ -982,17 +1218,17 @@ $loginStatus = [
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'));
// 添加active类到当前点击的tab
this.classList.add('active');
// 获取选中的分类ID
const selectedCategoryId = this.getAttribute('data-tab');
// 根据不同模块加载对应数据
switch(moduleId) {
switch (moduleId) {
case 'opencourse':
loadCategoryArticles(selectedCategoryId, 'webArticlesList');
break;
@@ -1079,7 +1315,7 @@ $loginStatus = [
// 创建文章HTML
function createArticleHtml(article) {
if (!article) return '';
// 格式化日期
const publishDate = new Date(article.publishdate * 1000);
const formattedDate = publishDate.toLocaleDateString('zh-CN', {
@@ -1087,7 +1323,7 @@ $loginStatus = [
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">
@@ -1123,7 +1359,7 @@ $loginStatus = [
// 创建资源HTML
function createResourceHtml(resource) {
if (!resource) return '';
// 格式化日期
const uploadDate = new Date(resource.uploaddate * 1000);
const formattedDate = uploadDate.toLocaleDateString('zh-CN', {
@@ -1131,7 +1367,7 @@ $loginStatus = [
month: '2-digit',
day: '2-digit'
});
// 格式化文件大小
const formatFileSize = (bytes) => {
if (bytes === 0) return '0 B';
@@ -1178,7 +1414,7 @@ $loginStatus = [
// 创建程序HTML
function createProgramHtml(program) {
if (!program) return '';
// 格式化日期
const createDate = new Date(program.create_time * 1000);
const formattedDate = createDate.toLocaleDateString('zh-CN', {
@@ -1186,11 +1422,11 @@ $loginStatus = [
month: '2-digit',
day: '2-digit'
});
return `
<div class="opencourse product-item" onclick="window.open('/index/program/detail?id=${program.id || ''}', '_blank')">
<div class="opencourse product-item" onclick="window.open('/index/resources/detail?id=${program.id || ''}', '_blank')">
<div class="video">
<img src="${program.icon || '/static/images/default-program.png'}" alt="" class="cover">
<img src="${program.icon || ''}" alt="" class="cover">
</div>
<div class="introduction">
<div class="title">${program.title || '无标题'}</div>
@@ -1266,9 +1502,9 @@ $loginStatus = [
// 创建游戏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="opencourse product-item" onclick="window.open('/index/resources/detail?id=${game.id || ''}', '_blank')">
<div class="video">
<img src="${game.icon || '/static/images/default-game.png'}" alt="" class="cover">
</div>
@@ -1307,7 +1543,7 @@ $loginStatus = [
}
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
loadWebArticles();
loadTechArticles();
loadResources();