mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 14:28:49 +01:00
🎨 支持浏览卡包内的闪卡 https://github.com/siyuan-note/siyuan/issues/6943
This commit is contained in:
parent
38570cb27f
commit
b999d293d5
1 changed files with 5 additions and 3 deletions
|
|
@ -18,6 +18,7 @@ package model
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
|
@ -45,14 +46,15 @@ func GetFlashcards(deckID string, page int) (blockIDs []string, total, pageCount
|
|||
return
|
||||
}
|
||||
|
||||
const pageSize = 20
|
||||
var allBlockIDs []string
|
||||
for bID, _ := range deck.BlockCard {
|
||||
allBlockIDs = append(allBlockIDs, bID)
|
||||
}
|
||||
sort.Strings(allBlockIDs)
|
||||
|
||||
start := (page - 1) * 20
|
||||
end := page * 20
|
||||
start := (page - 1) * pageSize
|
||||
end := page * pageSize
|
||||
if start > len(allBlockIDs) {
|
||||
return
|
||||
}
|
||||
|
|
@ -61,7 +63,7 @@ func GetFlashcards(deckID string, page int) (blockIDs []string, total, pageCount
|
|||
}
|
||||
blockIDs = allBlockIDs[start:end]
|
||||
total = len(allBlockIDs)
|
||||
pageCount = total / 20
|
||||
pageCount = int(math.Ceil(float64(total) / float64(pageSize)))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue