An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 支持配置闪卡 https://github.com/siyuan-note/siyuan/issues/7704
Liang Ding51f2a23cb551
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex 2ebc425ec8..0c584a6110 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -64,13 +64,14 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, pagerootIDs = append(rootIDs, strings.TrimSuffix(entry.Name(), ".sy"))}- treeBlockIDs := map[string]bool{}+ var treeBlockIDs []stringfor _, rootID := range rootIDs {blockIDs := getTreeSubTreeChildBlocks(rootID)- for blockID, _ := range blockIDs {- treeBlockIDs[blockID] = true+ for _, blockID := range blockIDs {+ treeBlockIDs = append(treeBlockIDs, blockID)}}+ treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)deck := Decks[builtinDeckID]if nil == deck {@@ -80,7 +81,7 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, pagevar allBlockIDs []stringdeckBlockIDs := deck.GetBlockIDs()for _, blockID := range deckBlockIDs {- if treeBlockIDs[blockID] {+ if gulu.Str.Contains(blockID, treeBlockIDs) {allBlockIDs = append(allBlockIDs, blockID)}}@@ -102,7 +103,7 @@ func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCoudeckBlockIDs := deck.GetBlockIDs()treeBlockIDs := getTreeSubTreeChildBlocks(rootID)for _, blockID := range deckBlockIDs {- if treeBlockIDs[blockID] {+ if gulu.Str.Contains(blockID, treeBlockIDs) {allBlockIDs = append(allBlockIDs, blockID)}}@@ -302,13 +303,14 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*FlrootIDs = append(rootIDs, strings.TrimSuffix(entry.Name(), ".sy"))}- treeBlockIDs := map[string]bool{}+ var treeBlockIDs []stringfor _, rootID := range rootIDs {blockIDs := getTreeSubTreeChildBlocks(rootID)- for blockID, _ := range blockIDs {- treeBlockIDs[blockID] = true+ for _, blockID := range blockIDs {+ treeBlockIDs = append(treeBlockIDs, blockID)}}+ treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)deck := Decks[builtinDeckID]if nil == deck {@@ -316,14 +318,10 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Flreturn}- cards := getDeckDueCards(deck, reviewedCardIDs)+ cards := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)now := time.Now()for _, card := range cards {blockID := card.BlockID()- if !treeBlockIDs[blockID] {- continue- }-ret = append(ret, newFlashcard(card, blockID, builtinDeckID, now))}if 1 > len(ret) {@@ -347,14 +345,10 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash}treeBlockIDs := getTreeSubTreeChildBlocks(rootID)- cards := getDeckDueCards(deck, reviewedCardIDs)+ cards := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)now := time.Now()for _, card := range cards {blockID := card.BlockID()- if !treeBlockIDs[blockID] {- continue- }-ret = append(ret, newFlashcard(card, blockID, builtinDeckID, now))}if 1 > len(ret) {@@ -363,9 +357,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flashreturn}-func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs map[string]bool) {- treeBlockIDs = map[string]bool{}-+func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {tree, err := loadTreeByBlockID(rootID)if nil != err {return@@ -394,7 +386,7 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs map[string]bool) {return ast.WalkContinue}- treeBlockIDs[n.ID] = true+ treeBlockIDs = append(treeBlockIDs, n.ID)return ast.WalkContinue})}@@ -426,7 +418,7 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcardreturn}- cards := getDeckDueCards(deck, reviewedCardIDs)+ cards := getDeckDueCards(deck, reviewedCardIDs, nil)now := time.Now()for _, card := range cards {blockID := card.BlockID()@@ -446,7 +438,7 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcardfunc getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard) {now := time.Now()for _, deck := range Decks {- cards := getDeckDueCards(deck, reviewedCardIDs)+ cards := getDeckDueCards(deck, reviewedCardIDs, nil)for _, card := range cards {blockID := card.BlockID()if nil == treenode.GetBlockTree(blockID) {@@ -895,7 +887,7 @@ func getDeckIDs() (deckIDs []string) {return}-func getDeckDueCards(deck *riff.Deck, reviewedCardIDs []string) (ret []riff.Card) {+func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string) (ret []riff.Card) {ret = []riff.Card{}dues := deck.Dues()@@ -906,6 +898,10 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs []string) (ret []riff.Cardcontinue}+ if 0 < len(blockIDs) && !gulu.Str.Contains(c.BlockID(), blockIDs) {+ continue+ }+fsrsCard := c.Impl().(*fsrs.Card)if fsrs.New == fsrsCard.State {newCount++