Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-02-24 20:03:03 +08:00
commit 3a35e4f161
6 changed files with 29 additions and 20 deletions

View File

@ -174,6 +174,7 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
if (["0", "1", "2", "3"].includes(type)) {
fetchPost("/api/riff/reviewRiffCard", {
deckID: blocks[index].deckID,
cardID: blocks[index].cardID,
blockID: blocks[index].blockID,
rating: parseInt(type)
}, () => {

View File

@ -67,8 +67,9 @@ interface ICardPackage {
}
interface ICard {
blockID: string
deckID: string
cardID: string
blockID: string
nextDues: IObject
}

View File

@ -57,9 +57,9 @@ func getRiffCards(c *gin.Context) {
deckID := arg["id"].(string)
page := int(arg["page"].(float64))
blockIDs, total, pageCount := model.GetFlashcards(deckID, page)
blocks, total, pageCount := model.GetFlashcards(deckID, page)
ret.Data = map[string]interface{}{
"blocks": blockIDs,
"blocks": blocks,
"total": total,
"pageCount": pageCount,
}
@ -75,9 +75,10 @@ func reviewRiffCard(c *gin.Context) {
}
deckID := arg["deckID"].(string)
cardID := arg["cardID"].(string)
blockID := arg["blockID"].(string)
rating := int(arg["rating"].(float64))
err := model.ReviewFlashcard(deckID, blockID, riff.Rating(rating))
err := model.ReviewFlashcard(deckID, cardID, blockID, riff.Rating(rating))
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@ -125,6 +126,7 @@ func getRiffDueCards(c *gin.Context) {
ret.Data = cards
}
// TODO 删除闪卡
func removeRiffCards(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View File

@ -30,7 +30,7 @@ require (
github.com/gin-gonic/gin v1.9.0
github.com/goccy/go-json v0.10.0
github.com/gofrs/flock v0.8.1
github.com/imroc/req/v3 v3.32.1
github.com/imroc/req/v3 v3.32.3
github.com/jinzhu/copier v0.3.5
github.com/json-iterator/go v1.1.12
github.com/mattn/go-sqlite3 v2.0.3+incompatible
@ -45,9 +45,9 @@ require (
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
github.com/siyuan-note/filelock v0.0.0-20230223100551-200cbe1cf84e
github.com/siyuan-note/httpclient v0.0.0-20230223101139-409ed0b4c5ff
github.com/siyuan-note/httpclient v0.0.0-20230224113038-40f0e2672f0f
github.com/siyuan-note/logging v0.0.0-20230223101545-ec2cbf198ffb
github.com/siyuan-note/riff v0.0.0-20230224070227-4514ccc3e496
github.com/siyuan-note/riff v0.0.0-20230224074237-c16f59420520
github.com/steambap/captcha v1.4.1
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2
github.com/vmihailenco/msgpack/v5 v5.3.5
@ -128,7 +128,7 @@ require (
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.2.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect
golang.org/x/exp v0.0.0-20230223210539-50820d90acfd // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect

View File

@ -164,8 +164,8 @@ github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/imroc/req/v3 v3.32.1 h1:OBP1QjDRqjEh64XrJ8NmP4kyTHWrqqG/TOqp0JLehsA=
github.com/imroc/req/v3 v3.32.1/go.mod h1:cZ+7C3L/AYOr4tLGG16hZF90F1WzAdAdzt1xFSlizXY=
github.com/imroc/req/v3 v3.32.3 h1:FX3xCN0iWn1wJKHN0EB8l7EjXDTE4j/C8m7zeAb2UH0=
github.com/imroc/req/v3 v3.32.3/go.mod h1:cZ+7C3L/AYOr4tLGG16hZF90F1WzAdAdzt1xFSlizXY=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
@ -282,12 +282,12 @@ github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b h1:828lTUW2C0
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
github.com/siyuan-note/filelock v0.0.0-20230223100551-200cbe1cf84e h1:SjId8gvjrN/dWa/I+FrRFQtNR3QoU1Vkm/DP0Oos6Rw=
github.com/siyuan-note/filelock v0.0.0-20230223100551-200cbe1cf84e/go.mod h1:9uEHHzT1PNXHKTP1PPIB+Q353kMK4RPHPnqjzPEGCUI=
github.com/siyuan-note/httpclient v0.0.0-20230223101139-409ed0b4c5ff h1:3G48J/tGUDmKhEh/x+0rU6i8Y2dULKBCe9q4bht5NGw=
github.com/siyuan-note/httpclient v0.0.0-20230223101139-409ed0b4c5ff/go.mod h1:/fjYEiYPN2ZNR2zVTopobwzo3rOychV2qbsutxiV0jI=
github.com/siyuan-note/httpclient v0.0.0-20230224113038-40f0e2672f0f h1:PQQ7PHLOVB1fKxlN5QEKqUAb0lF3itEalDTMWEXy2jE=
github.com/siyuan-note/httpclient v0.0.0-20230224113038-40f0e2672f0f/go.mod h1:WQZwbUczOhXdxhd0Z+oEdIPp6KuQ3gzR0LkDlEepanU=
github.com/siyuan-note/logging v0.0.0-20230223101545-ec2cbf198ffb h1:qzz7ZQw7/tHJd1IST+8UymXFF8RacokMLD7VZgyS+ww=
github.com/siyuan-note/logging v0.0.0-20230223101545-ec2cbf198ffb/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
github.com/siyuan-note/riff v0.0.0-20230224070227-4514ccc3e496 h1:6u9vlE4EhRja4abccUPGNmG+aMBm/D+5lVomkoYuSmo=
github.com/siyuan-note/riff v0.0.0-20230224070227-4514ccc3e496/go.mod h1:XJtLlKCr8cZE+lzykM4edHHih92M9M50UNw/nDLYRN8=
github.com/siyuan-note/riff v0.0.0-20230224074237-c16f59420520 h1:14vDSmi+YYBCnPb41ESSaq8kzgx6Sj4fE1mNJQwVObw=
github.com/siyuan-note/riff v0.0.0-20230224074237-c16f59420520/go.mod h1:XJtLlKCr8cZE+lzykM4edHHih92M9M50UNw/nDLYRN8=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY=
@ -351,8 +351,8 @@ golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20230223210539-50820d90acfd h1:wtFuj4DoOcAdb82Zh2PI90xiaqgp7maYA7KxjQXVtkY=
golang.org/x/exp v0.0.0-20230223210539-50820d90acfd/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20190823064033-3a9bac650e44/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=

View File

@ -158,7 +158,7 @@ func GetFlashcards(deckID string, page int) (blocks []*Block, total, pageCount i
// reviewCardCache <cardID, card> 用于复习时缓存卡片,以便支持撤销。
var reviewCardCache = map[string]riff.Card{}
func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err error) {
func ReviewFlashcard(deckID, cardID, blockID string, rating riff.Rating) (err error) {
deckLock.Lock()
defer deckLock.Unlock()
@ -168,9 +168,9 @@ func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err err
}
deck := Decks[deckID]
card := deck.GetCard(blockID)
card := deck.GetCard(cardID)
if nil == card {
logging.LogErrorf("card not found [%s]", blockID)
logging.LogErrorf("card not found [%s]", cardID)
return
}
@ -467,7 +467,12 @@ func removeFlashcard(blockIDs []string, deck *riff.Deck) {
}
for _, blockID := range blockIDs {
deck.RemoveCard(blockID)
// TODO 这里的代码需要重构,要支持一个块对应多张卡
cardID := deck.BlockCard[blockID]
if "" == cardID {
continue
}
deck.RemoveCard(cardID)
}
err := deck.Save()