mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-09 02:08:50 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
a93762abd3
commit
fd4a24243c
3 changed files with 35 additions and 3 deletions
|
|
@ -25,9 +25,9 @@ type LayoutGallery struct {
|
|||
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段
|
||||
CoverFromAssetKeyID string `json:"coverFromAssetKeyId,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效
|
||||
CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片
|
||||
FitImage bool `json:"fitImage"` // 是否适应图片大小
|
||||
ShowIcon bool `json:"showIcon"` // 是否显示图标
|
||||
WrapField bool `json:"wrapField"` // 是否换行字段
|
||||
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
|
||||
ShowIcon bool `json:"showIcon"` // 是否显示字段图标
|
||||
WrapField bool `json:"wrapField"` // 是否换行字段内容
|
||||
|
||||
CardFields []*ViewGalleryCardField `json:"fields"` // 画廊卡片字段
|
||||
CardIDs []string `json:"cardIds"` // 卡片 ID,用于自定义排序
|
||||
|
|
|
|||
|
|
@ -44,6 +44,36 @@ import (
|
|||
"github.com/xrash/smetrics"
|
||||
)
|
||||
|
||||
func (tx *Transaction) doSetAttrViewShowIcon(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewShowIcon(operation)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttrViewShowIcon(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
return
|
||||
case av.LayoutTypeGallery:
|
||||
view.Gallery.ShowIcon = operation.Data.(bool)
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewFitImage(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewFitImage(operation)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewCardSize(op)
|
||||
case "setAttrViewFitImage":
|
||||
ret = tx.doSetAttrViewFitImage(op)
|
||||
case "setAttrViewShowIcon":
|
||||
ret = tx.doSetAttrViewShowIcon(op)
|
||||
}
|
||||
|
||||
if nil != ret {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue