Skip to content

Commit dedadf3

Browse files
committed
fix(feynman): convertedCount 复制粘贴 bug——新增 converted 字段区分已转闪卡与已掌握
1 parent a529084 commit dedadf3

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎client/src/features/feynman/pages/FeynmanSessionPage.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export default function FeynmanSessionPage() {
9090
}, [isCompleted]);
9191

9292
const masteredCount = noteWeakPoints.filter((wp) => wp.mastered).length;
93-
const convertedCount = noteWeakPoints.filter((wp) => wp.mastered).length;
93+
// v0.36 修复:原实现与 masteredCount 同谓词恒等(复制粘贴 bug),
94+
// 已转换薄弱点按 converted 字段统计(见 types/feynman.ts FeynmanWeakPoint.converted)
95+
const convertedCount = noteWeakPoints.filter((wp) => wp.converted).length;
9496

9597
if (isLoading) {
9698
return <FeynmanLoadingSkeleton />;

‎client/src/features/feynman/store/feynmanStepSlice.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export const createStepSlice: FeynmanSlice<StepSlice> = (set, get) => ({
212212
const wp = toConvert.find((w) => w.id === wpId);
213213
if (!wp) continue;
214214
try {
215-
await updateWithLog(feynmanWeakPointStore, 'feynmanWeakPoints', wpId, { ...wp, mastered: true });
215+
await updateWithLog(feynmanWeakPointStore, 'feynmanWeakPoints', wpId, { ...wp, mastered: true, converted: true });
216216
} catch {
217217
// 标记失败可接受:下次转换最多重复建该张卡
218218
}
@@ -224,7 +224,7 @@ export const createStepSlice: FeynmanSlice<StepSlice> = (set, get) => ({
224224
weakPoints: {
225225
...state.weakPoints,
226226
[noteId]: (state.weakPoints[noteId] ?? []).map((w) =>
227-
createdWpIds.includes(w.id!) ? { ...w, mastered: true } : w,
227+
createdWpIds.includes(w.id!) ? { ...w, mastered: true, converted: true } : w,
228228
),
229229
},
230230
}));
@@ -234,7 +234,7 @@ export const createStepSlice: FeynmanSlice<StepSlice> = (set, get) => ({
234234
// 全部创建成功:统一标记已掌握(逐条容错,失败汇总提示)
235235
const failedMarks: string[] = [];
236236
for (const wp of toConvert) {
237-
const updated = { ...wp, mastered: true };
237+
const updated = { ...wp, mastered: true, converted: true };
238238
try {
239239
await updateWithLog(feynmanWeakPointStore, 'feynmanWeakPoints', wp.id!, updated);
240240
} catch {
@@ -250,7 +250,7 @@ export const createStepSlice: FeynmanSlice<StepSlice> = (set, get) => ({
250250
weakPoints: {
251251
...state.weakPoints,
252252
[noteId]: (state.weakPoints[noteId] ?? []).map((w) =>
253-
weakPointIds.includes(w.id!) ? { ...w, mastered: true } : w,
253+
weakPointIds.includes(w.id!) ? { ...w, mastered: true, converted: true } : w,
254254
),
255255
},
256256
}));

‎client/src/types/feynman.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export interface FeynmanWeakPoint {
3838
text: string;
3939
position: { start: number; end: number };
4040
mastered: boolean;
41+
/** 是否已转为闪卡(v0.36+)。converted 与 mastered 语义分离:
42+
* mastered 可被用户手动标记或转换时自动标记,converted 仅由
43+
* convertWeakPointsToFlashcards 置位。旧数据无此字段,视为未转换。 */
44+
converted?: boolean;
4145
createdAt: Date;
4246
}
4347

0 commit comments

Comments
 (0)