This commit is contained in:
Daniel 2025-07-26 10:45:40 +08:00
parent a76a520996
commit e1471ff585
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1677,23 +1677,23 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
todayStart := time.Now() todayStart := time.Now()
todayStart = time.Date(todayStart.Year(), todayStart.Month(), todayStart.Day(), 0, 0, 0, 0, time.Local) todayStart = time.Date(todayStart.Year(), todayStart.Month(), todayStart.Day(), 0, 0, 0, 0, time.Local)
if contentTime.Before(todayStart.AddDate(0, 0, -30)) { if contentTime.Before(todayStart.AddDate(0, 0, -30)) {
groupName = contentTime.Format("2006-01") groupName = "0" + contentTime.Format("2006-01") // 开头的数字用于排序,下同
} else if contentTime.Before(todayStart.AddDate(0, 0, -7)) { } else if contentTime.Before(todayStart.AddDate(0, 0, -7)) {
groupName = groupNameLast30Days groupName = "1" + groupNameLast30Days
} else if contentTime.Before(todayStart.AddDate(0, 0, -1)) { } else if contentTime.Before(todayStart.AddDate(0, 0, -1)) {
groupName = groupNameLast7Days groupName = "2" + groupNameLast7Days
} else if contentTime.Before(todayStart) { } else if contentTime.Before(todayStart) {
groupName = groupNameYesterday groupName = "3" + groupNameYesterday
} else if contentTime.After(todayStart) && contentTime.Before(todayStart.AddDate(0, 0, 1)) { } else if (contentTime.After(todayStart) || contentTime.Equal(todayStart)) && contentTime.Before(todayStart.AddDate(0, 0, 1)) {
groupName = groupNameToday groupName = "4" + groupNameToday
} else if (contentTime.After(todayStart.AddDate(0, 0, 1)) && contentTime.Before(todayStart.AddDate(0, 0, 2))) || contentTime.Equal(todayStart.AddDate(0, 0, 1)) {
groupName = groupNameTomorrow
} else if contentTime.After(todayStart.AddDate(0, 0, 30)) { } else if contentTime.After(todayStart.AddDate(0, 0, 30)) {
groupName = contentTime.Format("2006-01") groupName = "8" + contentTime.Format("2006-01")
} else if contentTime.After(todayStart.AddDate(0, 0, 7)) { } else if contentTime.After(todayStart.AddDate(0, 0, 7)) {
groupName = groupNameNext30Days groupName = "7" + groupNameNext30Days
} else if contentTime.After(todayStart.AddDate(0, 0, 1)) { } else if contentTime.After(todayStart.AddDate(0, 0, 1)) {
groupName = groupNameNext7Days groupName = "6" + groupNameNext7Days
} else {
groupName = "5" + groupNameTomorrow
} }
} }
} }
@ -1756,6 +1756,12 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
return view.Groups[i].Name > view.Groups[j].Name return view.Groups[i].Name > view.Groups[j].Name
}) })
} }
if group.Method == av.GroupMethodDateRelative {
for _, v := range view.Groups {
v.Name = v.Name[1:] // 去掉前缀排序数字
}
}
} }
func isGroupByDate(view *av.View) bool { func isGroupByDate(view *av.View) bool {