mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
eea13b713d
commit
ee95f9bf6f
3 changed files with 61 additions and 46 deletions
|
|
@ -350,6 +350,58 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
}
|
||||
}
|
||||
}
|
||||
case av.KeyTypeCreated: // 渲染创建时间
|
||||
ial := map[string]string{}
|
||||
block := item.GetBlockValue()
|
||||
if nil != block {
|
||||
ial = ials[block.Block.ID]
|
||||
}
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
id := itemID
|
||||
if "" != ial["id"] {
|
||||
id = ial["id"]
|
||||
}
|
||||
createdStr := id[:len("20060102150405")]
|
||||
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
||||
if nil == parseErr {
|
||||
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
|
||||
value.Created.IsNotEmpty = true
|
||||
} else {
|
||||
value.Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
|
||||
}
|
||||
case av.KeyTypeUpdated: // 渲染更新时间
|
||||
ial := map[string]string{}
|
||||
block := item.GetBlockValue()
|
||||
if nil != block {
|
||||
ial = ials[block.Block.ID]
|
||||
}
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
updatedStr := ial["updated"]
|
||||
if "" == updatedStr && nil != block {
|
||||
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
||||
value.Updated.IsNotEmpty = true
|
||||
} else {
|
||||
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
|
||||
if nil == parseErr {
|
||||
value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
|
||||
value.Updated.IsNotEmpty = true
|
||||
} else {
|
||||
value.Updated = av.NewFormattedValueUpdated(time.Now().UnixMilli(), 0, av.UpdatedFormatNone)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, item := range collection.GetItems() {
|
||||
for _, value := range item.GetValues() {
|
||||
itemID := item.GetID()
|
||||
|
||||
switch value.Type {
|
||||
case av.KeyTypeRollup: // 渲染汇总
|
||||
rollupKey, _ := attrView.GetKey(value.KeyID)
|
||||
if nil == rollupKey || nil == rollupKey.Rollup {
|
||||
|
|
@ -421,49 +473,6 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
}
|
||||
}
|
||||
}
|
||||
case av.KeyTypeCreated: // 渲染创建时间
|
||||
ial := map[string]string{}
|
||||
block := item.GetBlockValue()
|
||||
if nil != block {
|
||||
ial = ials[block.Block.ID]
|
||||
}
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
id := itemID
|
||||
if "" != ial["id"] {
|
||||
id = ial["id"]
|
||||
}
|
||||
createdStr := id[:len("20060102150405")]
|
||||
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
||||
if nil == parseErr {
|
||||
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
|
||||
value.Created.IsNotEmpty = true
|
||||
} else {
|
||||
value.Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
|
||||
}
|
||||
case av.KeyTypeUpdated: // 渲染更新时间
|
||||
ial := map[string]string{}
|
||||
block := item.GetBlockValue()
|
||||
if nil != block {
|
||||
ial = ials[block.Block.ID]
|
||||
}
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
updatedStr := ial["updated"]
|
||||
if "" == updatedStr && nil != block {
|
||||
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
||||
value.Updated.IsNotEmpty = true
|
||||
} else {
|
||||
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
|
||||
if nil == parseErr {
|
||||
value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
|
||||
value.Updated.IsNotEmpty = true
|
||||
} else {
|
||||
value.Updated = av.NewFormattedValueUpdated(time.Now().UnixMilli(), 0, av.UpdatedFormatNone)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue