mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
🎨 Improve av https://github.com/siyuan-note/siyuan/issues/15524
This commit is contained in:
parent
c640bfd91b
commit
7b8d163723
3 changed files with 16 additions and 15 deletions
|
|
@ -333,7 +333,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||||
switch value.Type {
|
switch value.Type {
|
||||||
case av.KeyTypeBlock: // 对于主键可能需要填充静态锚文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
|
case av.KeyTypeBlock: // 对于主键可能需要填充静态锚文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
|
||||||
if nil != value.Block {
|
if nil != value.Block {
|
||||||
for k, v := range ials[itemID] {
|
for k, v := range ials[value.Block.ID] {
|
||||||
if k == av.NodeAttrViewStaticText+"-"+attrView.ID {
|
if k == av.NodeAttrViewStaticText+"-"+attrView.ID {
|
||||||
value.Block.Content = v
|
value.Block.Content = v
|
||||||
break
|
break
|
||||||
|
|
@ -451,11 +451,11 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||||
keyValues = append(keyValues, &av.KeyValues{Key: createdKey, Values: []*av.Value{{ID: value.ID, KeyID: createdKey.ID, BlockID: itemID, Type: av.KeyTypeCreated, Created: value.Created}}})
|
keyValues = append(keyValues, &av.KeyValues{Key: createdKey, Values: []*av.Value{{ID: value.ID, KeyID: createdKey.ID, BlockID: itemID, Type: av.KeyTypeCreated, Created: value.Created}}})
|
||||||
items[itemID] = keyValues
|
items[itemID] = keyValues
|
||||||
case av.KeyTypeUpdated: // 渲染更新时间
|
case av.KeyTypeUpdated: // 渲染更新时间
|
||||||
ial := ials[itemID]
|
ial := map[string]string{}
|
||||||
if nil == ial {
|
|
||||||
ial = map[string]string{}
|
|
||||||
}
|
|
||||||
block := item.GetBlockValue()
|
block := item.GetBlockValue()
|
||||||
|
if nil != block {
|
||||||
|
ial = ials[block.Block.ID]
|
||||||
|
}
|
||||||
updatedStr := ial["updated"]
|
updatedStr := ial["updated"]
|
||||||
if "" == updatedStr && nil != block {
|
if "" == updatedStr && nil != block {
|
||||||
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
||||||
|
|
@ -488,9 +488,10 @@ func fillAttributeViewTemplateValues(attrView *av.AttributeView, collection av.C
|
||||||
switch value.Type {
|
switch value.Type {
|
||||||
case av.KeyTypeTemplate: // 渲染模板字段
|
case av.KeyTypeTemplate: // 渲染模板字段
|
||||||
keyValues := items[itemID]
|
keyValues := items[itemID]
|
||||||
ial := ials[itemID]
|
ial := map[string]string{}
|
||||||
if nil == ial {
|
blockVal := item.GetBlockValue()
|
||||||
ial = map[string]string{}
|
if nil != blockVal {
|
||||||
|
ial = ials[blockVal.Block.ID]
|
||||||
}
|
}
|
||||||
content, renderErr := RenderTemplateField(ial, keyValues, value.Template.Content)
|
content, renderErr := RenderTemplateField(ial, keyValues, value.Template.Content)
|
||||||
value.Template.Content = content
|
value.Template.Content = content
|
||||||
|
|
|
||||||
|
|
@ -65,11 +65,11 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
||||||
|
|
||||||
// 批量加载绑定块对应的树
|
// 批量加载绑定块对应的树
|
||||||
var ialIDs []string
|
var ialIDs []string
|
||||||
for cardID, keyValues := range cardsValues {
|
for _, keyValues := range cardsValues {
|
||||||
for _, kValues := range keyValues {
|
for _, kValues := range keyValues {
|
||||||
block := kValues.GetBlockValue()
|
blockVal := kValues.GetBlockValue()
|
||||||
if nil != block && !block.IsDetached {
|
if nil != blockVal && !blockVal.IsDetached {
|
||||||
ialIDs = append(ialIDs, cardID)
|
ialIDs = append(ialIDs, blockVal.Block.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,9 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
|
||||||
// 批量获取块属性以提升性能
|
// 批量获取块属性以提升性能
|
||||||
var ialIDs []string
|
var ialIDs []string
|
||||||
for _, row := range ret.Rows {
|
for _, row := range ret.Rows {
|
||||||
block := row.GetBlockValue()
|
blockVal := row.GetBlockValue()
|
||||||
if nil != block && !block.IsDetached {
|
if nil != blockVal && !blockVal.IsDetached {
|
||||||
ialIDs = append(ialIDs, row.ID)
|
ialIDs = append(ialIDs, blockVal.Block.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ials := BatchGetBlockAttrs(ialIDs)
|
ials := BatchGetBlockAttrs(ialIDs)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue