🎨 Improve av

This commit is contained in:
Daniel 2025-06-27 11:34:56 +08:00
parent d77d29cf78
commit a45b62e76b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 16 additions and 7 deletions

View file

@ -1216,7 +1216,7 @@ func renderAttributeView(attrView *av.AttributeView, viewID, query string, page,
} }
// 做一些数据兼容和订正处理 // 做一些数据兼容和订正处理
checkViewInstance(attrView, view) checkViewInstance(attrView)
upgradeAttributeViewSpec(attrView) upgradeAttributeViewSpec(attrView)
switch view.LayoutType { switch view.LayoutType {

View file

@ -23,14 +23,23 @@ import (
"github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/treenode"
) )
func checkViewInstance(attrView *av.AttributeView, view *av.View) { func checkViewInstance(attrView *av.AttributeView) {
if av.LayoutTypeGallery == view.LayoutType && nil == view.Gallery { changed := false
// 切换为画廊视图时可能没有初始化画廊实例 https://github.com/siyuan-note/siyuan/issues/15122 for i, view := range attrView.Views {
if nil != view.Table { if av.LayoutTypeGallery == view.LayoutType && nil == view.Gallery {
view.LayoutType = av.LayoutTypeTable // 切换为画廊视图时可能没有初始化画廊实例 https://github.com/siyuan-note/siyuan/issues/15122
av.SaveAttributeView(attrView) if nil != view.Table {
view.LayoutType = av.LayoutTypeTable
changed = true
} else {
attrView.Views = append(attrView.Views[:i], attrView.Views[i+1:]...)
changed = true
}
} }
} }
if changed {
av.SaveAttributeView(attrView)
}
} }
func upgradeAttributeViewSpec(attrView *av.AttributeView) { func upgradeAttributeViewSpec(attrView *av.AttributeView) {