540 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			540 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
{include file="component/head" /}
 | 
						|
{include file="component/header-simple" /}
 | 
						|
<div class="main">
 | 
						|
    <div class="location">
 | 
						|
        <div class="container">
 | 
						|
            <div class="location-item">
 | 
						|
                <a href="/">首页</a>
 | 
						|
                <span>></span>
 | 
						|
                <a href="/index/program/index" id="cateLink"></a>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
    </div>
 | 
						|
 | 
						|
    <div class="program-detail-container">
 | 
						|
        <div class="program-header">
 | 
						|
            <h1 class="program-title" id="programTitle"></h1>
 | 
						|
            <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>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="program-content" id="programContent">
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="program-info">
 | 
						|
            <div class="info-item">
 | 
						|
                <span class="info-label">软件大小:</span>
 | 
						|
                <span id="programSize"></span>
 | 
						|
            </div>
 | 
						|
            <div class="info-item">
 | 
						|
                <span class="info-label">运行环境:</span>
 | 
						|
                <span id="programEnvironment"></span>
 | 
						|
            </div>
 | 
						|
            <div class="info-item">
 | 
						|
                <span class="info-label">更新时间:</span>
 | 
						|
                <span id="programUpdateTime"></span>
 | 
						|
            </div>
 | 
						|
            <div class="info-item">
 | 
						|
                <span class="info-label">软件版本:</span>
 | 
						|
                <span id="programVersion"></span>
 | 
						|
            </div>
 | 
						|
        </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">
 | 
						|
                <i class="fa fa-share-alt"></i>
 | 
						|
                <span class="action-text">分享</span>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="program-navigation">
 | 
						|
            <div class="prev-program" id="prevProgram">
 | 
						|
            </div>
 | 
						|
            <div class="next-program" id="nextProgram">
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="related-programs">
 | 
						|
            <h3 class="related-title">相关推荐</h3>
 | 
						|
            <div class="related-list" id="relatedPrograms">
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
    </div>
 | 
						|
</div>
 | 
						|
 | 
						|
<!-- 返回顶部按钮 -->
 | 
						|
<div class="go-to-top" id="goToTop">
 | 
						|
    <i class="layui-icon layui-icon-top"></i>
 | 
						|
</div>
 | 
						|
 | 
						|
{include file="component/footer" /}
 | 
						|
 | 
						|
