mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 04:50:59 +08:00
🎨 支持浏览卡包内的闪卡 https://github.com/siyuan-note/siyuan/issues/6943
This commit is contained in:
parent
c4ba046898
commit
7d450f88eb
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func searchRiffCards(c *gin.Context) {
|
func getRiffCards(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
@ -37,7 +37,8 @@ func searchRiffCards(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deckID := arg["deckID"].(string)
|
deckID := arg["deckID"].(string)
|
||||||
blockIDs := model.SearchFlashcard(deckID)
|
page := int(arg["page"].(float64))
|
||||||
|
blockIDs := model.GetFlashcards(deckID, page)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"blockIDs": blockIDs,
|
"blockIDs": blockIDs,
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||||||
ginServer.Handle("POST", "/api/riff/removeRiffCards", model.CheckAuth, removeRiffCards)
|
ginServer.Handle("POST", "/api/riff/removeRiffCards", model.CheckAuth, removeRiffCards)
|
||||||
ginServer.Handle("POST", "/api/riff/getRiffDueCards", model.CheckAuth, getRiffDueCards)
|
ginServer.Handle("POST", "/api/riff/getRiffDueCards", model.CheckAuth, getRiffDueCards)
|
||||||
ginServer.Handle("POST", "/api/riff/reviewRiffCard", model.CheckAuth, reviewRiffCard)
|
ginServer.Handle("POST", "/api/riff/reviewRiffCard", model.CheckAuth, reviewRiffCard)
|
||||||
ginServer.Handle("POST", "/api/riff/searchRiffCards", model.CheckAuth, searchRiffCards)
|
ginServer.Handle("POST", "/api/riff/getRiffCards", model.CheckAuth, getRiffCards)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
||||||
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)
|
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -38,7 +39,27 @@ import (
|
|||||||
var Decks = map[string]*riff.Deck{}
|
var Decks = map[string]*riff.Deck{}
|
||||||
var deckLock = sync.Mutex{}
|
var deckLock = sync.Mutex{}
|
||||||
|
|
||||||
func SearchFlashcard(deckID string) (blockIDs []string) {
|
func GetFlashcards(deckID string, page int) (blockIDs []string) {
|
||||||
|
deck := Decks[deckID]
|
||||||
|
if nil == deck {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var allBlockIDs []string
|
||||||
|
for bID, _ := range deck.BlockCard {
|
||||||
|
allBlockIDs = append(allBlockIDs, bID)
|
||||||
|
}
|
||||||
|
sort.Strings(allBlockIDs)
|
||||||
|
|
||||||
|
start := (page - 1) * 20
|
||||||
|
end := page * 20
|
||||||
|
if start > len(allBlockIDs) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if end > len(allBlockIDs) {
|
||||||
|
end = len(allBlockIDs)
|
||||||
|
}
|
||||||
|
blockIDs = allBlockIDs[start:end]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user