From 38570cb27fedafeb3d7f2e006d562084cc6829eb Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 29 Dec 2022 21:52:36 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=8D=A1=E5=8C=85=E5=86=85=E7=9A=84=E9=97=AA=E5=8D=A1=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/6943?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/riff.go | 6 ++++-- kernel/model/flashcard.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/api/riff.go b/kernel/api/riff.go index fb8bc54f0..3841a2815 100644 --- a/kernel/api/riff.go +++ b/kernel/api/riff.go @@ -38,9 +38,11 @@ func getRiffCards(c *gin.Context) { deckID := arg["deckID"].(string) page := int(arg["page"].(float64)) - blockIDs := model.GetFlashcards(deckID, page) + blockIDs, total, pageCount := model.GetFlashcards(deckID, page) ret.Data = map[string]interface{}{ - "blockIDs": blockIDs, + "blockIDs": blockIDs, + "total": total, + "pageCount": pageCount, } } diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 4d45ad4d8..c292b9b0d 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -39,7 +39,7 @@ import ( var Decks = map[string]*riff.Deck{} var deckLock = sync.Mutex{} -func GetFlashcards(deckID string, page int) (blockIDs []string) { +func GetFlashcards(deckID string, page int) (blockIDs []string, total, pageCount int) { deck := Decks[deckID] if nil == deck { return @@ -60,6 +60,8 @@ func GetFlashcards(deckID string, page int) (blockIDs []string) { end = len(allBlockIDs) } blockIDs = allBlockIDs[start:end] + total = len(allBlockIDs) + pageCount = total / 20 return }