fix: keep manual favorites when no nav visit data; external-only visits don't trigger reorder
- Favorites section only rebuilds from Top-4 by visit frequency once real navigation hosts have visit data; otherwise manual Gitea/HomeAgent/AgentMail items are preserved untouched - Pure external-site history (wikipedia etc.) no longer causes favorites to borrow tiles from other sections
This commit is contained in:
@ -301,6 +301,7 @@ func rebuildDashySections() {
|
||||
|
||||
// 收集所有导航项(排除历史访问 section 本身),带 host 访问量
|
||||
hv := hostVisits()
|
||||
|
||||
type cand struct {
|
||||
nav dashyNav
|
||||
host string
|
||||
@ -346,6 +347,36 @@ func rebuildDashySections() {
|
||||
return candidates[i].visits > candidates[j].visits
|
||||
})
|
||||
|
||||
// 导航项若均无访问记录(首次/纯外站访问),保持常用服务原手动配置不动
|
||||
{
|
||||
anyNav := false
|
||||
for _, c := range candidates {
|
||||
if c.visits > 0 {
|
||||
anyNav = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !anyNav {
|
||||
for _, si := range secs {
|
||||
if si.name == histName {
|
||||
si.raw["items"] = []any{map[string]any{
|
||||
"title": "\u7b49\u5f85\u6d4f\u89c8\u5668\u63d2\u4ef6\u63a5\u5165...",
|
||||
"description": "\u540c\u6b65\u540e\u6309\u603b\u8bbf\u95ee\u9891\u6b21\u81ea\u52a8\u6392\u5e8f",
|
||||
"icon": "fas fa-info-circle", "url": "/admin/",
|
||||
}}
|
||||
}
|
||||
}
|
||||
out, err := yaml.Marshal(cfg)
|
||||
if err == nil {
|
||||
tmp := confFile + ".sort-tmp"
|
||||
if err2 := os.WriteFile(tmp, out, 0644); err2 == nil {
|
||||
os.Rename(tmp, confFile)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// host 去重:同 host 只保留访问最高的一条导航项
|
||||
// (rebuild 前常用服务可能已有上一轮写入的副本,与其它 section 同 host 会重复)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user