fix: 修复 Space 模板缺少 formatCount/str 函数导致的启动 panic
- 在 theme/loader.go FuncMap 中添加 formatCount 和 str 函数 - formatCount 将 int64 格式化为中文计数(如 2.5万) - 控制器 ActiveFolderID 改为 uint 类型,避免模板中 str 类型比较 - 控制器传递 ActiveFolder 对象,移除模板内查找逻辑 - 清理旧模板替换残留的孤儿 HTML/SVG 代码
This commit is contained in:
@ -351,7 +351,7 @@
|
||||
{{if .FoldersResult}}
|
||||
{{range $f := .FoldersResult.Folders}}
|
||||
<a href="/space/{{$.SpaceUser.ID}}?tab=collections&folder={{$f.ID}}"
|
||||
class="space-sidebar-link{{if eq (str $.ActiveFolderID) (str $f.ID)}} active{{end}}"
|
||||
class="space-sidebar-link{{if eq $.ActiveFolderID $f.ID}} active{{end}}"
|
||||
data-folder-id="{{$f.ID}}">
|
||||
<svg class="space-sidebar-icon" viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M17 3H7c-1.1 0-2 .9-2 2v16l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"/></svg>
|
||||
{{$f.Name}}
|
||||
@ -366,32 +366,21 @@
|
||||
<main class="space-main">
|
||||
{{if .FoldersResult}}
|
||||
{{if gt (len .FoldersResult.Folders) 0}}
|
||||
{{/* 找到当前激活的收藏夹 */}}
|
||||
{{$activeFolder := ""}}
|
||||
{{range $f := .FoldersResult.Folders}}
|
||||
{{if eq (str $.ActiveFolderID) (str $f.ID)}}
|
||||
{{$activeFolder = $f}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if $activeFolder}}
|
||||
{{if .ActiveFolder}}
|
||||
<!-- 收藏夹头信息 -->
|
||||
<div class="collection-header">
|
||||
<div class="collection-cover">
|
||||
{{if $activeFolder.Description}}
|
||||
<div class="collection-cover-placeholder"></div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="collection-info-row">
|
||||
<div>
|
||||
<h1 class="collection-name">{{$activeFolder.Name}}</h1>
|
||||
<h1 class="collection-name">{{.ActiveFolder.Name}}</h1>
|
||||
<p class="collection-meta">
|
||||
{{if $activeFolder.IsPublic}}公开{{else}}私密{{end}}
|
||||
· 视频数 {{.FolderItems.Total}}
|
||||
{{if .ActiveFolder.IsPublic}}公开{{else}}私密{{end}}
|
||||
· 文章数 {{.FolderItems.Total}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="collection-actions">
|
||||
<button class="space-action-btn primary small">播放全部</button>
|
||||
<button class="space-action-btn outline small">批量操作</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -406,14 +395,8 @@
|
||||
</div>
|
||||
<div class="collection-filter">
|
||||
<select class="filter-select">
|
||||
<option>当前</option>
|
||||
<option>全部</option>
|
||||
</select>
|
||||
<div class="filter-search">
|
||||
<input type="text" placeholder="请输入关键词" class="filter-search-input">
|
||||
<button class="filter-search-btn">
|
||||
<svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user