perf: V0.9.4 商品列表分页 + sitemap 文件缓存 + banner/asset/gzip/类型修复
- P1: Product::listing() 分页(WHERE status=1+LIMIT/OFFSET+总数),ProductController 改用并加翻页器,消除列表全表
- P1: outputSitemap() 加 storage/cache/sitemap.xml 文件缓存(TTL 3600s),消除每次爬虫全表
- P2: 首页 banner 改 whereLimit('status',1,20)
- P2: asset() 追加 ?v=filemtime 版本串,theme.css 改后自动击穿 1y 浏览器缓存
- P2: nginx 启用 gzip(文本资源压缩)
- P2: Model::count() $val 隐式可空改 mixed(PHP 8.4+ 弃用)
This commit is contained in:
@@ -44,5 +44,18 @@ $sub = $cat ? $cat['description'] : '水冷循环 / 相变蓄冷 / 涡扇风冷
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if (($totalPages ?? 1) > 1): ?>
|
||||
<?php
|
||||
$base = 'products' . ($activeCat ? '?cat=' . $activeCat : '');
|
||||
$mk = fn($p) => site_url($base . ($activeCat ? '&' : '?') . 'page=' . $p);
|
||||
?>
|
||||
<nav class="pager" style="display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin:34px 0">
|
||||
<?php if ($page > 1): ?><a class="btn btn-ghost" href="<?php echo $mk($page - 1); ?>">上一页</a><?php endif; ?>
|
||||
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
||||
<a class="btn btn-ghost" style="<?php echo $i == $page ? 'background:var(--c-primary);color:#fff' : '' ?>" href="<?php echo $mk($i); ?>"><?php echo $i; ?></a>
|
||||
<?php endfor; ?>
|
||||
<?php if ($page < $totalPages): ?><a class="btn btn-ghost" href="<?php echo $mk($page + 1); ?>">下一页</a><?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user