Files
mce/templates/MetaLab-2026/html/posts/index.html
Victor_Jay d3e5cbe18b refactor: 静态资源缓存破坏改为文件级哈希,重启不刷新未修改文件的缓存
- 启动时计算每个 JS/CSS 的 SHA-1 前 8 位作为版本号
- 文件不变则哈希不变,浏览器继续用缓存,重启零压力
- 替换全局 AssetVersion 为 assetV 模板函数,按文件路径查询哈希
- 移除 BuildPageData 中的全局版本号注入
2026-05-31 01:53:17 +08:00

59 lines
1.8 KiB
HTML

{{template "layout/header.html" .}}
<body>
{{template "layout/nav.html" .}}
<div class="container posts-container">
<div class="posts-header">
<h1>社区帖子</h1>
{{if .IsLoggedIn}}
<a href="/posts/new" class="btn btn-primary">撰写帖子</a>
{{end}}
</div>
{{if .Error}}
<div class="error-message">{{.Error}}</div>
{{end}}
{{if .Keyword}}
<div class="search-hint">搜索:<strong>{{.Keyword}}</strong></div>
{{end}}
<div class="posts-list">
{{if eq (len .Posts) 0}}
<div class="empty-state">暂无帖子</div>
{{else}}
{{range .Posts}}
<article class="post-card">
<h2 class="post-card-title">
<a href="/posts/{{.ID}}">{{.Title}}</a>
</h2>
<div class="post-card-meta">
<span class="post-author">{{if .AuthorName}}{{.AuthorName}}{{else}}该用户已注销{{end}}</span>
<span class="post-time">{{.CreatedAt.Format "2006-01-02 15:04"}}</span>
</div>
<p class="post-card-summary">{{if .Excerpt}}{{.Excerpt}}{{else}}{{printf "%.200s" .Body}}{{end}}</p>
</article>
{{end}}
{{end}}
</div>
{{if gt .TotalPages 1}}
<div class="pagination">
{{if gt .Page 1}}
<a href="?page={{.PrevPage}}{{if .Keyword}}&keyword={{.Keyword}}{{end}}" class="page-link">上一页</a>
{{end}}
<span class="page-info">第 {{.Page}} / {{.TotalPages}} 页 (共 {{.Total}} 条)</span>
{{if lt .Page .TotalPages}}
<a href="?page={{.NextPage}}{{if .Keyword}}&keyword={{.Keyword}}{{end}}" class="page-link">下一页</a>
{{end}}
</div>
{{end}}
</div>
{{template "layout/footer.html" .}}
<script src="/static/js/common.js?v={{assetV "/static/js/common.js"}}"></script>
</body>
</html>