码桶
发现社区成员的开源项目
post.php13.5 KB
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$cid = $this->cid;
$thumb = lb_get_thumb($this);
$version = $this->fields->version ?? '';
$fileSize = $this->fields->fileSize ?? '';
$systemReq = $this->fields->systemReq ?? '';
$language = $this->fields->language ?? '';
$license = $this->fields->license ?? '';
$unzipPassword = $this->fields->unzipPassword ?? '';
$downloadCount = intval($this->fields->downloadCount ?? 0);
$downloadLinks = lb_parse_download_links($this->fields->downloadLinks ?? '');
$changelog = lb_parse_changelog($this->fields->changelog ?? '');
$rating = lb_get_rating($cid);
$licenseLabel = lb_get_license_label($license);
$langLabel = lb_get_language_label($language);
$this->need('header.php');
?>
<div class="content-area">
<article class="single-resource" itemscope itemtype="http://schema.org/SoftwareApplication">
<div class="resource-header">
<div class="resource-thumb-large">
<img src="<?php echo htmlspecialchars($thumb); ?>"
alt="<?php $this->title(); ?>"
itemprop="image"
onerror="this.src='<?php echo lb_theme_url('assets/img/placeholder.png'); ?>'">
</div>
<div class="resource-info">
<h1 class="resource-title" itemprop="name"><?php $this->title(); ?></h1>
<?php if ($version): ?>
<div class="resource-version" itemprop="softwareVersion">
<span class="label">版本:</span>
<span class="value"><?php echo htmlspecialchars($version); ?></span>
</div>
<?php endif; ?>
<div class="resource-tags">
<?php if ($licenseLabel): ?>
<span class="res-tag <?php echo $licenseLabel['class']; ?>"><?php echo $licenseLabel['text']; ?></span>
<?php endif; ?>
<?php if ($langLabel): ?>
<span class="res-tag tag-lang"><?php echo $langLabel; ?></span>
<?php endif; ?>
</div>
<div class="resource-stats">
<div class="stat-item">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
<span class="stat-value" id="download-count-display"><?php echo $downloadCount; ?></span>
<span class="stat-label">次下载</span>
</div>
<div class="stat-item">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
<line x1="16" y1="2" x2="16" y2="6"/>
<line x1="8" y1="2" x2="8" y2="6"/>
<line x1="3" y1="10" x2="21" y2="10"/>
</svg>
<span class="stat-value"><?php $this->date('Y-m-d'); ?></span>
<span class="stat-label">更新日期</span>
</div>
<?php if ($fileSize): ?>
<div class="stat-item" itemprop="fileSize">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/>
</svg>
<span class="stat-value"><?php echo htmlspecialchars($fileSize); ?></span>
<span class="stat-label">文件大小</span>
</div>
<?php endif; ?>
</div>
<?php if ($this->options->enableRating == 1): ?>
<div class="resource-rating" id="resource-rating" data-cid="<?php echo $cid; ?>">
<div class="rating-stars" role="radiogroup" aria-label="评分">
<?php for ($i = 1; $i <= 5; $i++): ?>
<button class="star-btn" data-rating="<?php echo $i; ?>"
aria-label="<?php echo $i; ?> 星" role="radio"
<?php echo $i <= round($rating['avg']) ? 'aria-checked="true"' : 'aria-checked="false"'; ?>>
<svg viewBox="0 0 24 24" fill="<?php echo $i <= round($rating['avg']) ? 'currentColor' : 'none'; ?>"
stroke="currentColor" stroke-width="2">
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>
</svg>
</button>
<?php endfor; ?>
</div>
<div class="rating-info">
<span class="rating-score" id="rating-score"><?php echo $rating['avg']; ?></span>
<span class="rating-count" id="rating-count">(<?php echo $rating['count']; ?> 人评分)</span>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php if ($systemReq || $fileSize || $language || $unzipPassword): ?>
<div class="resource-meta-box">
<h3 class="meta-box-title">资源信息</h3>
<div class="meta-grid">
<?php if ($systemReq): ?>
<div class="meta-row">
<span class="meta-label">系统要求</span>
<span class="meta-value"><?php echo htmlspecialchars($systemReq); ?></span>
</div>
<?php endif; ?>
<?php if ($fileSize): ?>
<div class="meta-row">
<span class="meta-label">文件大小</span>
<span class="meta-value"><?php echo htmlspecialchars($fileSize); ?></span>
</div>
<?php endif; ?>
<?php if ($language): ?>
<div class="meta-row">
<span class="meta-label">语言版本</span>
<span class="meta-value"><?php echo $langLabel; ?></span>
</div>
<?php endif; ?>
<?php if ($unzipPassword): ?>
<div class="meta-row">
<span class="meta-label">解压密码</span>
<span class="meta-value">
<code id="unzip-password"><?php echo htmlspecialchars($unzipPassword); ?></code>
<button class="copy-btn" onclick="lb_copy_text('unzip-password', this)">复制</button>
</span>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="resource-detail-tabs">
<div class="tabs-nav">
<button class="tab-btn active" data-tab="intro">资源介绍</button>
<?php if (!empty($changelog)): ?>
<button class="tab-btn" data-tab="changelog">更新日志</button>
<?php endif; ?>
</div>
<div class="tab-panel active" id="tab-intro">
<div class="resource-content fmt" itemprop="description">
<?php $this->content(); ?>
</div>
</div>
<?php if (!empty($changelog)): ?>
<div class="tab-panel" id="tab-changelog">
<div class="changelog-list">
<?php foreach ($changelog as $item): ?>
<div class="changelog-item">
<div class="changelog-header">
<span class="changelog-version"><?php echo htmlspecialchars($item['version']); ?></span>
<span class="changelog-date"><?php echo htmlspecialchars($item['date']); ?></span>
</div>
<div class="changelog-content"><?php echo htmlspecialchars($item['content']); ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php if (!empty($downloadLinks)): ?>
<div class="download-section">
<h3 class="download-section-title">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
下载地址
</h3>
<div class="download-links">
<?php foreach ($downloadLinks as $index => $link): ?>
<a class="download-btn type-<?php echo htmlspecialchars($link['type']); ?>"
href="<?php echo htmlspecialchars($link['url']); ?>"
target="_blank" rel="nofollow noopener"
data-cid="<?php echo $cid; ?>"
onclick="lb_track_download(this)">
<span class="download-icon">
<?php if ($link['type'] === 'local'): ?>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<ellipse cx="12" cy="5" rx="9" ry="3"/>
<path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"/>
<path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"/>
</svg>
<?php else:
$dlHost = parse_url($link['url'], PHP_URL_HOST);
$faviconUrl = $dlHost ? lb_get_favicon($dlHost) : '';
?>
<?php if ($faviconUrl): ?>
<img class="download-favicon" src="<?php echo htmlspecialchars($faviconUrl); ?>" alt="" loading="lazy"
onerror="this.parentNode.style.display='none';">
<?php else: ?>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="2" y1="12" x2="22" y2="12"/>
<path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/>
</svg>
<?php endif; ?>
<?php endif; ?>
</span>
<span class="download-text">
<span class="download-name"><?php echo htmlspecialchars($link['name']); ?></span>
<span class="download-type"><?php echo $link['type'] === 'local' ? '本地下载' : '网盘下载'; ?></span>
</span>
<svg class="download-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="7" y1="17" x2="17" y2="7"/>
<polyline points="7 7 17 7 17 17"/>
</svg>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if ($this->tags): ?>
<div class="resource-tags-section">
<span class="tags-label">标签:</span>
<?php $this->tags(' ', true, ''); ?>
</div>
<?php endif; ?>
<nav class="post-navigation">
<?php $this->thePrev('%s', '没有上一篇了'); ?>
<?php $this->theNext('%s', '没有下一篇了'); ?>
</nav>
</article>
<?php
$lbNoticeTitle = trim($this->fields->notice_title ?? '');
$lbNoticeContent = trim($this->fields->notice_content ?? '');
if ($lbNoticeContent !== ''):
?>
<div class="notice-modal" id="notice-modal">
<div class="notice-modal-box">
<button type="button" class="notice-modal-close" id="notice-modal-close" aria-label="关闭">×</button>
<div class="notice-modal-title">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/>
<line x1="12" y1="9" x2="12" y2="13"/>
<line x1="12" y1="17" x2="12.01" y2="17"/>
</svg>
<?php echo htmlspecialchars($lbNoticeTitle !== '' ? $lbNoticeTitle : '特别提醒'); ?>
</div>
<div class="notice-modal-content">
<?php echo $this->fields->notice_content; ?>
</div>
<button type="button" class="notice-modal-btn" id="notice-modal-btn">我知道了</button>
</div>
</div>
<?php endif; ?>
<?php $this->need('comments.php'); ?>
</div>
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>