From 692665f1000d994cb132b5ea370fa52472371ec3 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 10:40:04 +0800 Subject: [PATCH 1/7] :art: Card view supports displaying field names https://github.com/siyuan-note/siyuan/issues/15180 --- kernel/av/layout_gallery.go | 2 ++ kernel/model/attribute_view.go | 31 +++++++++++++++++++++++++++++++ kernel/model/transaction.go | 2 ++ kernel/sql/av_gallery.go | 1 + 4 files changed, 36 insertions(+) diff --git a/kernel/av/layout_gallery.go b/kernel/av/layout_gallery.go index 817984383..f97252459 100644 --- a/kernel/av/layout_gallery.go +++ b/kernel/av/layout_gallery.go @@ -29,6 +29,7 @@ type LayoutGallery struct { CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比 CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片 FitImage bool `json:"fitImage"` // 是否适应封面图片大小 + DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称 CardFields []*ViewGalleryCardField `json:"fields"` // 卡片字段 @@ -94,6 +95,7 @@ type Gallery struct { CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比 CardSize CardSize `json:"cardSize"` // 卡片大小 FitImage bool `json:"fitImage"` // 是否适应封面图片大小 + DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称 Fields []*GalleryField `json:"fields"` // 卡片字段 Cards []*GalleryCard `json:"cards"` // 卡片 CardCount int `json:"cardCount"` // 总卡片数 diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index f90868e69..905a4df44 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -514,6 +514,36 @@ func setAttrViewFitImage(operation *Operation) (err error) { return } +func (tx *Transaction) doSetAttrViewDisplayFieldName(operation *Operation) (ret *TxErr) { + err := setAttrViewDisplayFieldName(operation) + if err != nil { + return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()} + } + return +} + +func setAttrViewDisplayFieldName(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.DisplayFieldName = operation.Data.(bool) + } + + err = av.SaveAttributeView(attrView) + return +} + func (tx *Transaction) doSetAttrViewCardSize(operation *Operation) (ret *TxErr) { err := setAttrViewCardSize(operation) if err != nil { @@ -2503,6 +2533,7 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErr view.Gallery.CoverFromAssetKeyID = masterView.Gallery.CoverFromAssetKeyID view.Gallery.CardSize = masterView.Gallery.CardSize view.Gallery.FitImage = masterView.Gallery.FitImage + view.Gallery.DisplayFieldName = masterView.Gallery.DisplayFieldName view.Gallery.ShowIcon = masterView.Gallery.ShowIcon view.Gallery.WrapField = masterView.Gallery.WrapField } diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 0f65692a2..1057fed86 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -289,6 +289,8 @@ func performTx(tx *Transaction) (ret *TxErr) { ret = tx.doSetAttrViewCardSize(op) case "setAttrViewFitImage": ret = tx.doSetAttrViewFitImage(op) + case "setDisplayFieldName": + ret = tx.doSetAttrViewDisplayFieldName(op) case "setAttrViewShowIcon": ret = tx.doSetAttrViewShowIcon(op) case "setAttrViewWrapField": diff --git a/kernel/sql/av_gallery.go b/kernel/sql/av_gallery.go index d4e937b81..f09b222f4 100644 --- a/kernel/sql/av_gallery.go +++ b/kernel/sql/av_gallery.go @@ -26,6 +26,7 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query CardAspectRatio: view.Gallery.CardAspectRatio, CardSize: view.Gallery.CardSize, FitImage: view.Gallery.FitImage, + DisplayFieldName: view.Gallery.DisplayFieldName, Fields: []*av.GalleryField{}, Cards: []*av.GalleryCard{}, } From f0ff16c60a1b7e84305a8a3ef16b7e17c991d11f Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 10:51:02 +0800 Subject: [PATCH 2/7] :art: Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964 --- kernel/model/attribute_view.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 905a4df44..e2042e168 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -4682,11 +4682,11 @@ func regenAttrViewViewGroups(attrView *av.AttributeView, keyID string) { for _, g := range view.Groups { if view.Group.HideEmpty { - if 2 != g.GroupHidden && 1 > len(g.GroupItemIDs) { + if 0 == g.GroupHidden && 1 > len(g.GroupItemIDs) { g.GroupHidden = 1 } } else { - if 2 != g.GroupHidden { + if 1 == g.GroupHidden { g.GroupHidden = 0 } } From b358d4b70fe5c7ffccc06cce918d8f7ba77dc22c Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 10:54:33 +0800 Subject: [PATCH 3/7] :art: Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964 --- kernel/model/attribute_view.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index e2042e168..9af501b02 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -4682,11 +4682,15 @@ func regenAttrViewViewGroups(attrView *av.AttributeView, keyID string) { for _, g := range view.Groups { if view.Group.HideEmpty { - if 0 == g.GroupHidden && 1 > len(g.GroupItemIDs) { - g.GroupHidden = 1 + if 1 > len(g.GroupItemIDs) { + if 0 == g.GroupHidden { + g.GroupHidden = 1 + } + } else { + g.GroupHidden = 0 } } else { - if 1 == g.GroupHidden { + if 2 != g.GroupHidden { g.GroupHidden = 0 } } From 2f57e57b920dee2f0b278fba9abb2832d171ad53 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 11:10:26 +0800 Subject: [PATCH 4/7] :art: Improve status bar index creation information prompt https://github.com/siyuan-note/siyuan/issues/15390 --- kernel/model/box.go | 7 +++++++ kernel/model/index.go | 6 ++++++ kernel/model/repository.go | 9 +-------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/kernel/model/box.go b/kernel/model/box.go index b38b1a6b7..2261f5378 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -676,7 +676,14 @@ func FullReindex() { task.AppendTask(task.ReloadUI, util.ReloadUI) } +var fullReindexing bool + func fullReindex() { + fullReindexing = true + defer func() { + fullReindexing = false + }() + util.PushEndlessProgress(Conf.language(35)) defer util.PushClearProgress() diff --git a/kernel/model/index.go b/kernel/model/index.go index c9721623b..fba733b61 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -368,6 +368,12 @@ func subscribeSQLEvents() { // util.ContextPushMsg(context, msg) //}) eventbus.Subscribe(eventbus.EvtSQLInsertBlocksFTS, func(context map[string]interface{}, blockCount int, hash string) { + if !fullReindexing { + // 如果不是全量重建索引,则不显示进度信息 + // Improve status bar index creation information prompt https://github.com/siyuan-note/siyuan/issues/15390 + return + } + current := context["current"].(int) total := context["total"] msg := fmt.Sprintf(Conf.Language(90), current, total, blockCount, hash) diff --git a/kernel/model/repository.go b/kernel/model/repository.go index d0c01eb79..b84b468f5 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -54,7 +54,6 @@ import ( "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/conf" "github.com/siyuan-note/siyuan/kernel/filesys" - "github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/task" "github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/util" @@ -772,13 +771,7 @@ func checkoutRepo(id string) { return } - task.AppendTask(task.DatabaseIndexFull, fullReindex) - task.AppendTask(task.DatabaseIndexRef, IndexRefs) - go func() { - sql.FlushQueue() - ResetVirtualBlockRefCache() - }() - task.AppendTask(task.ReloadUI, util.ReloadUIResetScroll) + FullReindex() if syncEnabled { task.AppendAsyncTaskWithDelay(task.PushMsg, 7*time.Second, util.PushMsg, Conf.Language(134), 0) From 9da208ec524adee2bd96a0123f9b40c9c071dcc4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 11:23:26 +0800 Subject: [PATCH 5/7] :art: Improve status bar index creation information prompt https://github.com/siyuan-note/siyuan/issues/15390 --- kernel/model/box.go | 6 ++---- kernel/model/index.go | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/model/box.go b/kernel/model/box.go index 2261f5378..abd9ad823 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -676,12 +676,10 @@ func FullReindex() { task.AppendTask(task.ReloadUI, util.ReloadUI) } -var fullReindexing bool - func fullReindex() { - fullReindexing = true + pushSQLInsertBlocksFTSMsg = true defer func() { - fullReindexing = false + pushSQLInsertBlocksFTSMsg = false }() util.PushEndlessProgress(Conf.language(35)) diff --git a/kernel/model/index.go b/kernel/model/index.go index fba733b61..ab8d64ccb 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -359,6 +359,8 @@ func init() { subscribeSQLEvents() } +var pushSQLInsertBlocksFTSMsg bool + func subscribeSQLEvents() { // 使用下面的 EvtSQLInsertBlocksFTS 就可以了 //eventbus.Subscribe(eventbus.EvtSQLInsertBlocks, func(context map[string]interface{}, current, total, blockCount int, hash string) { @@ -368,7 +370,7 @@ func subscribeSQLEvents() { // util.ContextPushMsg(context, msg) //}) eventbus.Subscribe(eventbus.EvtSQLInsertBlocksFTS, func(context map[string]interface{}, blockCount int, hash string) { - if !fullReindexing { + if !pushSQLInsertBlocksFTSMsg { // 如果不是全量重建索引,则不显示进度信息 // Improve status bar index creation information prompt https://github.com/siyuan-note/siyuan/issues/15390 return From 1fd3f92137391155be18881693b817ba600a9672 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 11:24:57 +0800 Subject: [PATCH 6/7] :art: Improve status bar index creation information prompt https://github.com/siyuan-note/siyuan/issues/15390 --- kernel/model/file.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/model/file.go b/kernel/model/file.go index 41dcb0a4b..67cf8c8b9 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1306,6 +1306,10 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) } FlushTxQueue() + pushSQLInsertBlocksFTSMsg = true + defer func() { + pushSQLInsertBlocksFTSMsg = false + }() luteEngine := util.NewLute() count := 0 for fromPath, fromBox := range pathsBoxes { From 7569fec509d98dc8781f3969d91eb9ecb6f041a1 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 30 Jul 2025 11:31:54 +0800 Subject: [PATCH 7/7] :art: Improve status bar index creation information prompt https://github.com/siyuan-note/siyuan/issues/15390 --- kernel/model/file.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index 67cf8c8b9..41dcb0a4b 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1306,10 +1306,6 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) } FlushTxQueue() - pushSQLInsertBlocksFTSMsg = true - defer func() { - pushSQLInsertBlocksFTSMsg = false - }() luteEngine := util.NewLute() count := 0 for fromPath, fromBox := range pathsBoxes {