Liang Ding 2023-03-22 10:57:11 +08:00
parent e83b41786a
commit 4f3766af15
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
11 changed files with 54 additions and 48 deletions

View file

@ -95,12 +95,12 @@ func setFlashcard(c *gin.Context) {
return
}
if 1 > flashcard.DailyNewCardLimit {
flashcard.DailyNewCardLimit = 1
if 1 > flashcard.NewCardLimit {
flashcard.NewCardLimit = 1
}
if 1 > flashcard.DailyReviewCardLimit {
flashcard.DailyReviewCardLimit = 1
if 1 > flashcard.ReviewCardLimit {
flashcard.ReviewCardLimit = 1
}
model.Conf.Flashcard = flashcard

View file

@ -17,19 +17,19 @@
package conf
type Flashcard struct {
DailyNewCardLimit int `json:"dailyNewCardLimit"` // 每日新卡上限 https://github.com/siyuan-note/siyuan/issues/7695
DailyReviewCardLimit int `json:"dailyReviewCardLimit"` // 每日复习卡上限 https://github.com/siyuan-note/siyuan/issues/7703
List bool `json:"list"` // 是否启用列表块制卡 https://github.com/siyuan-note/siyuan/issues/7701
SuperBlock bool `json:"superBlock"` // 是否启用超级块制卡 https://github.com/siyuan-note/siyuan/issues/7702
Deck bool `json:"deck"` // 是否启用卡包制卡 https://github.com/siyuan-note/siyuan/issues/7724
NewCardLimit int `json:"newCardLimit"` // 新卡上限 https://github.com/siyuan-note/siyuan/issues/7695
ReviewCardLimit int `json:"reviewCardLimit"` // 复习卡上限 https://github.com/siyuan-note/siyuan/issues/7703
List bool `json:"list"` // 是否启用列表块制卡 https://github.com/siyuan-note/siyuan/issues/7701
SuperBlock bool `json:"superBlock"` // 是否启用超级块制卡 https://github.com/siyuan-note/siyuan/issues/7702
Deck bool `json:"deck"` // 是否启用卡包制卡 https://github.com/siyuan-note/siyuan/issues/7724
}
func NewFlashcard() *Flashcard {
return &Flashcard{
DailyNewCardLimit: 20,
DailyReviewCardLimit: 200,
List: true,
SuperBlock: true,
Deck: false,
NewCardLimit: 20,
ReviewCardLimit: 200,
List: true,
SuperBlock: true,
Deck: false,
}
}

View file

@ -318,11 +318,11 @@ func InitConf() {
if nil == Conf.Flashcard {
Conf.Flashcard = conf.NewFlashcard()
}
if 1 > Conf.Flashcard.DailyNewCardLimit {
Conf.Flashcard.DailyNewCardLimit = 20
if 1 > Conf.Flashcard.NewCardLimit {
Conf.Flashcard.NewCardLimit = 20
}
if 1 > Conf.Flashcard.DailyReviewCardLimit {
Conf.Flashcard.DailyReviewCardLimit = 200
if 1 > Conf.Flashcard.ReviewCardLimit {
Conf.Flashcard.ReviewCardLimit = 200
}
if nil == Conf.AI {

View file

@ -915,8 +915,14 @@ func getDeckDueCards(deck *riff.Deck) (ret []riff.Card) {
fsrsCard := c.Impl().(*fsrs.Card)
if fsrs.New == fsrsCard.State {
newCount++
if newCount > Conf.Flashcard.NewCardLimit {
continue
}
} else {
reviewCount++
if reviewCount > Conf.Flashcard.ReviewCardLimit {
continue
}
}
ret = append(ret, c)