mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 03:50:16 +08:00
🎨 支持基于文档复习闪卡 https://github.com/siyuan-note/siyuan/issues/7057
This commit is contained in:
parent
26e62e1eda
commit
f552b17f53
@ -76,13 +76,6 @@ func getTreeRiffDueCards(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootID := arg["rootID"].(string)
|
rootID := arg["rootID"].(string)
|
||||||
err := model.AddTreeFlashcards(rootID)
|
|
||||||
if nil != err {
|
|
||||||
ret.Code = -1
|
|
||||||
ret.Msg = err.Error()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cards, err := model.GetTreeDueFlashcards(rootID)
|
cards, err := model.GetTreeDueFlashcards(rootID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
|
@ -143,10 +143,15 @@ func GetTreeDueFlashcards(rootID string) (ret []*Flashcard, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockIDs := map[string]bool{}
|
blockIDs := map[string]bool{}
|
||||||
for n := tree.Root.FirstChild; nil != n; n = n.Next {
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
blockIDs[n.ID] = true
|
if !entering || !n.IsBlock() {
|
||||||
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockIDs[n.ID] = true
|
||||||
|
return ast.WalkContinue
|
||||||
|
})
|
||||||
|
|
||||||
cards := deck.Dues()
|
cards := deck.Dues()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
for _, card := range cards {
|
for _, card := range cards {
|
||||||
@ -336,19 +341,6 @@ func RemoveFlashcards(deckID string, blockIDs []string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddTreeFlashcards(rootID string) (err error) {
|
|
||||||
tree, err := loadTreeByBlockID(rootID)
|
|
||||||
if nil != err {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var blockIDs []string
|
|
||||||
for n := tree.Root.FirstChild; nil != n; n = n.Next {
|
|
||||||
blockIDs = append(blockIDs, n.ID)
|
|
||||||
}
|
|
||||||
return AddFlashcards(builtinDeckID, blockIDs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddFlashcards(deckID string, blockIDs []string) (err error) {
|
func AddFlashcards(deckID string, blockIDs []string) (err error) {
|
||||||
deckLock.Lock()
|
deckLock.Lock()
|
||||||
defer deckLock.Unlock()
|
defer deckLock.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user