mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 07:48:49 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
5df063fbec
commit
c145cd2a95
3 changed files with 33 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ type LayoutGallery struct {
|
|||
|
||||
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段
|
||||
CoverFromAssetKeyID string `json:"coverFromAssetKeyId,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效
|
||||
CardSize CardSize `json:"cardSize"` // 卡片大小
|
||||
CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片
|
||||
FitImage bool `json:"fitImage"` // 是否适应图片大小
|
||||
ShowIcon bool `json:"showIcon"` // 是否显示图标
|
||||
WrapField bool `json:"wrapField"` // 是否换行字段
|
||||
|
|
|
|||
|
|
@ -44,6 +44,36 @@ import (
|
|||
"github.com/xrash/smetrics"
|
||||
)
|
||||
|
||||
func (tx *Transaction) doSetAttrViewCardSize(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewCardSize(operation)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttrViewCardSize(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.CardSize = av.CardSize(operation.Data.(float64))
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewCoverFromAssetKeyID(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewCoverFromAssetKeyID(operation)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -282,6 +282,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewCoverFrom(op)
|
||||
case "setAttrViewCoverFromAssetKeyID":
|
||||
ret = tx.doSetAttrViewCoverFromAssetKeyID(op)
|
||||
case "setAttrViewCardSize":
|
||||
ret = tx.doSetAttrViewCardSize(op)
|
||||
}
|
||||
|
||||
if nil != ret {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue