修复bug

This commit is contained in:
云泽网 2025-05-21 00:40:14 +08:00
parent ade061223e
commit d70257ed8f
90 changed files with 477 additions and 175 deletions

View File

@ -106,6 +106,7 @@ class ResourcesController extends BaseController
'url' => input('post.url'),
'fileurl' => input('post.fileurl'),
'code' => input('post.code'),
'zipcode' => input('post.zipcode'),
'uploader' => input('post.uploader'),
'desc' => input('post.desc'),
'content' => input('post.content'),
@ -155,6 +156,7 @@ class ResourcesController extends BaseController
'fileurl' => $data['fileurl'],
'url' => $data['url'],
'code' => $data['code'],
'zipcode' => $data['zipcode'],
'sort' => $data['sort'],
'number' => $data['number'],
'content' => $data['content'],

View File

@ -112,6 +112,14 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">解压密码</label>
<div class="layui-input-block">
<input type="text" name="zipcode" required placeholder="请输入解压密码" autocomplete="off"
class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">

View File

@ -113,6 +113,14 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">解压密码</label>
<div class="layui-input-block">
<input type="text" name="zipcode" required placeholder="请输入解压密码" autocomplete="off"
class="layui-input" value="{$resource.zipcode|default=''}" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">

View File

@ -1 +0,0 @@

View File

@ -17,9 +17,9 @@
<h1 class="game-title"><?php echo $game['title']; ?></h1>
<div class="game-meta">
<span class="game-category"><?php echo $cateName; ?></span>
<span class="game-views"><i class="fa-solid fa-eye"></i> <?php echo $game['views']; ?> 次浏览</span>
<span class="game-views"><i class="fa-solid fa-eye"></i> <?php echo $game['views']; ?> </span>
<span class="game-downloads"><i class="fa-solid fa-download"></i> <span
id="gameDownloads"><?php echo $game['downloads']; ?></span> 次下载</span>
id="gameDownloads"><?php echo $game['downloads']; ?></span> </span>
</div>
</div>
<div class="game-content">
@ -43,6 +43,13 @@
</div>
</div>
<div class="game-navigation">
<div class="prev-game" id="prevGame">
</div>
<div class="next-game" id="nextGame">
</div>
</div>
<!-- 相关游戏 -->
<?php if (!empty($relatedGames)): ?>
<div class="related-games">
@ -56,7 +63,7 @@
alt="<?php echo $related['title']; ?>">
</div>
<div class="game-info">
<h4 class="game-title"><?php echo $related['title']; ?></h4>
<h4 class="game-title-1"><?php echo $related['title']; ?></h4>
</div>
</div>
<?php endforeach; ?>
@ -83,6 +90,44 @@
return;
}
// 获取游戏详情
fetch('/index/game/detail?id=' + gameId, {
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 渲染上一篇
const prevGame = document.getElementById('prevGame');
if (result.data.prevGame) {
prevGame.innerHTML = `
<a href="/index/game/detail?id=${result.data.prevGame.id}">
<i class="fa fa-arrow-left"></i> 上一篇:${result.data.prevGame.title}
</a>
`;
} else {
prevGame.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>';
}
// 渲染下一篇
const nextGame = document.getElementById('nextGame');
if (result.data.nextGame) {
nextGame.innerHTML = `
<a href="/index/game/detail?id=${result.data.nextGame.id}">
下一篇:${result.data.nextGame.title} <i class="fa fa-arrow-right"></i>
</a>
`;
} else {
nextGame.innerHTML = '<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>';
}
}
})
.catch(error => {
console.error('获取游戏详情失败:', error);
});
// 更新访问次数
updateGameViews(gameId);
@ -105,7 +150,7 @@
// 直接使用返回的URL
if (data.data && data.data.url) {
window.location.href = data.data.url;
window.open(data.data.url, '_blank');
} else {
alert('下载地址不存在');
}
@ -124,7 +169,7 @@
const codeBtn = document.getElementById('codeBtn');
if (codeBtn) {
codeBtn.addEventListener('click', function() {
const code = '{$game.code}';
const code = '<?php echo $game['code']; ?>';
if (code) {
// 创建一个临时输入框
const tempInput = document.createElement('input');
@ -185,7 +230,7 @@
if (result.code === 1) {
const viewsElement = document.querySelector('.game-views');
if (viewsElement) {
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views} 次浏览`;
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views}`;
}
}
})
@ -217,11 +262,27 @@
}
.game-title {
font-size: 28px;
font-size: 30px;
font-weight: 700;
color: #333;
margin-bottom: 15px;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.game-title-1 {
font-size: 16px;
font-weight: 700;
color: #333;
margin-bottom: 15px;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.game-meta {
@ -273,6 +334,29 @@
border-bottom: 1px solid #eee;
}
.game-navigation {
display: flex;
justify-content: space-between;
margin: 30px 0;
}
.prev-game,
.next-game {
max-width: 45%;
}
.prev-game a,
.next-game a {
color: #333 !important;
text-decoration: none;
}
.prev-game a:hover,
.next-game a:hover {
color: #f57005 !important;
transition: all 0.3s ease;
}
.btn {
/* background: #f57005; */
color: #fff;
@ -305,6 +389,14 @@
margin: 40px 0;
}
.related-games h3{
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.related-title {
font-size: 20px;
font-weight: 600;
@ -345,16 +437,6 @@
padding: 10px;
}
.game-title {
font-size: 16px;
font-weight: 600;
margin-bottom: 5px;
color: #333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.go-to-top {
position: fixed;
right: 30px;

View File

@ -17,9 +17,8 @@
<div class="program-meta">
<span class="program-author"><i class="fa fa-user"></i> <span id="programAuthor"></span></span>
<span class="program-date"><i class="fa fa-calendar"></i> <span id="programDate"></span></span>
<span class="program-views"><i class="fa-solid fa-eye"></i> <span id="programViews"></span> 浏览</span>
<span class="program-downloads"><i class="fa-solid fa-download"></i> <span id="programDownloads"></span>
下载</span>
<span class="program-views"><i class="fa-solid fa-eye"></i> <span id="programViews"></span></span>
<span class="program-downloads"><i class="fa-solid fa-download"></i> <span id="programDownloads"></span></span>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:52:"E:\Demo\PHP\yunzer\app\admin\view\resources\edit.php";i:1747747200;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
<?php /*a:2:{s:52:"E:\Demo\PHP\yunzer\app\admin\view\resources\edit.php";i:1747755572;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -207,6 +207,14 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">解压密码</label>
<div class="layui-input-block">
<input type="text" name="zipcode" required placeholder="请输入解压密码" autocomplete="off"
class="layui-input" value="<?php echo htmlentities((string) (isset($resource['zipcode']) && ($resource['zipcode'] !== '')?$resource['zipcode']:'')); ?>" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:51:"E:\Demo\PHP\yunzer\app\admin\view\resources\add.php";i:1747744873;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
<?php /*a:2:{s:51:"E:\Demo\PHP\yunzer\app\admin\view\resources\add.php";i:1747755547;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -206,6 +206,14 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">解压密码</label>
<div class="layui-input-block">
<input type="text" name="zipcode" required placeholder="请输入解压密码" autocomplete="off"
class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
@ -349,27 +357,58 @@
return;
}
// 查找选中的分类信息
var parentCategory = null;
var childCategory = null;
window.categoryData.forEach(function(parent) {
if (parent.children) {
parent.children.forEach(function(child) {
if (child.id == selectedId) {
parentCategory = parent;
childCategory = child;
// 递归查找分类信息的函数
function findCategory(categories, targetId) {
for (let category of categories) {
// 检查当前分类
if (category.id == targetId) {
return {
parent: null,
current: category,
total: category.total || 0
};
}
// 检查子分类
if (category.children && category.children.length > 0) {
for (let child of category.children) {
if (child.id == targetId) {
return {
parent: category,
current: child,
total: child.total || 0
};
}
// 递归检查更深层级的子分类
if (child.children && child.children.length > 0) {
const result = findCategory([child], targetId);
if (result) {
return result;
}
}
}
});
}
}
});
return null;
}
if (parentCategory && childCategory) {
// 查找选中的分类信息
const categoryInfo = findCategory(window.categoryData, selectedId);
if (categoryInfo) {
// 生成资源编号
var total = childCategory.total || 0;
var nextNumber = total + 1;
var nextNumber = categoryInfo.total + 1;
var numberStr = nextNumber.toString().padStart(5, '0');
var resourceNumber = parentCategory.number + childCategory.number + numberStr;
var resourceNumber = '';
// 构建编号前缀
if (categoryInfo.parent) {
resourceNumber = categoryInfo.parent.number + categoryInfo.current.number;
} else {
resourceNumber = categoryInfo.current.number;
}
// 添加序号
resourceNumber += numberStr;
// 设置资源编号
$('input[name="number"]').val(resourceNumber);

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:53:"E:\Demo\PHP\yunzer\app\admin\view\resources\lists.php";i:1747747324;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
<?php /*a:2:{s:53:"E:\Demo\PHP\yunzer\app\admin\view\resources\lists.php";i:1747755163;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
<!DOCTYPE html>
<html>
<head>

View File

@ -1,4 +1,4 @@
<?php /*a:5:{s:53:"E:\Demo\PHP\yunzer\app\index\view\articles\detail.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747415782;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
<?php /*a:5:{s:53:"E:\Demo\PHP\yunzer\app\index\view\articles\detail.php";i:1747754938;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747754938;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
<!DOCTYPE html>
<html>
@ -48,7 +48,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="/static/images/logo1.png" width="186" alt="Logo"></a>
</div>
<div class="main-menu__nav">
<ul class="main-menu__list">
@ -90,7 +90,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="/static/images/logo1.png" width="150" alt="Logo"></a>
</div>
<div class="sticky-nav__menu">
<ul>
@ -475,12 +475,12 @@
</div>
<div class="article-actions">
<div class="action-item like-btn">
<div class="action-item like-btn" id="likeBtn">
<i class="fa fa-thumbs-up"></i>
<span class="action-text">点赞</span>
<span class="action-count" id="articleLikes">0</span>
</div>
<div class="action-item share-btn">
<div class="action-item share-btn" id="shareBtn">
<i class="fa fa-share-alt"></i>
<span class="action-text">分享</span>
</div>
@ -932,31 +932,31 @@
function renderArticleDetail(data) {
// 渲染分类链接
document.getElementById('cateLink').textContent = data.cateName;
// 渲染文章标题
document.getElementById('articleTitle').textContent = data.article.title;
// 渲染文章元信息
document.getElementById('articleAuthor').textContent = data.article.author;
document.getElementById('articleDate').textContent = formatDate(data.article.create_time);
document.getElementById('articleViews').textContent = data.article.views;
// 渲染文章内容
document.getElementById('articleContent').innerHTML = data.article.content;
// 渲染标签
const tagsContainer = document.getElementById('articleTags');
if (data.article.tags && data.article.tags.length > 0) {
tagsContainer.innerHTML = data.article.tags.map(tag =>
tagsContainer.innerHTML = data.article.tags.map(tag =>
`<span class="tag-item">${tag}</span>`
).join('');
} else {
tagsContainer.innerHTML = '<span class="no-tags">暂无标签</span>';
}
// 渲染点赞数
document.getElementById('articleLikes').textContent = data.article.likes || 0;
// 渲染上一篇
const prevArticle = document.getElementById('prevArticle');
if (data.prevArticle) {
@ -968,7 +968,7 @@
} else {
prevArticle.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>';
}
// 渲染下一篇
const nextArticle = document.getElementById('nextArticle');
if (data.nextArticle) {
@ -980,7 +980,7 @@
} else {
nextArticle.innerHTML = '<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>';
}
// 渲染相关文章
const relatedArticles = document.getElementById('relatedArticles');
if (data.relatedArticles && data.relatedArticles.length > 0) {
@ -1003,7 +1003,7 @@
}
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
// 获取文章ID
const articleId = new URLSearchParams(window.location.search).get('id');
if (!articleId) {
@ -1018,12 +1018,12 @@
}
})
.then(response => {
console.log('Response status:', response.status);
console.log('Response headers:', response.headers);
// console.log('Response status:', response.status);
// console.log('Response headers:', response.headers);
return response.json();
})
.then(result => {
console.log('API response:', result);
// console.log('API response:', result);
if (result.code === 1) {
renderArticleDetail(result.data);
// 更新访问次数
@ -1043,44 +1043,69 @@
});
// 点赞功能
const likeBtn = document.querySelector('.like-btn');
const likeBtn = document.getElementById('likeBtn');
if (likeBtn) {
likeBtn.addEventListener('click', function() {
// 检查是否已经点赞
if (likeBtn.classList.contains('liked')) {
likeBtn.style.pointerEvents = 'none'; // 禁用点击
likeBtn.style.cursor = 'default'; // 改变鼠标样式
return;
}
likeBtn.addEventListener('click', function () {
// 立即禁用按钮,防止重复点击
likeBtn.style.pointerEvents = 'none';
likeBtn.style.cursor = 'default';
fetch('/index/articles/like?id=' + articleId, {
method: 'POST'
})
.then(response => response.json())
.then(data => {
if (data.code === 1) {
const countElement = this.querySelector('.action-count');
let count = parseInt(countElement.textContent);
countElement.textContent = count + 1;
this.classList.add('liked');
this.style.color = '#f57005';
} else {
alert('点赞失败:' + data.msg);
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.catch(error => {
console.error('点赞请求失败:', error);
});
.then(response => response.json())
.then(data => {
if (data.code === 1) {
const countElement = document.getElementById('articlesLikes');
if (countElement) {
let count = parseInt(countElement.textContent) || 0;
countElement.textContent = count + 1;
}
// 添加点赞状态
likeBtn.classList.add('liked');
likeBtn.querySelector('i').style.color = '#f57005';
layer.msg('点赞成功', {icon: 1});
} else {
// 如果请求失败,恢复按钮状态
likeBtn.style.pointerEvents = 'auto';
likeBtn.style.cursor = 'pointer';
layer.msg('点赞失败:' + data.msg, {icon: 2});
}
})
.catch(error => {
// 如果请求失败,恢复按钮状态
likeBtn.style.pointerEvents = 'auto';
likeBtn.style.cursor = 'pointer';
console.error('点赞请求失败:', error);
layer.msg('点赞失败,请稍后重试', {icon: 2});
});
});
}
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
// 监听滚动事件
window.addEventListener('scroll', function() {
window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
} else {
goToTop.classList.remove('show');
}
});
// 点击返回顶部
goToTop.addEventListener('click', function() {
goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
@ -1099,18 +1124,42 @@
id: articleId
})
})
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 更新成功,更新页面上的访问次数显示
const viewsElement = document.getElementById('articleViews');
if (viewsElement) {
viewsElement.textContent = result.data.views;
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 更新成功,更新页面上的访问次数显示
const viewsElement = document.getElementById('articleViews');
if (viewsElement) {
viewsElement.textContent = result.data.views;
}
}
}
})
.catch(error => {
console.error('更新访问次数失败:', error);
})
.catch(error => {
console.error('更新访问次数失败:', error);
});
}
// 分享功能
const shareBtn = document.getElementById('shareBtn');
if (shareBtn) {
shareBtn.addEventListener('click', function () {
// 获取当前页面URL
const currentUrl = window.location.href;
// 创建临时输入框
const tempInput = document.createElement('input');
tempInput.value = currentUrl;
document.body.appendChild(tempInput);
// 选择并复制文本
tempInput.select();
document.execCommand('copy');
// 移除临时输入框
document.body.removeChild(tempInput);
// 提示用户复制成功
alert('链接已复制到剪贴板');
});
}
</script>

View File

@ -1,4 +1,4 @@
<?php /*a:5:{s:52:"E:\Demo\PHP\yunzer\app\index\view\program\detail.php";i:1747417109;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747415782;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
<?php /*a:5:{s:52:"E:\Demo\PHP\yunzer\app\index\view\program\detail.php";i:1747755857;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747754938;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
<!DOCTYPE html>
<html>
@ -48,7 +48,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="/static/images/logo1.png" width="186" alt="Logo"></a>
</div>
<div class="main-menu__nav">
<ul class="main-menu__list">
@ -90,7 +90,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="/static/images/logo1.png" width="150" alt="Logo"></a>
</div>
<div class="sticky-nav__menu">
<ul>
@ -462,8 +462,8 @@
<div class="program-meta">
<span class="program-author"><i class="fa fa-user"></i> <span id="programAuthor"></span></span>
<span class="program-date"><i class="fa fa-calendar"></i> <span id="programDate"></span></span>
<span class="program-views"><i class="fa-solid fa-eye"></i> <span id="programViews"></span> 浏览</span>
<span class="program-downloads"><i class="fa-solid fa-download"></i> <span id="programDownloads"></span> 下载</span>
<span class="program-views"><i class="fa-solid fa-eye"></i> <span id="programViews"></span></span>
<span class="program-downloads"><i class="fa-solid fa-download"></i> <span id="programDownloads"></span></span>
</div>
</div>
@ -489,12 +489,16 @@
</div>
</div>
<div class="program-content">
</div>
<div class="program-actions">
<div class="action-item download-btn" id="downloadBtn">
<i class="fa fa-download"></i>
<span class="action-text">立即下载</span>
</div>
<div class="action-item share-btn">
<div class="action-item share-btn" id="shareBtn">
<i class="fa fa-share-alt"></i>
<span class="action-text">分享</span>
</div>
@ -703,6 +707,11 @@
margin: 30px 0;
}
.program-navigation a {
color: #333;
text-decoration: none;
}
.prev-program,
.next-program {
max-width: 45%;
@ -858,25 +867,25 @@
function renderProgramDetail(data) {
// 渲染分类链接
document.getElementById('cateLink').textContent = data.cateName;
// 渲染程序标题
document.getElementById('programTitle').textContent = data.program.title;
// 渲染程序元信息
document.getElementById('programAuthor').textContent = data.program.author;
document.getElementById('programDate').textContent = formatDate(data.program.create_time);
document.getElementById('programViews').textContent = data.program.views;
document.getElementById('programDownloads').textContent = data.program.downloads;
// 渲染程序内容
document.getElementById('programContent').innerHTML = data.program.content;
// 渲染程序信息
document.getElementById('programSize').textContent = data.program.size || '未知';
document.getElementById('programEnvironment').textContent = data.program.environment || '通用';
document.getElementById('programUpdateTime').textContent = formatDate(data.program.update_time);
document.getElementById('programVersion').textContent = data.program.version || '1.0.0';
// 渲染上一个程序
const prevProgram = document.getElementById('prevProgram');
if (data.prevProgram) {
@ -888,7 +897,7 @@
} else {
prevProgram.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一个了</span>';
}
// 渲染下一个程序
const nextProgram = document.getElementById('nextProgram');
if (data.nextProgram) {
@ -900,7 +909,7 @@
} else {
nextProgram.innerHTML = '<span class="disabled">没有下一个了 <i class="fa fa-arrow-right"></i></span>';
}
// 渲染相关程序
const relatedPrograms = document.getElementById('relatedPrograms');
if (data.relatedPrograms && data.relatedPrograms.length > 0) {
@ -923,7 +932,7 @@
}
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
// 获取程序ID
const programId = new URLSearchParams(window.location.search).get('id');
if (!programId) {
@ -937,72 +946,63 @@
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.json())
.then(result => {
if (result.code === 1) {
renderProgramDetail(result.data);
// 更新访问次数
updateProgramViews(programId);
} else {
alert(result.msg || '获取程序详情失败');
}
})
.catch(error => {
console.error('获取程序详情失败:', error);
alert('获取程序详情失败,请检查网络连接或刷新页面重试');
});
.then(response => response.json())
.then(result => {
if (result.code === 1) {
renderProgramDetail(result.data);
// 更新访问次数
updateProgramViews(programId);
// 初始化分享功能
initShareFunction();
} else {
alert(result.msg || '获取程序详情失败');
}
})
.catch(error => {
console.error('获取程序详情失败:', error);
alert('获取程序详情失败,请检查网络连接或刷新页面重试');
});
// 下载功能
const downloadBtn = document.getElementById('downloadBtn');
if (downloadBtn) {
downloadBtn.addEventListener('click', function() {
downloadBtn.addEventListener('click', function () {
fetch('/index/program/download?id=' + programId, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.json())
.then(data => {
if (data.code === 1) {
const downloadsElement = document.getElementById('programDownloads');
let downloads = parseInt(downloadsElement.textContent);
downloadsElement.textContent = downloads + 1;
// 获取当前域名
const domain = window.location.origin;
// 拼接完整的下载地址
if (data.data && data.data.fileurl) {
const downloadUrl = domain + data.data.fileurl;
.then(response => response.json())
.then(data => {
if (data.code === 1 && data.data && data.data.fileurl) {
const downloadUrl = window.location.origin + data.data.fileurl;
window.location.href = downloadUrl;
} else {
alert('下载地址不存在');
}
} else {
alert('下载失败:' + data.msg);
}
})
.catch(error => {
console.error('下载请求失败:', error);
alert('下载请求失败,请稍后重试');
});
})
.catch(error => {
console.error('下载请求失败:', error);
alert('下载请求失败,请稍后重试');
});
});
}
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
// 监听滚动事件
window.addEventListener('scroll', function() {
window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
} else {
goToTop.classList.remove('show');
}
});
// 点击返回顶部
goToTop.addEventListener('click', function() {
goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
@ -1022,19 +1022,45 @@
id: programId
})
})
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 更新成功,更新页面上的访问次数显示
const viewsElement = document.getElementById('programViews');
if (viewsElement) {
viewsElement.textContent = result.data.views;
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 更新成功,更新页面上的访问次数显示
const viewsElement = document.getElementById('programViews');
if (viewsElement) {
viewsElement.textContent = result.data.views;
}
}
}
})
.catch(error => {
console.error('更新访问次数失败:', error);
});
})
.catch(error => {
console.error('更新访问次数失败:', error);
});
}
// 初始化分享功能
function initShareFunction() {
const shareBtn = document.getElementById('shareBtn');
if (shareBtn) {
shareBtn.addEventListener('click', function () {
// 获取当前页面URL
const currentUrl = window.location.href;
// 创建临时输入框
const tempInput = document.createElement('input');
tempInput.value = currentUrl;
document.body.appendChild(tempInput);
// 选择并复制文本
tempInput.select();
document.execCommand('copy');
// 移除临时输入框
document.body.removeChild(tempInput);
// 提示用户复制成功
layer.msg('链接已复制到剪贴板');
});
}
}
</script>
</body>

View File

@ -1,4 +1,4 @@
<?php /*a:5:{s:49:"E:\Demo\PHP\yunzer\app\index\view\game\detail.php";i:1747754891;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747415782;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
<?php /*a:5:{s:49:"E:\Demo\PHP\yunzer\app\index\view\game\detail.php";i:1747757578;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747754938;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
<!DOCTYPE html>
<html>
@ -48,7 +48,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="/static/images/logo1.png" width="186" alt="Logo"></a>
</div>
<div class="main-menu__nav">
<ul class="main-menu__list">
@ -90,7 +90,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="/static/images/logo1.png" width="150" alt="Logo"></a>
</div>
<div class="sticky-nav__menu">
<ul>
@ -462,9 +462,9 @@
<h1 class="game-title"><?php echo $game['title']; ?></h1>
<div class="game-meta">
<span class="game-category"><?php echo $cateName; ?></span>
<span class="game-views"><i class="fa-solid fa-eye"></i> <?php echo $game['views']; ?> 次浏览</span>
<span class="game-views"><i class="fa-solid fa-eye"></i> <?php echo $game['views']; ?> </span>
<span class="game-downloads"><i class="fa-solid fa-download"></i> <span
id="gameDownloads"><?php echo $game['downloads']; ?></span> 次下载</span>
id="gameDownloads"><?php echo $game['downloads']; ?></span> </span>
</div>
</div>
<div class="game-content">
@ -488,6 +488,13 @@
</div>
</div>
<div class="game-navigation">
<div class="prev-game" id="prevGame">
</div>
<div class="next-game" id="nextGame">
</div>
</div>
<!-- 相关游戏 -->
<?php if (!empty($relatedGames)): ?>
<div class="related-games">
@ -501,7 +508,7 @@
alt="<?php echo $related['title']; ?>">
</div>
<div class="game-info">
<h4 class="game-title"><?php echo $related['title']; ?></h4>
<h4 class="game-title-1"><?php echo $related['title']; ?></h4>
</div>
</div>
<?php endforeach; ?>
@ -583,6 +590,44 @@
return;
}
// 获取游戏详情
fetch('/index/game/detail?id=' + gameId, {
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 渲染上一篇
const prevGame = document.getElementById('prevGame');
if (result.data.prevGame) {
prevGame.innerHTML = `
<a href="/index/game/detail?id=${result.data.prevGame.id}">
<i class="fa fa-arrow-left"></i> 上一篇:${result.data.prevGame.title}
</a>
`;
} else {
prevGame.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>';
}
// 渲染下一篇
const nextGame = document.getElementById('nextGame');
if (result.data.nextGame) {
nextGame.innerHTML = `
<a href="/index/game/detail?id=${result.data.nextGame.id}">
下一篇:${result.data.nextGame.title} <i class="fa fa-arrow-right"></i>
</a>
`;
} else {
nextGame.innerHTML = '<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>';
}
}
})
.catch(error => {
console.error('获取游戏详情失败:', error);
});
// 更新访问次数
updateGameViews(gameId);
@ -605,7 +650,7 @@
// 直接使用返回的URL
if (data.data && data.data.url) {
window.location.href = data.data.url;
window.open(data.data.url, '_blank');
} else {
alert('下载地址不存在');
}
@ -624,7 +669,7 @@
const codeBtn = document.getElementById('codeBtn');
if (codeBtn) {
codeBtn.addEventListener('click', function() {
const code = '<?php echo htmlentities((string) $game['code']); ?>';
const code = '<?php echo $game['code']; ?>';
if (code) {
// 创建一个临时输入框
const tempInput = document.createElement('input');
@ -685,7 +730,7 @@
if (result.code === 1) {
const viewsElement = document.querySelector('.game-views');
if (viewsElement) {
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views} 次浏览`;
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views}`;
}
}
})
@ -717,11 +762,27 @@
}
.game-title {
font-size: 28px;
font-size: 30px;
font-weight: 700;
color: #333;
margin-bottom: 15px;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.game-title-1 {
font-size: 16px;
font-weight: 700;
color: #333;
margin-bottom: 15px;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.game-meta {
@ -773,6 +834,29 @@
border-bottom: 1px solid #eee;
}
.game-navigation {
display: flex;
justify-content: space-between;
margin: 30px 0;
}
.prev-game,
.next-game {
max-width: 45%;
}
.prev-game a,
.next-game a {
color: #333 !important;
text-decoration: none;
}
.prev-game a:hover,
.next-game a:hover {
color: #f57005 !important;
transition: all 0.3s ease;
}
.btn {
/* background: #f57005; */
color: #fff;
@ -805,6 +889,14 @@
margin: 40px 0;
}
.related-games h3{
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.related-title {
font-size: 20px;
font-weight: 600;
@ -845,16 +937,6 @@
padding: 10px;
}
.game-title {
font-size: 16px;
font-weight: 600;
margin-bottom: 5px;
color: #333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.go-to-top {
position: fixed;
right: 30px;