mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
♻️ Refactor av
This commit is contained in:
parent
1dcc635f4d
commit
67b8566047
5 changed files with 55 additions and 28 deletions
|
|
@ -572,8 +572,11 @@ func renderAttributeView(c *gin.Context) {
|
||||||
var views []map[string]interface{}
|
var views []map[string]interface{}
|
||||||
for _, v := range attrView.Views {
|
for _, v := range attrView.Views {
|
||||||
pSize := 10
|
pSize := 10
|
||||||
if nil != v.Table && av.LayoutTypeTable == v.LayoutType {
|
switch v.LayoutType {
|
||||||
|
case av.LayoutTypeTable:
|
||||||
pSize = v.Table.PageSize
|
pSize = v.Table.PageSize
|
||||||
|
case av.LayoutTypeGallery:
|
||||||
|
pSize = v.Gallery.PageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
view := map[string]interface{}{
|
view := map[string]interface{}{
|
||||||
|
|
|
||||||
|
|
@ -208,11 +208,13 @@ func NewTableView() (ret *View) {
|
||||||
Name: getI18nName("table"),
|
Name: getI18nName("table"),
|
||||||
LayoutType: LayoutTypeTable,
|
LayoutType: LayoutTypeTable,
|
||||||
Table: &LayoutTable{
|
Table: &LayoutTable{
|
||||||
Spec: 0,
|
BaseLayout: &BaseLayout{
|
||||||
ID: ast.NewNodeID(),
|
Spec: 0,
|
||||||
Filters: []*ViewFilter{},
|
ID: ast.NewNodeID(),
|
||||||
Sorts: []*ViewSort{},
|
Filters: []*ViewFilter{},
|
||||||
PageSize: TableViewDefaultPageSize,
|
Sorts: []*ViewSort{},
|
||||||
|
PageSize: TableViewDefaultPageSize,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
@ -225,11 +227,13 @@ func NewTableViewWithBlockKey(blockKeyID string) (view *View, blockKey, selectKe
|
||||||
Name: name,
|
Name: name,
|
||||||
LayoutType: LayoutTypeTable,
|
LayoutType: LayoutTypeTable,
|
||||||
Table: &LayoutTable{
|
Table: &LayoutTable{
|
||||||
Spec: 0,
|
BaseLayout: &BaseLayout{
|
||||||
ID: ast.NewNodeID(),
|
Spec: 0,
|
||||||
Filters: []*ViewFilter{},
|
ID: ast.NewNodeID(),
|
||||||
Sorts: []*ViewSort{},
|
Filters: []*ViewFilter{},
|
||||||
PageSize: TableViewDefaultPageSize,
|
Sorts: []*ViewSort{},
|
||||||
|
PageSize: TableViewDefaultPageSize,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
blockKey = NewKey(blockKeyID, getI18nName("key"), "", KeyTypeBlock)
|
blockKey = NewKey(blockKeyID, getI18nName("key"), "", KeyTypeBlock)
|
||||||
|
|
@ -246,11 +250,13 @@ func NewGalleryView() (ret *View) {
|
||||||
Name: getI18nName("gallery"),
|
Name: getI18nName("gallery"),
|
||||||
LayoutType: LayoutTypeGallery,
|
LayoutType: LayoutTypeGallery,
|
||||||
Gallery: &LayoutGallery{
|
Gallery: &LayoutGallery{
|
||||||
Spec: 0,
|
BaseLayout: &BaseLayout{
|
||||||
ID: ast.NewNodeID(),
|
Spec: 0,
|
||||||
Filters: []*ViewFilter{},
|
ID: ast.NewNodeID(),
|
||||||
Sorts: []*ViewSort{},
|
Filters: []*ViewFilter{},
|
||||||
PageSize: GalleryViewDefaultPageSize,
|
Sorts: []*ViewSort{},
|
||||||
|
PageSize: GalleryViewDefaultPageSize,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
26
kernel/av/layout.go
Normal file
26
kernel/av/layout.go
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// SiYuan - Refactor your thinking
|
||||||
|
// Copyright (c) 2020-present, b3log.org
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package av
|
||||||
|
|
||||||
|
// BaseLayout 描述了布局的基础结构,包含通用的过滤、排序和分页信息。
|
||||||
|
type BaseLayout struct {
|
||||||
|
Spec int `json:"spec"` // 布局格式版本
|
||||||
|
ID string `json:"id"` // 布局 ID
|
||||||
|
Filters []*ViewFilter `json:"filters"` // 过滤规则
|
||||||
|
Sorts []*ViewSort `json:"sorts"` // 排序规则
|
||||||
|
PageSize int `json:"pageSize"` // 每页行数
|
||||||
|
}
|
||||||
|
|
@ -20,16 +20,12 @@ import "sort"
|
||||||
|
|
||||||
// LayoutGallery 描述了画廊布局的结构。
|
// LayoutGallery 描述了画廊布局的结构。
|
||||||
type LayoutGallery struct {
|
type LayoutGallery struct {
|
||||||
Spec int `json:"spec"` // 布局格式版本
|
*BaseLayout
|
||||||
ID string `json:"id"` // 布局 ID
|
|
||||||
|
|
||||||
CoverFrom int `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段
|
CoverFrom int `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段
|
||||||
CoverFromAssetKeyID string `json:"coverFromAssetKeyId,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效
|
CoverFromAssetKeyID string `json:"coverFromAssetKeyId,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效
|
||||||
CardFields []*ViewGalleryCardField `json:"fields"` // 画廊卡片字段
|
CardFields []*ViewGalleryCardField `json:"fields"` // 画廊卡片字段
|
||||||
CardIDs []string `json:"cardIds"` // 卡片 ID,用于自定义排序
|
CardIDs []string `json:"cardIds"` // 卡片 ID,用于自定义排序
|
||||||
Filters []*ViewFilter `json:"filters"` // 过滤规则
|
|
||||||
Sorts []*ViewSort `json:"sorts"` // 排序规则
|
|
||||||
PageSize int `json:"pageSize"` // 每页卡片数
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ViewGalleryCardField 描述了画廊卡片字段的结构。
|
// ViewGalleryCardField 描述了画廊卡片字段的结构。
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,10 @@ import (
|
||||||
|
|
||||||
// LayoutTable 描述了表格布局的结构。
|
// LayoutTable 描述了表格布局的结构。
|
||||||
type LayoutTable struct {
|
type LayoutTable struct {
|
||||||
Spec int `json:"spec"` // 布局格式版本
|
*BaseLayout
|
||||||
ID string `json:"id"` // 布局 ID
|
|
||||||
|
|
||||||
Columns []*ViewTableColumn `json:"columns"` // 表格列
|
Columns []*ViewTableColumn `json:"columns"` // 表格列
|
||||||
RowIDs []string `json:"rowIds"` // 行 ID,用于自定义排序
|
RowIDs []string `json:"rowIds"` // 行 ID,用于自定义排序
|
||||||
Filters []*ViewFilter `json:"filters"` // 过滤规则
|
|
||||||
Sorts []*ViewSort `json:"sorts"` // 排序规则
|
|
||||||
PageSize int `json:"pageSize"` // 每页行数
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ViewTableColumn 描述了表格列的结构。
|
// ViewTableColumn 描述了表格列的结构。
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue