🎨 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)
switch view.LayoutType {

View file

@ -23,15 +23,24 @@ import (
"github.com/siyuan-note/siyuan/kernel/treenode"
)
func checkViewInstance(attrView *av.AttributeView, view *av.View) {
func checkViewInstance(attrView *av.AttributeView) {
changed := false
for i, view := range attrView.Views {
if av.LayoutTypeGallery == view.LayoutType && nil == view.Gallery {
// 切换为画廊视图时可能没有初始化画廊实例 https://github.com/siyuan-note/siyuan/issues/15122
if nil != view.Table {
view.LayoutType = av.LayoutTypeTable
av.SaveAttributeView(attrView)
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) {
currentSpec := attrView.Spec