This commit is contained in:
Daniel 2025-07-04 12:00:47 +08:00
parent d7f56c2bb6
commit 1ab9b5c518
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
24 changed files with 141 additions and 85 deletions

View file

@ -189,7 +189,7 @@ type View struct {
PageSize int `json:"pageSize"` // 每页条目数
LayoutType LayoutType `json:"type"` // 当前布局类型
Table *LayoutTable `json:"table,omitempty"` // 表格布局
Gallery *LayoutGallery `json:"gallery,omitempty"` // 画廊布局
Gallery *LayoutGallery `json:"gallery,omitempty"` // 卡片布局
ItemIDs []string `json:"itemIds,omitempty"` // 项目 ID 列表,用于维护所有项目
Groups []*View `json:"groups,omitempty"` // 分组视图列表
@ -206,7 +206,7 @@ type LayoutType string
const (
LayoutTypeTable LayoutType = "table" // 属性视图类型 - 表格
LayoutTypeGallery LayoutType = "gallery" // 属性视图类型 - 画廊
LayoutTypeGallery LayoutType = "gallery" // 属性视图类型 - 卡片
)
const (

View file

@ -111,7 +111,7 @@ func (baseInstanceField *BaseInstanceField) GetID() string {
}
// Collection 描述了一个集合的接口。
// 集合可以是表格、画廊等,包含多个项目。
// 集合可以是表格、卡片等,包含多个项目。
type Collection interface {
// GetItems 返回集合中的所有项目。
@ -138,7 +138,7 @@ type Field interface {
}
// Item 描述了一个项目的接口。
// 项目可以是表格行、画廊卡片等。
// 项目可以是表格行、卡片等。
type Item interface {
// GetBlockValue 返回主键的值。

View file

@ -20,7 +20,7 @@ import (
"github.com/88250/lute/ast"
)
// LayoutGallery 描述了画廊布局的结构。
// LayoutGallery 描述了卡片布局的结构。
type LayoutGallery struct {
*BaseLayout
@ -30,7 +30,7 @@ type LayoutGallery struct {
CardSize CardSize `json:"cardSize"` // 卡片大小0小卡片1中卡片2大卡片
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
CardFields []*ViewGalleryCardField `json:"fields"` // 画廊卡片字段
CardFields []*ViewGalleryCardField `json:"fields"` // 卡片字段
// TODO CardIDs 字段已经废弃,计划于 2026 年 6 月 30 日后删除 https://github.com/siyuan-note/siyuan/issues/15194
//Deprecated
@ -70,7 +70,7 @@ const (
CardSizeLarge // 大卡片
)
// CoverFrom 描述了画廊中的卡片封面来源的枚举类型。
// CoverFrom 描述了卡片封面来源的枚举类型。
type CoverFrom int
const (
@ -80,12 +80,12 @@ const (
CoverFromContentBlock // 内容块
)
// ViewGalleryCardField 描述了画廊卡片字段的结构。
// ViewGalleryCardField 描述了卡片字段的结构。
type ViewGalleryCardField struct {
*BaseField
}
// Gallery 描述了画廊实例的结构。
// Gallery 描述了卡片视图实例的结构。
type Gallery struct {
*BaseInstance
@ -94,12 +94,12 @@ type Gallery struct {
CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比
CardSize CardSize `json:"cardSize"` // 卡片大小
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
Fields []*GalleryField `json:"fields"` // 画廊字段
Cards []*GalleryCard `json:"cards"` // 画廊卡片
CardCount int `json:"cardCount"` // 画廊总卡片数
Fields []*GalleryField `json:"fields"` // 卡片字段
Cards []*GalleryCard `json:"cards"` // 卡片
CardCount int `json:"cardCount"` // 总卡片数
}
// GalleryCard 描述了画廊实例卡片的结构。
// GalleryCard 描述了卡片实例的结构。
type GalleryCard struct {
ID string `json:"id"` // 卡片 ID
Values []*GalleryFieldValue `json:"values"` // 卡片字段值
@ -108,12 +108,12 @@ type GalleryCard struct {
CoverContent string `json:"coverContent"` // 卡片封面文本内容
}
// GalleryField 描述了画廊实例卡片字段的结构。
// GalleryField 描述了卡片实例字段的结构。
type GalleryField struct {
*BaseInstanceField
}
// GalleryFieldValue 描述了画廊实例字段值的结构。
// GalleryFieldValue 描述了卡片字段实例值的结构。
type GalleryFieldValue struct {
*BaseValue
}

View file

@ -17,5 +17,5 @@
package av
func (gallery *Gallery) Calc() {
// 画廊视图不支持计算
// 卡片视图不支持计算
}

View file

@ -50,7 +50,7 @@ type ViewTableColumn struct {
Calc *ColumnCalc `json:"calc,omitempty"` // 计算
}
// Table 描述了表格实例的结构。
// Table 描述了表格视图实例的结构。
type Table struct {
*BaseInstance

View file

@ -3234,7 +3234,7 @@ func AddAttributeViewKey(avID, keyID, keyName, keyType, keyIcon, previousKeyID s
if nil != view.Table {
if "" == previousKeyID {
if av.LayoutTypeGallery == currentView.LayoutType {
// 如果当前视图是画廊视图则添加到最后
// 如果当前视图是卡片视图则添加到最后
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{BaseField: &av.BaseField{ID: key.ID}})
} else {
view.Table.Columns = append([]*av.ViewTableColumn{{BaseField: &av.BaseField{ID: key.ID}}}, view.Table.Columns...)

View file

@ -48,7 +48,7 @@ func checkAttrView(attrView *av.AttributeView, view *av.View) {
// 视图类型不匹配时需要订正
for i, v := range attrView.Views {
if av.LayoutTypeGallery == v.LayoutType && nil == v.Gallery {
// 切换为画廊视图时可能没有初始化画廊实例 https://github.com/siyuan-note/siyuan/issues/15122
// 切换为卡片视图时可能没有初始化卡片实例 https://github.com/siyuan-note/siyuan/issues/15122
if nil != v.Table {
v.LayoutType = av.LayoutTypeTable
changed = true