修复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
+99 -17
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;