增加游戏模块
This commit is contained in:
@@ -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:1747416219;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1747649140;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;}*/ ?>
|
||||
<?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:1747416219;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1747748380;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -536,6 +536,27 @@
|
||||
</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">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="gameDownloadList">
|
||||
<!-- 游戏将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -656,6 +677,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 加载游戏下载
|
||||
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>';
|
||||
@@ -718,6 +765,9 @@
|
||||
case 'programDownload':
|
||||
loadCategoryPrograms(selectedCategoryId, 'programDownloadList');
|
||||
break;
|
||||
case 'gameDownload':
|
||||
loadCategoryGames(selectedCategoryId, 'gameDownloadList');
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -958,12 +1008,71 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 渲染游戏列表
|
||||
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)">
|
||||
|
||||
Reference in New Issue
Block a user