Closed Rosouly closed 7 months ago
问题已解决:
1.传入参数中:elapsedDays,scheduledDays和lastReview key值不对,应该是对应的elapsed_days,scheduled_days,last_review。算法需要根据last_review和当前时间now进行比较时间差的。 2.new Date(formatDate(FirstCard.value.due)) 这些格式转换没有必要,内部会完成string->Date,number->Date的转换 3.let scheduling_cards = f.repeat(FirstCard.value, formatDate(now)); 不需要使用formatDate(now),直接用上面定义的now就可以了
我在使用ts-fsrs的过程中遇到了invalid date的报错,我试过修改时间的格式,但依旧未能解决这个问题
具体报错如下: ts-fsrs.js?v=a1e981b4:895 Uncaught (in promise) Error: Invalid date at x (ts-fsrs.js?v=a1e981b4:895:11) at Date.diff (ts-fsrs.js?v=a1e981b4:884:10) at new D (ts-fsrs.js?v=a1e981b4:975:132) at P.repeat (ts-fsrs.js?v=a1e981b4:1075:15) at Proxy.getReviewLog (review_mode.vue:110:28)
代码: import { createEmptyCard, formatDate, generatorParameters, fsrs, Rating, Grades } from "ts-fsrs";
async function getReviewLog(key) { const now = new Date() FirstCard.value.due = new Date(formatDate(FirstCard.value.due)) FirstCard.value.lastReview = new Date(formatDate(FirstCard.value.lastReview)) console.log(FirstCard.value) let scheduling_cards = f.repeat(FirstCard.value, formatDate(now)); let card = scheduling_cards[key].card let log = scheduling_cards[key].log
传入的参数是:FirstCard.value: { "cid": 12, "nid": 12, "due": "2024-04-01 21:45:32", "stability": 0.5701, "difficulty": 7.5455, "elapsedDays": 0, "scheduledDays": 0, "reps": 1, "lapses": 0, "state": 1, "lastReview": "2024-03-31 17:37:26", "videoId": "AtChcxeaukQ", "sid": 35 }