From 9c4094ab5ac28b9c4f55fbfdda3fbcd5a60e0a6f Mon Sep 17 00:00:00 2001 From: margrop <1731827+margrop@users.noreply.github.com> Date: Thu, 3 Dec 2026 15:15:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=B1=E4=BA=AB=E9=94=99=E9=A2=98?= =?UTF-8?q?=E6=9C=AC=E9=9A=8F=E5=A4=87=E4=BB=BD=E5=AF=BC=E5=87=BA=E4=B8=8E?= =?UTF-8?q?=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 备份版本升至 27,导出共享成员邮箱、角色与状态 - 个人备份包含自有错题本中成员录入的题目 - 导入按成员邮箱重建共享关系,已存在时更新角色,缺失成员跳过 - 补充共享备份往返、缺员与旧版兼容集成测试,同步文档 Refs: https://github.com/margrop/wrong-notebook/issues/73 --- README.en.md | 2 +- README.md | 2 +- doc/wiki/User-Guide.md | 2 +- doc/wiki/en/User-Guide-en.md | 2 +- src/__tests__/integration/data-backup.test.ts | 81 ++++++++++++++++++- src/app/api/export/route.ts | 35 +++++++- src/lib/backup/format.ts | 35 +++++++- src/lib/backup/import-parser.ts | 2 + src/lib/backup/import-writer/index.ts | 2 + .../backup/import-writer/notebook-shares.ts | 70 ++++++++++++++++ src/lib/backup/import-writer/types.ts | 6 ++ 11 files changed, 229 insertions(+), 10 deletions(-) create mode 100644 src/lib/backup/import-writer/notebook-shares.ts diff --git a/README.en.md b/README.en.md index e179e57b..1aa78ee3 100644 --- a/README.en.md +++ b/README.en.md @@ -182,7 +182,7 @@ Practice statistics show total practice, accuracy (correct / attempted) and acti ### Management and statistics -- **👥 Notebook sharing**: a notebook owner can invite other accounts by email as members, choosing **Read-only** or **Can edit**. After a member accepts the invitation on the notebook home page, the notebook and its questions appear in that member's list, readable or editable by role; questions the member adds belong to the notebook and are visible to all members by role. The owner can change roles or remove members at any time, and members can leave sharing themselves. Only the owner can rename or delete the notebook and manage members; read-only members can view, print and export questions but cannot modify them or run bulk operations. +- **👥 Notebook sharing**: a notebook owner can invite other accounts by email as members, choosing **Read-only** or **Can edit**. After a member accepts the invitation on the notebook home page, the notebook and its questions appear in that member's list, readable or editable by role; questions the member adds belong to the notebook and are visible to all members by role. The owner can change roles or remove members at any time, and members can leave sharing themselves. Only the owner can rename or delete the notebook and manage members; read-only members can view, print and export questions but cannot modify them or run bulk operations. Sharing relationships are exported with the owner's backup and rebuilt by member email on import; members whose email is not present on the target instance are skipped. - **🔍 Filters**: filter by mastery, date range, knowledge point, question type, grade and term, paper level and more; supports bulk actions and comparing the similarity of two questions. Selected questions can have their source, grade/term and knowledge tags edited in bulk, be moved to another notebook (tags stay unchanged), or exported as JSON, Excel or Word (the Excel columns match the question bank import template, so the file can be re-imported directly; Word embeds the question's own figures by default, with the original photo as a separate option); **Select all filtered results** selects up to 2,000 items across pages, and operations above 100 items submit in batches with progress and retry for failed items. - **📊 Statistics**: mastery rate, trends and subject distribution for both mistakes and practice, with time-range and subject filters. - **⏳ Background tasks**: the button at the bottom right shows the progress of long-running jobs such as recognition, AI generation, animation voice, bulk tagging and exam generation. Jobs keep running on the server after you leave the page. Photo recognition results are also kept in **Recognition**. diff --git a/README.md b/README.md index 176d8076..752e790e 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ ### 管理与统计 -- **👥 错题本共享**:错题本所有者可按账号邮箱邀请其他用户成为成员,并选择「只读」或「可编辑」。成员在错题本首页接受邀请后,该错题本及其中的题目会出现在自己的列表中,按角色读取或修改;成员新增的题目归属该错题本,所有成员按角色可见。所有者可随时调整成员角色或移除成员,成员也可主动退出共享。只有所有者能改名、删除错题本和管理成员;只读成员可查看题目、打印和导出,但不能修改题目或执行批量操作。 +- **👥 错题本共享**:错题本所有者可按账号邮箱邀请其他用户成为成员,并选择「只读」或「可编辑」。成员在错题本首页接受邀请后,该错题本及其中的题目会出现在自己的列表中,按角色读取或修改;成员新增的题目归属该错题本,所有成员按角色可见。所有者可随时调整成员角色或移除成员,成员也可主动退出共享。只有所有者能改名、删除错题本和管理成员;只读成员可查看题目、打印和导出,但不能修改题目或执行批量操作。共享关系随所有者数据备份导出,导入时按成员邮箱重建;本机不存在该邮箱的成员会跳过。 - **🔍 多维度筛选**:按掌握状态、时间范围、知识点、题型、年级学期、试卷等级等条件筛选,支持批量操作和两题相似度比较;选中的错题可批量修改来源、年级学期和知识点标签,移动到其他错题本(标签保持不变),也可导出为 JSON、Excel 或 Word(Excel 列与题库导入模板一致,可往返导入;Word 默认嵌入题目自带配图,拍照原图需另行勾选);「全选筛选结果」可跨页选中上千道题,超过 100 道时按批提交并显示进度,失败项可重试。 - **📊 数据统计**:错题与练习的掌握率、趋势和学科分布,支持时间范围与学科筛选。错题列表支持用地址参数预设掌握状态(`?mastery=new|reviewing|mastered`)和知识点标签(`?tag=标签名`)筛选。 - **⏳ 后台任务**:页面右下角的按钮可查看识别、AI 生成、动画语音生成、批量标注、组卷等耗时事务的进度;离开页面后事务仍在服务器上继续。拍照识别的结果另在「识别任务」中持久保存。 diff --git a/doc/wiki/User-Guide.md b/doc/wiki/User-Guide.md index 81d1ca98..5a2b5263 100644 --- a/doc/wiki/User-Guide.md +++ b/doc/wiki/User-Guide.md @@ -16,7 +16,7 @@ 错题本所有者可在详情页的「共享成员」卡片中按账号邮箱邀请其他用户,选择「只读」或「可编辑」权限。被邀请者在错题本首页的「共享邀请」中接受后,该错题本与其中的题目会出现在自己的列表中,并按角色读写;拒绝则邀请消失。所有者可随时调整成员权限或移除成员,成员也可在详情页退出共享。成员新增的题目归属该错题本,所有成员按角色可见。 -只有所有者能重命名、删除错题本和管理成员;可编辑成员可新增、修改、删除题目、批量操作和重新标注知识点;只读成员可查看、打印和导出,但不能修改题目。共享关系不随数据备份导出,导入备份只还原错题本的所有者。 +只有所有者能重命名、删除错题本和管理成员;可编辑成员可新增、修改、删除题目、批量操作和重新标注知识点;只读成员可查看、打印和导出,但不能修改题目。共享关系随所有者数据备份导出(记录成员邮箱与角色),导入时按邮箱重建;同一错题本与成员已存在时按备份更新角色,本机不存在该邮箱的成员会跳过。成员退出共享只删除关系,题目保留;所有者删除错题本会连带删除其中的题目。 ## 录入题目 diff --git a/doc/wiki/en/User-Guide-en.md b/doc/wiki/en/User-Guide-en.md index e1834ad6..4ca47b8d 100644 --- a/doc/wiki/en/User-Guide-en.md +++ b/doc/wiki/en/User-Guide-en.md @@ -16,7 +16,7 @@ The notebook list shows only each name and question count; click one to open its A notebook owner can invite other accounts by email from the **Shared members** card on the detail page, choosing **Read-only** or **Can edit**. Once the invitee accepts under **Sharing invitations** on the notebook home page, the notebook and its questions appear in their list and are readable or editable by role; declining removes the invitation. The owner can change a member's role or remove the member at any time, and a member can leave sharing from the detail page. Questions a member adds belong to the notebook and are visible to all members by role. -Only the owner can rename or delete the notebook and manage members. Members with edit rights can add, modify and delete questions, run bulk actions and retag knowledge points; read-only members can view, print and export questions but cannot modify them. Sharing relationships are not included in data backups, so importing a backup restores only the notebook owner. +Only the owner can rename or delete the notebook and manage members. Members with edit rights can add, modify and delete questions, run bulk actions and retag knowledge points; read-only members can view, print and export questions but cannot modify them. Sharing relationships are exported with the owner's backup (member email and role) and rebuilt by email on import; an existing notebook-member pair has its role updated from the backup, while members whose email is absent on the target instance are skipped. A member leaving sharing removes only the relationship and keeps the questions; the owner deleting a notebook also deletes its questions. ## Add questions diff --git a/src/__tests__/integration/data-backup.test.ts b/src/__tests__/integration/data-backup.test.ts index 28ffe4a7..50dcf460 100644 --- a/src/__tests__/integration/data-backup.test.ts +++ b/src/__tests__/integration/data-backup.test.ts @@ -69,6 +69,7 @@ async function clearUserData() { await database.bankQuestion.deleteMany(); await database.questionBank.deleteMany(); await database.errorItem.deleteMany({ where: { userId: 'user-1' } }); + await database.notebookShare.deleteMany(); await database.subject.deleteMany({ where: { userId: 'user-1' } }); await database.knowledgeTag.deleteMany({ where: { userId: 'user-1' } }); await database.knowledgeTag.deleteMany({ where: { isSystem: true } }); @@ -257,9 +258,10 @@ describe('数据导出后再导入(真实 SQLite)', () => { spy.mockRestore(); }); - it('导出文件使用第 26 版格式,包含 tagSet、小问、练习生成题、试卷配图、题库来源、自定义题型与空的 extensions', async () => { + it('导出文件使用第 27 版格式,包含 tagSet、小问、练习生成题、试卷配图、题库来源、自定义题型、空共享关系与空的 extensions', async () => { const backup = await exportBackup(); - expect(backup.version).toBe(26); + expect(backup.version).toBe(27); + expect(backup.notebookShares).toEqual([]); expect(backup.errorItems.find((item: { id: string }) => item.id === 'item-1')?.subQuestions) .toBe(JSON.stringify([ { index: 1, stem: '求 x 的值', answer: 'x = 3' }, @@ -1043,7 +1045,7 @@ describe('数据导出后再导入(真实 SQLite)', () => { expect(response.status).toBe(200); const compressed = Buffer.from(await response.arrayBuffer()); expect([compressed[0], compressed[1]]).toEqual([0x1f, 0x8b]); - expect(JSON.parse(gunzipSync(compressed).toString('utf8')).version).toBe(26); + expect(JSON.parse(gunzipSync(compressed).toString('utf8')).version).toBe(27); await clearUserData(); const imported = await IMPORT(new Request('http://localhost/api/import', { @@ -1072,6 +1074,79 @@ describe('数据导出后再导入(真实 SQLite)', () => { }); }); +describe('共享错题本备份', () => { + it('共享成员、角色与成员录入的题目随所有者备份往返,导入按邮箱重建', async () => { + const member = await database.user.create({ + data: { id: 'member-1', email: 'member@example.com', password: 'test-only', name: '成员' }, + }); + await database.notebookShare.create({ + data: { subjectId: 'math', memberId: member.id, invitedById: 'user-1', role: 'edit', status: 'active' }, + }); + await database.errorItem.create({ + data: { + id: 'member-item', userId: member.id, subjectId: 'math', originalImageUrl: '', + questionText: '成员录入的题目', answerText: '答案', analysis: '解析', + }, + }); + + const backup = await exportBackup(); + expect(backup.notebookShares).toContainEqual(expect.objectContaining({ + subjectId: 'math', memberEmail: 'member@example.com', memberName: '成员', role: 'edit', status: 'active', + })); + // 成员录入的题仍归属错题本,须随所有者备份导出 + expect(backup.errorItems.map((item: { id: string }) => item.id)).toContain('member-item'); + + await clearUserData(); + const { stats } = await importBackup(backup); + expect(stats).toMatchObject({ notebookSharesCreated: 1, notebookSharesSkipped: 0 }); + + const subject = await database.subject.findFirstOrThrow({ where: { userId: 'user-1', name: '数学' } }); + expect(await database.notebookShare.findFirstOrThrow({ where: { subjectId: subject.id } })).toMatchObject({ + memberId: member.id, role: 'edit', status: 'active', invitedById: 'user-1', + }); + expect(await database.errorItem.findFirstOrThrow({ where: { questionText: '成员录入的题目' } })).toMatchObject({ + userId: 'user-1', subjectId: subject.id, + }); + + // 重复导入按备份更新角色/状态,不新增关系 + const again = await importBackup(backup); + expect(again.stats.notebookSharesCreated).toBe(0); + expect(await database.notebookShare.count()).toBe(1); + }); + + it('备份中的成员邮箱在本机不存在时跳过共享关系,题目仍导入', async () => { + const member = await database.user.create({ + data: { id: 'member-1', email: 'member@example.com', password: 'test-only' }, + }); + await database.notebookShare.create({ + data: { subjectId: 'math', memberId: member.id, invitedById: 'user-1', role: 'read', status: 'active' }, + }); + await database.errorItem.create({ + data: { id: 'member-item', userId: member.id, subjectId: 'math', originalImageUrl: '', questionText: '成员录入的题目' }, + }); + const backup = await exportBackup(); + await database.user.delete({ where: { id: member.id } }); + + await clearUserData(); + const { stats } = await importBackup(backup); + expect(stats.notebookSharesSkipped).toBe(1); + expect(await database.notebookShare.count()).toBe(0); + expect(await database.errorItem.count({ where: { questionText: '成员录入的题目' } })).toBe(1); + }); + + it('旧版备份没有共享字段时正常导入', async () => { + const backup = await exportBackup(); + const legacy = structuredClone(backup) as Record & { version: number }; + delete legacy.notebookShares; + legacy.version = 26; + + await clearUserData(); + const { stats } = await importBackup(legacy); + expect(stats.notebookSharesCreated).toBe(0); + expect(await database.notebookShare.count()).toBe(0); + }); +}); + describe('跨账号合并导入', () => { const originalSession = { user: { id: 'user-1', email: 'backup-test@example.com', role: 'user' }, expires: '2099-01-01' }; diff --git a/src/app/api/export/route.ts b/src/app/api/export/route.ts index 81e42dc4..3b80fae6 100644 --- a/src/app/api/export/route.ts +++ b/src/app/api/export/route.ts @@ -27,7 +27,7 @@ const EXPORT_ERROR_ITEM_BATCH_SIZE = 200; type ExportErrorItemRow = Prisma.ErrorItemGetPayload<{ include: { tags: true } }>; /** 按 id 游标分批读取错题及标签,顺序稳定且不依赖 OFFSET */ -async function fetchExportErrorItems(where: { userId?: string }): Promise { +async function fetchExportErrorItems(where: Prisma.ErrorItemWhereInput): Promise { const rows: ExportErrorItemRow[] = []; let cursor: string | undefined; for (;;) { @@ -63,6 +63,21 @@ export const GET = withUser(async (req: Request, { user, session }: Authenticate where: userFilter, }); + // 共享关系随所有者备份导出:记录成员邮箱与角色,导入时按邮箱重建(version 27) + const notebookShares = await prisma.notebookShare.findMany({ + where: exportAll ? {} : { subject: { userId: user.id } }, + select: { + id: true, + subjectId: true, + role: true, + status: true, + createdAt: true, + updatedAt: true, + member: { select: { email: true, name: true } }, + invitedBy: { select: { email: true } }, + }, + }); + // 系统标签按 tagSet 分组导出,避免不同体系的系统标签混淆 const systemTags = await prisma.knowledgeTag.findMany({ where: { @@ -76,7 +91,11 @@ export const GET = withUser(async (req: Request, { user, session }: Authenticate }, }); - const errorItems = await fetchExportErrorItems(userFilter); + // 个人备份包含自有错题本中的全部题目(成员录入的题 userId 不同,仍归属该错题本) + const errorItemWhere: Prisma.ErrorItemWhereInput = exportAll + ? {} + : { OR: [{ userId: user.id }, { subject: { userId: user.id } }] }; + const errorItems = await fetchExportErrorItems(errorItemWhere); const reviewSchedules = await prisma.reviewSchedule.findMany({ where: exportAll @@ -152,6 +171,17 @@ export const GET = withUser(async (req: Request, { user, session }: Authenticate mobileNavFourth: user.mobileNavFourth, }, subjects, + notebookShares: notebookShares.map((share) => ({ + id: share.id, + subjectId: share.subjectId, + memberEmail: share.member.email, + memberName: share.member.name, + invitedByEmail: share.invitedBy.email, + role: share.role, + status: share.status, + createdAt: share.createdAt, + updatedAt: share.updatedAt, + })), systemTags: sortTagsByParent(systemTags), customTags: sortTagsByParent(customTags), errorItems: errorItems.map((item) => ({ @@ -186,6 +216,7 @@ export const GET = withUser(async (req: Request, { user, session }: Authenticate userId: user.id, scope: exportAll ? 'all' : 'user', subjectsCount: subjects.length, + notebookSharesCount: notebookShares.length, systemTagsCount: systemTags.length, customTagsCount: customTags.length, errorItemsCount: errorItems.length, diff --git a/src/lib/backup/format.ts b/src/lib/backup/format.ts index 90b86659..520649eb 100644 --- a/src/lib/backup/format.ts +++ b/src/lib/backup/format.ts @@ -23,7 +23,7 @@ import { */ /** 当前备份文件版本号 */ -export const BACKUP_VERSION = 26; +export const BACKUP_VERSION = 27; /** 备份文件中的用户对象 */ export interface BackupUser { @@ -61,6 +61,21 @@ export interface BackupSubject { updatedAt: string | Date; } +/** 错题本共享关系(version 27 起导出;按成员邮箱重建,避免跨实例用户 ID 不一致) */ +export interface BackupNotebookShare { + id: string; + subjectId: string; + memberEmail: string; + memberName?: string | null; + invitedByEmail?: string | null; + /** read 只读 | edit 可编辑 */ + role: string; + /** invited 待接受 | active 已生效 */ + status: string; + createdAt: string | Date; + updatedAt: string | Date; +} + /** 备份文件中的系统标签(version 3 起导出) */ export interface BackupSystemTag { id: string; @@ -342,6 +357,8 @@ export interface BackupFile { scope: string; user: BackupUser; subjects: BackupSubject[]; + /** 错题本共享关系(version 27 起导出) */ + notebookShares?: BackupNotebookShare[]; systemTags: BackupSystemTag[]; customTags: BackupCustomTag[]; errorItems: BackupErrorItem[]; @@ -374,6 +391,12 @@ export type ImportedBackupSubject = Omit & { + createdAt: ImportedDate; + updatedAt: ImportedDate; +}; + /** 导入侧的系统标签 */ export type ImportedBackupSystemTag = Omit & { createdAt: ImportedDate; @@ -453,6 +476,8 @@ export interface ImportableBackupFile { scope?: string; user: BackupUser; subjects?: ImportedBackupSubject[]; + /** 旧版导出文件没有 */ + notebookShares?: ImportedBackupNotebookShare[]; systemTags?: ImportedBackupSystemTag[]; customTags?: ImportedBackupCustomTag[]; errorItems: ImportedBackupErrorItem[]; @@ -476,6 +501,13 @@ const backupTagSchema = backupIdObjectSchema.extend({ name: z.string().max(500).optional(), subject: z.string().max(100).optional(), }); +const backupNotebookShareSchema = backupIdObjectSchema.extend({ + subjectId: z.string().min(1).max(200), + memberEmail: z.string().min(1).max(320), + invitedByEmail: z.string().max(320).optional(), + role: z.string().max(20).optional(), + status: z.string().max(20).optional(), +}); const backupExamPaperSchema = backupIdObjectSchema.extend({ questions: z.array(z.unknown()).max(MAX_BACKUP_EXAM_QUESTIONS).optional(), }); @@ -492,6 +524,7 @@ const backupFileSchema = z.object({ user: z.record(z.string(), z.unknown()), errorItems: z.array(backupIdObjectSchema).max(MAX_BACKUP_ERROR_ITEMS), subjects: z.array(backupIdObjectSchema).max(MAX_BACKUP_TAGS).optional(), + notebookShares: z.array(backupNotebookShareSchema).max(MAX_BACKUP_TAGS).optional(), systemTags: z.array(backupTagSchema).max(MAX_BACKUP_TAGS).optional(), customTags: z.array(backupTagSchema).max(MAX_BACKUP_TAGS).optional(), reviewSchedules: z.array(z.record(z.string(), z.unknown())).max(MAX_BACKUP_REVIEW_SCHEDULES).optional(), diff --git a/src/lib/backup/import-parser.ts b/src/lib/backup/import-parser.ts index c001ac79..e1604b96 100644 --- a/src/lib/backup/import-parser.ts +++ b/src/lib/backup/import-parser.ts @@ -155,6 +155,7 @@ export interface NormalizedImportData { preferences: Prisma.UserUpdateInput; hasPreferences: boolean; subjects: NonNullable; + notebookShares: NonNullable; systemTags: NonNullable; customTags: NonNullable; errorItems: NormalizedErrorItem[]; @@ -263,6 +264,7 @@ export function normalizeBackupForImport(body: ImportData, belongsToCurrentUser: preferences, hasPreferences: Object.keys(preferences).length > 0, subjects: body.subjects ?? [], + notebookShares: body.notebookShares ?? [], systemTags: body.systemTags ?? [], customTags: body.customTags ?? [], errorItems: body.errorItems.map(normalizeErrorItem), diff --git a/src/lib/backup/import-writer/index.ts b/src/lib/backup/import-writer/index.ts index c2640b9e..e40e3efc 100644 --- a/src/lib/backup/import-writer/index.ts +++ b/src/lib/backup/import-writer/index.ts @@ -6,6 +6,7 @@ import { scheduleMasteryEvaluation } from "@/lib/mastery"; import { createImportContext } from "./types"; import type { ImportWriterOptions, ImportWriterResult } from "./types"; import { importPreferences, importSubjects } from "./subjects"; +import { importNotebookShares } from "./notebook-shares"; import { importCustomQuestionTypes } from "./custom-question-types"; import { importSystemTags, importCustomTags, preloadErrorItemTags } from "./tags"; import { importQuestionBanks } from "./banks"; @@ -25,6 +26,7 @@ export async function importBackupData(options: ImportWriterOptions): Promise { + const { tx, normalized, stats, subjectIdMap } = ctx; + + for (const share of normalized.notebookShares) { + const subjectId = subjectIdMap.get(share.subjectId); + if (!subjectId) { + stats.notebookSharesSkipped++; + continue; + } + + const subject = await tx.subject.findUnique({ + where: { id: subjectId }, + select: { userId: true }, + }); + if (!subject) { + stats.notebookSharesSkipped++; + continue; + } + + const member = await tx.user.findUnique({ + where: { email: share.memberEmail }, + select: { id: true }, + }); + if (!member || member.id === subject.userId) { + stats.notebookSharesSkipped++; + continue; + } + + // 邀请人缺失或与成员相同时,以错题本所有者兜底 + let invitedById = subject.userId; + if (share.invitedByEmail) { + const inviter = await tx.user.findUnique({ + where: { email: share.invitedByEmail }, + select: { id: true }, + }); + if (inviter && inviter.id !== member.id) invitedById = inviter.id; + } + + // 新字段总有角色与状态;异常值按最小权限只读、已生效处理 + const role = isNotebookShareRole(share.role) ? share.role : "read"; + const status = isNotebookShareStatus(share.status) ? share.status : "active"; + + const existing = await tx.notebookShare.findUnique({ + where: { subjectId_memberId: { subjectId, memberId: member.id } }, + select: { id: true, role: true, status: true }, + }); + if (existing) { + if (existing.role !== role || existing.status !== status) { + await tx.notebookShare.update({ + where: { id: existing.id }, + data: { role, status, invitedById }, + }); + stats.notebookSharesUpdated++; + } + continue; + } + + await tx.notebookShare.create({ + data: { subjectId, memberId: member.id, invitedById, role, status }, + }); + stats.notebookSharesCreated++; + } +} diff --git a/src/lib/backup/import-writer/types.ts b/src/lib/backup/import-writer/types.ts index 3d476326..6f2d4196 100644 --- a/src/lib/backup/import-writer/types.ts +++ b/src/lib/backup/import-writer/types.ts @@ -7,6 +7,9 @@ import type { NormalizedImportData } from "@/lib/backup/import-parser"; /** 导入统计,随响应返回 */ export interface ImportStats { subjectsCreated: number; + notebookSharesCreated: number; + notebookSharesUpdated: number; + notebookSharesSkipped: number; tagsCreated: number; errorItemsCreated: number; reviewSchedulesCreated: number; @@ -83,6 +86,9 @@ export function createImportContext({ tx, user, importAll, normalized }: ImportW normalized, stats: { subjectsCreated: 0, + notebookSharesCreated: 0, + notebookSharesUpdated: 0, + notebookSharesSkipped: 0, tagsCreated: 0, errorItemsCreated: 0, reviewSchedulesCreated: 0,