<style>
 | 
						|
    .location {
 | 
						|
        max-width: 1000px;
 | 
						|
        margin: 30px auto;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-detail-container {
 | 
						|
        max-width: 1000px;
 | 
						|
        margin: 30px auto;
 | 
						|
        padding: 50px;
 | 
						|
        background: #fff;
 | 
						|
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
 | 
						|
        border-radius: 8px;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-header {
 | 
						|
        margin-bottom: 30px;
 | 
						|
        border-bottom: 1px solid #eee;
 | 
						|
        padding-bottom: 20px;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-title {
 | 
						|
        font-size: 28px;
 | 
						|
        font-weight: 700;
 | 
						|
        color: #333;
 | 
						|
        margin-bottom: 15px;
 | 
						|
        line-height: 1.4;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-meta {
 | 
						|
        display: flex;
 | 
						|
        flex-wrap: wrap;
 | 
						|
        gap: 20px;
 | 
						|
        color: #666;
 | 
						|
        font-size: 14px;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-meta span {
 | 
						|
        display: flex;
 | 
						|
        align-items: center;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-meta i {
 | 
						|
        margin-right: 5px;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-content {
 | 
						|
        line-height: 1.8;
 | 
						|
        color: #333;
 | 
						|
        font-size: 16px;
 | 
						|
        margin-bottom: 30px;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-info {
 | 
						|
        background: #f8f9fa;
 | 
						|
        padding: 20px;
 | 
						|
        border-radius: 8px;
 | 
						|
        margin: 20px 0;
 | 
						|
    }
 | 
						|
 | 
						|
    .info-item {
 | 
						|
        margin-bottom: 10px;
 | 
						|
        display: flex;
 | 
						|
        align-items: center;
 | 
						|
    }
 | 
						|
 | 
						|
    .info-label {
 | 
						|
        font-weight: bold;
 | 
						|
        width: 100px;
 | 
						|
        color: #666;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-actions {
 | 
						|
        display: flex;
 | 
						|
        justify-content: center;
 | 
						|
        gap: 40px;
 | 
						|
        margin: 30px 0;
 | 
						|
        padding: 20px 0;
 | 
						|
        border-top: 1px solid #eee;
 | 
						|
        border-bottom: 1px solid #eee;
 | 
						|
    }
 | 
						|
 | 
						|
    .action-item {
 | 
						|
        display: flex;
 | 
						|
        flex-direction: column;
 | 
						|
        align-items: center;
 | 
						|
        cursor: pointer;
 | 
						|
        padding: 15px 30px;
 | 
						|
        border-radius: 8px;
 | 
						|
        transition: all 0.3s ease;
 | 
						|
    }
 | 
						|
 | 
						|
    .download-btn {
 | 
						|
        background: #f57005;
 | 
						|
        color: #fff;
 | 
						|
    }
 | 
						|
 | 
						|
    .download-btn:hover {
 | 
						|
        background: #e66600;
 | 
						|
        transform: translateY(-2px);
 | 
						|
    }
 | 
						|
 | 
						|
    .share-btn {
 | 
						|
        background: #f8f9fa;
 | 
						|
        color: #666;
 | 
						|
    }
 | 
						|
 | 
						|
    .share-btn:hover {
 | 
						|
        background: #e9ecef;
 | 
						|
    }
 | 
						|
 | 
						|
    .action-item i {
 | 
						|
        font-size: 24px;
 | 
						|
        margin-bottom: 5px;
 | 
						|
    }
 | 
						|
 | 
						|
    .action-text {
 | 
						|
        font-size: 14px;
 | 
						|
    }
 | 
						|
 | 
						|
    .program-navigation {
 | 
						|
        display: flex;
 | 
						|
        justify-content: space-between;
 | 
						|
        margin: 30px 0;
 | 
						|
    }
 | 
						|
 | 
						|
    .prev-program,
 | 
						|
    .next-program {
 | 
						|
        max-width: 45%;
 | 
						|
    }
 | 
						|
 | 
						|
    .prev-program a,
 | 
						|
    .next-program a {
 | 
						|
        color: #333;
 | 
						|
        text-decoration: none;
 | 
						|
    }
 | 
						|
 | 
						|
    .prev-program a:hover,
 | 
						|
    .next-program a:hover {
 | 
						|
        color: #f57005;
 | 
						|
    }
 | 
						|
 | 
						|
    .disabled {
 | 
						|
        color: #999;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-programs {
 | 
						|
        margin: 40px 0;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-title {
 | 
						|
        font-size: 20px;
 | 
						|
        font-weight: 600;
 | 
						|
        margin-bottom: 20px;
 | 
						|
        padding-bottom: 10px;
 | 
						|
        border-bottom: 1px solid #eee;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-list {
 | 
						|
        display: grid;
 | 
						|
        grid-template-columns: repeat(3, 1fr);
 | 
						|
        gap: 20px;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-item {
 | 
						|
        border-radius: 8px;
 | 
						|
        overflow: hidden;
 | 
						|
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
 | 
						|
        transition: transform 0.3s;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-item:hover {
 | 
						|
        transform: translateY(-5px);
 | 
						|
    }
 | 
						|
 | 
						|
    .related-item a {
 | 
						|
        text-decoration: none;
 | 
						|
        color: inherit;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-image img {
 | 
						|
        width: 100%;
 | 
						|
        height: 150px;
 | 
						|
        object-fit: cover;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-info {
 | 
						|
        padding: 10px;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-item-title {
 | 
						|
        font-size: 16px;
 | 
						|
        font-weight: 600;
 | 
						|
        margin-bottom: 5px;
 | 
						|
        color: #333;
 | 
						|
        overflow: hidden;
 | 
						|
        text-overflow: ellipsis;
 | 
						|
        white-space: nowrap;
 | 
						|
    }
 | 
						|
 | 
						|
    .related-item-desc {
 | 
						|
        font-size: 12px;
 | 
						|
        color: #666;
 | 
						|
        overflow: hidden;
 | 
						|
        text-overflow: ellipsis;
 | 
						|
        display: -webkit-box;
 | 
						|
        -webkit-line-clamp: 2;
 | 
						|
        -webkit-box-orient: vertical;
 | 
						|
    }
 | 
						|
 | 
						|
    .go-to-top {
 | 
						|
        position: fixed;
 | 
						|
        right: 30px;
 | 
						|
        bottom: 30px;
 | 
						|
        width: 40px;
 | 
						|
        height: 40px;
 | 
						|
        background: #f57005;
 | 
						|
        color: #fff;
 | 
						|
        border-radius: 50%;
 | 
						|
        display: flex;
 | 
						|
        align-items: center;
 | 
						|
        justify-content: center;
 | 
						|
        cursor: pointer;
 | 
						|
        opacity: 0;
 | 
						|
        visibility: hidden;
 | 
						|
        transition: all 0.3s ease;
 | 
						|
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
 | 
						|
        z-index: 1000;
 | 
						|
    }
 | 
						|
 | 
						|
    .go-to-top.show {
 | 
						|
        opacity: 1;
 | 
						|
        visibility: visible;
 | 
						|
    }
 | 
						|
 | 
						|
    .go-to-top:hover {
 | 
						|
        background: #e66600;
 | 
						|
        transform: translateY(-3px);
 | 
						|
    }
 | 
						|
 | 
						|
    @media (max-width: 768px) {
 | 
						|
        .program-title {
 | 
						|
            font-size: 24px;
 | 
						|
        }
 | 
						|
 | 
						|
        .related-list {
 | 
						|
            grid-template-columns: repeat(1, 1fr);
 | 
						|
        }
 | 
						|
 | 
						|
        .program-meta {
 | 
						|
            gap: 10px;
 | 
						|
        }
 | 
						|
 | 
						|
        .go-to-top {
 | 
						|
            right: 20px;
 | 
						|
            bottom: 20px;
 | 
						|
            width: 36px;
 | 
						|
            height: 36px;
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    .location-item a {
 | 
						|
        color: #000 !important;
 | 
						|
    }
 | 
						|
</style>
 | 
						|
 | 
						|
<script>
 | 
						|
    // 格式化日期
 | 
						|
    function formatDate(timestamp) {
 | 
						|
        const date = new Date(timestamp * 1000);
 | 
						|
        return date.toLocaleDateString('zh-CN', {
 | 
						|
            year: 'numeric',
 | 
						|
            month: '2-digit',
 | 
						|
            day: '2-digit'
 | 
						|
        });
 | 
						|
    }
 | 
						|
 | 
						|
    // 渲染程序详情
 | 
						|
    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) {
 | 
						|
            prevProgram.innerHTML = `
 | 
						|
                <a href="/index/program/detail?id=${data.prevProgram.id}">
 | 
						|
                    <i class="fa fa-arrow-left"></i> 上一个:${data.prevProgram.title}
 | 
						|
                </a>
 | 
						|
            `;
 | 
						|
        } else {
 | 
						|
            prevProgram.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一个了</span>';
 | 
						|
        }
 | 
						|
        
 | 
						|
        // 渲染下一个程序
 | 
						|
        const nextProgram = document.getElementById('nextProgram');
 | 
						|
        if (data.nextProgram) {
 | 
						|
            nextProgram.innerHTML = `
 | 
						|
                <a href="/index/program/detail?id=${data.nextProgram.id}">
 | 
						|
                    下一个:${data.nextProgram.title} <i class="fa fa-arrow-right"></i>
 | 
						|
                </a>
 | 
						|
            `;
 | 
						|
        } 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) {
 | 
						|
            relatedPrograms.innerHTML = data.relatedPrograms.map(program => `
 | 
						|
                <div class="related-item">
 | 
						|
                    <a href="/index/program/detail?id=${program.id}">
 | 
						|
                        <div class="related-image">
 | 
						|
                            <img src="${program.icon}" alt="${program.title}">
 | 
						|
                        </div>
 | 
						|
                        <div class="related-info">
 | 
						|
                            <div class="related-item-title">${program.title}</div>
 | 
						|
                            <div class="related-item-desc">${program.desc || ''}</div>
 | 
						|
                        </div>
 | 
						|
                    </a>
 | 
						|
                </div>
 | 
						|
            `).join('');
 | 
						|
        } else {
 | 
						|
            relatedPrograms.innerHTML = '<div class="no-related">暂无相关程序</div>';
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    // 页面加载完成后执行
 | 
						|
    document.addEventListener('DOMContentLoaded', function() {
 | 
						|
        // 获取程序ID
 | 
						|
        const programId = new URLSearchParams(window.location.search).get('id');
 | 
						|
        if (!programId) {
 | 
						|
            alert('程序ID不存在');
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        // 获取程序详情
 | 
						|
        fetch(`/index/program/detail?id=${programId}`, {
 | 
						|
            headers: {
 | 
						|
                '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('获取程序详情失败,请检查网络连接或刷新页面重试');
 | 
						|
        });
 | 
						|
 | 
						|
        // 下载功能
 | 
						|
        const downloadBtn = document.getElementById('downloadBtn');
 | 
						|
        if (downloadBtn) {
 | 
						|
            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;
 | 
						|
                            window.location.href = downloadUrl;
 | 
						|
                        } else {
 | 
						|
                            alert('下载地址不存在');
 | 
						|
                        }
 | 
						|
                    } else {
 | 
						|
                        alert('下载失败:' + data.msg);
 | 
						|
                    }
 | 
						|
                })
 | 
						|
                .catch(error => {
 | 
						|
                    console.error('下载请求失败:', error);
 | 
						|
                    alert('下载请求失败,请稍后重试');
 | 
						|
                });
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        // 返回顶部功能
 | 
						|
        const goToTop = document.getElementById('goToTop');
 | 
						|
        
 | 
						|
        // 监听滚动事件
 | 
						|
        window.addEventListener('scroll', function() {
 | 
						|
            if (window.pageYOffset > 300) {
 | 
						|
                goToTop.classList.add('show');
 | 
						|
            } else {
 | 
						|
                goToTop.classList.remove('show');
 | 
						|
            }
 | 
						|
        });
 | 
						|
        
 | 
						|
        // 点击返回顶部
 | 
						|
        goToTop.addEventListener('click', function() {
 | 
						|
            window.scrollTo({
 | 
						|
                top: 0,
 | 
						|
                behavior: 'smooth'
 | 
						|
            });
 | 
						|
        });
 | 
						|
    });
 | 
						|
 | 
						|
    // 更新程序访问次数
 | 
						|
    function updateProgramViews(programId) {
 | 
						|
        fetch('/index/program/updateViews', {
 | 
						|
            method: 'POST',
 | 
						|
            headers: {
 | 
						|
                'Content-Type': 'application/json',
 | 
						|
                'X-Requested-With': 'XMLHttpRequest'
 | 
						|
            },
 | 
						|
            body: JSON.stringify({
 | 
						|
                id: programId
 | 
						|
            })
 | 
						|
        })
 | 
						|
        .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);
 | 
						|
        });
 | 
						|
    }
 | 
						|
</script>
 | 
						|
{include file="component/foot" /} |