This commit is contained in:
Daniel 2025-07-28 23:48:24 +08:00
parent 396450a2ec
commit 7906e8f516
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1569,12 +1569,14 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
type GroupState struct {
Folded bool
Hidden int
Sort int
}
groupStates := map[string]*GroupState{}
for _, groupView := range view.Groups {
for i, groupView := range view.Groups {
groupStates[groupView.Name] = &GroupState{
Folded: groupView.GroupFolded,
Hidden: groupView.GroupHidden,
Sort: i,
}
}
@ -1730,7 +1732,7 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
view.GroupUpdated = time.Now().UnixMilli()
// 恢复分组视图状态
// 恢复分组视图状态
for _, groupView := range view.Groups {
if state, ok := groupStates[groupView.Name]; ok {
groupView.GroupFolded = state.Folded
@ -1738,6 +1740,18 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
}
}
// 恢复分组视图的顺序
if len(groupStates) > 0 {
sort.SliceStable(view.Groups, func(i, j int) bool {
if stateI, ok := groupStates[view.Groups[i].Name]; ok {
if stateJ, ok := groupStates[view.Groups[j].Name]; ok {
return stateI.Sort < stateJ.Sort
}
}
return false
})
}
if av.GroupOrderMan != view.Group.Order {
sort.SliceStable(view.Groups, func(i, j int) bool {
iName, jName := view.Groups[i].Name, view.Groups[j].Name