diff --git a/README.en.md b/README.en.md index 49d6ab89..cde53afe 100644 --- a/README.en.md +++ b/README.en.md @@ -183,7 +183,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. The owner can rename the notebook and manage members; an administrator owner can also delete it. Read-only members can view, print and export questions but cannot modify them or run bulk operations. All members can create exam papers from the shared notebook, answer questions in the due-review queue and record their own practice; statistics filtered by a shared notebook cover only that notebook and label its owner, while practice and weak-tag evidence are counted for the current account. If two people edit the same question, a stale version gets a conflict response and can be saved after reloading. Sharing relationships are exported with the owner's backup from format version 27 and rebuilt by member email on import; members whose email is not present on the target instance are skipped. +- **👥 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. The owner can rename the notebook and manage members; notebooks and questions can only be deleted by the owner or an administrator, while edit members can modify but not delete shared questions. Read-only members can view, print and export questions but cannot modify them or run bulk operations. All members can create exam papers from the shared notebook, answer questions in the due-review queue and record their own practice; statistics filtered by a shared notebook cover only that notebook and label its owner, while practice and weak-tag evidence are counted for the current account. If two people edit the same question, a stale version gets a conflict response and can be saved after reloading. Sharing relationships are exported with the owner's backup from format version 27 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. The result count updates live, the page size can be switched, and a direct page jump appears when there are many pages. Saved filter views can be saved, applied in one tap and deleted (stored in this browser, shared by notebook, and holding only filters, not page numbers). Returning from a question's details restores the page, filters and scroll position automatically. On mobile, advanced filters sit in a drawer, and entering a `#sequence number` or 6-character ID in the search box and pressing Enter opens that question. - **📊 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**. @@ -197,7 +197,7 @@ Practice statistics show total practice, accuracy (correct / attempted) and acti - **📈 Anonymous telemetry and administrator agreement**: the administrator accepts the [agreement](doc/EULA.en.md) during initialization (on fnOS, in the installer wizard). The instance then sends a batch of anonymous usage statistics and error fingerprints to the Wrong Notebook collection service about every 6 hours, without user or instance identifiers, IP addresses, question content, AI conversations or error messages. Instances upgraded from older versions do not forward by default; administrators see a banner where they can review the agreement and turn it on. Under "Settings → User Management → Privacy & telemetry" an administrator can turn forwarding off, enable local recording (kept on this server for troubleshooting), point to a self-hosted collection service and see what the instance collected; `TELEMETRY_DISABLED=true` forces everything off. When the agreement changes, administrators must accept again and forwarding pauses meanwhile; ordinary users are not affected. See [Privacy](doc/PRIVACY.en.md) and the [design](doc/TELEMETRY_DESIGN.md). - **🐞 Debug logs**: when something goes wrong, an admin turns on debug mode under "Settings → User Management", reproduces the problem, then exports the debug log (JSON) and sends it to the author. Debug mode records every server log, including `debug` level, plus frontend errors; API keys, passwords and tokens are removed on export. The log lives in memory only, debug mode turns off after 24 hours, and a restart clears it. - **🔌 Openclaw integration**: an external Openclaw agent can upload question images in bulk via `POST /api/openclaw/batch-upload`; see [Environment variables](#-environment-variables). -- **🧩 MCP server**: external agents can list notebooks and questions, query knowledge tags and due reviews, create notebooks and questions with figures, create exam papers, record exam results and read mastery distributions and weak points through the MCP Streamable HTTP endpoint `POST /api/mcp`. AI work can also be delegated: question recognition, reanswering, retagging, figure redraw, LaTeX repair, SVG animations, GeoGebra analysis and multi-question splitting; long calls return a background task id and can be polled. Set `MCP_API_KEY` and `MCP_USER_EMAIL` to enable it; tools and client setup are in [MCP Server](doc/wiki/en/MCP-Server-en.md). +- **🧩 MCP server**: external agents can list notebooks and questions, query knowledge tags and due reviews, create notebooks and questions with figures, create exam papers, record exam results and read mastery distributions and weak points through the MCP Streamable HTTP endpoint `POST /api/mcp`. AI work can also be delegated: question recognition, reanswering, retagging, figure redraw, LaTeX repair, SVG animations, GeoGebra analysis and multi-question splitting; long calls return a background task id and can be polled. Set `MCP_API_KEY` and `MCP_USER_EMAIL` to enable it; optional `MCP_ALLOWED_EMAILS` lets one key switch between whitelisted accounts per tool call. Tools and client setup are in [MCP Server](doc/wiki/en/MCP-Server-en.md). ## 🚀 Quick Start @@ -597,7 +597,8 @@ The most common variables are below; see the collapsed table and [`.env.example` | Variable | Description | Default | Notes | | :--- | :--- | :--- | :--- | | `MCP_API_KEY` | MCP integration key | None | External agents send it as `Authorization: Bearer` or `x-api-key`. Generate with `openssl rand -hex 32` | -| `MCP_USER_EMAIL` | MCP target account | None | Fixes the notebook data to this account; use an email (a username also works), and the account must be enabled | +| `MCP_USER_EMAIL` | MCP default target account | None | Fixes the default account's notebook data; use an email (a username also works), and the account must be enabled | +| `MCP_ALLOWED_EMAILS` | MCP optional account whitelist | None | Comma-separated emails; with it set, tools can pass `account` to switch accounts; empty means default only | When adding environment variables, update `.env.example` as well. diff --git a/README.md b/README.md index 530b34ce..77d4405f 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ ### 管理与统计 -- **👥 错题本共享**:错题本所有者可按账号邮箱邀请其他用户成为成员,并选择「只读」或「可编辑」。成员在错题本首页接受邀请后,该错题本及其中的题目会出现在自己的列表中,按角色读取或修改;成员新增的题目归属该错题本,所有成员按角色可见。所有者可随时调整成员角色或移除成员,成员也可主动退出共享。所有者能改名和管理成员,管理员所有者能删除错题本;只读成员可查看题目、打印和导出,但不能修改题目或执行批量操作。成员都可从共享错题本组卷、在今日复习中作答并记录自己的练习;统计中心按共享错题本筛选时只统计该错题本并标注所有者,练习与薄弱知识点按当前账号的作答记录计算。两人同时修改同一题时,过期版本返回冲突,重新加载后可保存。共享关系从备份第 27 版起随所有者数据备份导出,导入时按成员邮箱重建;本机不存在该邮箱的成员会跳过。 +- **👥 错题本共享**:错题本所有者可按账号邮箱邀请其他用户成为成员,并选择「只读」或「可编辑」。成员在错题本首页接受邀请后,该错题本及其中的题目会出现在自己的列表中,按角色读取或修改;成员新增的题目归属该错题本,所有成员按角色可见。所有者可随时调整成员角色或移除成员,成员也可主动退出共享。所有者能改名和管理成员;错题本与题目仅所有者或管理员可删除,可编辑成员能修改但不能删除共享题目。只读成员可查看题目、打印和导出,但不能修改题目或执行批量操作。成员都可从共享错题本组卷、在今日复习中作答并记录自己的练习;统计中心按共享错题本筛选时只统计该错题本并标注所有者,练习与薄弱知识点按当前账号的作答记录计算。两人同时修改同一题时,过期版本返回冲突,重新加载后可保存。共享关系从备份第 27 版起随所有者数据备份导出,导入时按成员邮箱重建;本机不存在该邮箱的成员会跳过。 - **🔍 多维度筛选**:按掌握状态、时间范围、知识点、题型、年级学期、试卷等级等条件筛选,支持批量操作和两题相似度比较;选中的错题可批量修改来源、年级学期和知识点标签,移动到其他错题本(标签保持不变),也可导出为 JSON、Excel 或 Word(Excel 列与题库导入模板一致,可往返导入;Word 默认嵌入题目自带配图,拍照原图需另行勾选);「全选筛选结果」可跨页选中上千道题,超过 100 道时按批提交并显示进度,失败项可重试。筛选结果实时计数,可切换每页条数,页码多时直接跳页;常用筛选视图可保存、一键应用和删除(保存在本机浏览器,同一错题本共享,只记筛选条件不记页码);进入错题详情再返回时自动恢复页码、筛选和滚动位置;移动端把高级筛选收进抽屉,搜索框输入 `#流水号` 或 6 位 ID 回车可直接定位题目。 - **📊 数据统计**:错题与练习的掌握率、趋势和学科分布,支持时间范围与学科筛选。错题列表支持用地址参数预设掌握状态(`?mastery=new|reviewing|mastered`)和知识点标签(`?tag=标签名`)筛选。 - **⏳ 后台任务**:页面右下角的按钮可查看识别、AI 生成、动画语音生成、批量标注、组卷等耗时事务的进度;离开页面后事务仍在服务器上继续。拍照识别的结果另在「识别任务」中持久保存。 @@ -230,7 +230,7 @@ - **📈 匿名遥测与使用协议**:管理员在初始化时同意[使用协议](doc/EULA.md)(飞牛OS 在安装向导中勾选),实例默认每 6 小时向错题本收集服务发送一批匿名的功能使用统计和错误指纹,不含用户或实例标识、IP、题目内容、AI 对话或错误原文;存量实例升级后默认不外发,管理员登录时可从提示横幅查看协议后开启。「设置 → 用户管理 → 隐私与遥测」可关闭外发、开启本地记录(只保存在本机,供排查问题)、改为自建收集服务,并查看本实例收集了什么;设置 `TELEMETRY_DISABLED=true` 强制全部关闭。协议升级后管理员需重新同意,期间暂停外发,普通用户不受影响。详见[隐私说明](doc/PRIVACY.md)与[设计](doc/TELEMETRY_DESIGN.md)。 - **🐞 调试日志**:遇到问题时,管理员在「设置 → 用户管理」中打开调试模式,复现问题后导出调试日志(JSON)发给作者。调试模式下记录包括 debug 级别在内的全部服务端日志和前端错误,导出时自动去除 API Key、密码和令牌;日志只保存在内存中,24 小时后自动关闭,服务重启后清空。 - **🔌 Openclaw 集成**:外部 Openclaw agent 可通过 `POST /api/openclaw/batch-upload` 批量上传题目图片,配置见[环境变量](#-环境变量)。 -- **🧩 MCP 服务**:外部 agent 可通过 MCP Streamable HTTP 端点 `POST /api/mcp` 查询错题本、错题、知识点和今日待复习题,创建错题本和带配图的错题,按条件组卷、录入试卷结果并读取掌握分布与薄弱知识点;AI 能力也可交给 Agent:题目识别、重新解题、重新标注知识点、重绘配图、修复 LaTeX、生成 SVG 动画与 GeoGebra 演示、多题分题,长任务返回后台任务编号并可轮询结果。配置 `MCP_API_KEY` 与 `MCP_USER_EMAIL` 后启用,工具与接入方式见 [MCP 服务](doc/wiki/MCP-Server.md)。 +- **🧩 MCP 服务**:外部 agent 可通过 MCP Streamable HTTP 端点 `POST /api/mcp` 查询错题本、错题、知识点和今日待复习题,创建错题本和带配图的错题,按条件组卷、录入试卷结果并读取掌握分布与薄弱知识点;AI 能力也可交给 Agent:题目识别、重新解题、重新标注知识点、重绘配图、修复 LaTeX、生成 SVG 动画与 GeoGebra 演示、多题分题,长任务返回后台任务编号并可轮询结果。配置 `MCP_API_KEY` 与 `MCP_USER_EMAIL` 后启用;可选 `MCP_ALLOWED_EMAILS` 让同一密钥按工具参数切换白名单账号,工具与接入方式见 [MCP 服务](doc/wiki/MCP-Server.md)。 ## 🚀 快速开始 @@ -628,7 +628,8 @@ GeoGebra 的文字、不等式和标签参数按共用命令清单校验,重 | 环境变量 | 描述 | 默认值 | 说明 | | :--- | :--- | :--- | :--- | | `MCP_API_KEY` | MCP 集成密钥 | 无 | 外部 agent 通过 `Authorization: Bearer` 或 `x-api-key` 提交;可用 `openssl rand -hex 32` 生成 | -| `MCP_USER_EMAIL` | MCP 目标账号 | 无 | 固定该账号的错题数据;填邮箱(也可填用户名),账号须启用 | +| `MCP_USER_EMAIL` | MCP 默认目标账号 | 无 | 固定默认账号的错题数据;填邮箱(也可填用户名),账号须启用 | +| `MCP_ALLOWED_EMAILS` | MCP 可选账号白名单 | 无 | 逗号分隔邮箱;配置后工具可传 `account` 切换账号,留空只用默认账号 | 新增环境变量时需同步更新 `.env.example`。 diff --git a/src/__tests__/integration/notebook-sharing.test.ts b/src/__tests__/integration/notebook-sharing.test.ts index f07bccf4..7c499293 100644 --- a/src/__tests__/integration/notebook-sharing.test.ts +++ b/src/__tests__/integration/notebook-sharing.test.ts @@ -33,6 +33,7 @@ import { GET as LIST_SHARES, POST as INVITE, PATCH as UPDATE_ROLE, DELETE as REM import { GET as LIST_INVITATIONS, POST as RESPOND_INVITATION } from '@/app/api/notebooks/invitations/route'; import { GET as LIST_ITEMS } from '@/app/api/error-items/list/route'; import { GET as GET_ITEM, PUT as UPDATE_ITEM } from '@/app/api/error-items/[id]/route'; +import { DELETE as DELETE_ITEM } from '@/app/api/error-items/[id]/delete/route'; import { POST as BATCH_DELETE } from '@/app/api/error-items/batch-delete/route'; import { POST as CREATE_EXAM } from '@/app/api/exams/route'; import { GET as REVIEW_DUE } from '@/app/api/review/due/route'; @@ -54,6 +55,9 @@ let carol: { id: string; email: string }; const signInAs = (user: { id: string; email: string }) => { mocks.session = { user: { id: user.id, email: user.email, role: 'user' }, expires: '2099-01-01' }; }; +const signInAsAdmin = (user: { id: string; email: string }) => { + mocks.session = { user: { id: user.id, email: user.email, role: 'admin' }, expires: '2099-01-01' }; +}; const json = (body: unknown) => ({ method: 'POST', body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } }); const params = (id: string) => ({ params: Promise.resolve({ id }) }); @@ -479,4 +483,36 @@ describe('错题本共享', () => { select: { masteryLevel: true, masteryProbability: true, masteryReason: true, masterySource: true }, })).toMatchObject({ masteryLevel: 2, masteryProbability: 1, masteryReason: '已掌握', masterySource: 'rule' }); }); + + it('共享 edit 成员可编辑但不可删除,所有者与管理员可删除', async () => { + const { notebook, item } = await seedNotebook(alice.id); + signInAs(alice); + const invited = await (await INVITE(new Request(`http://localhost/api/notebooks/${notebook.id}/shares`, json({ email: bob.email, role: 'edit' })), params(notebook.id))).json(); + signInAs(bob); + await RESPOND_INVITATION(new Request('http://localhost/api/notebooks/invitations', json({ shareId: invited.id, action: 'accept' }))); + + // edit 成员可写,但单题与批量删除均只删自己的题:共享题被拒绝 + expect((await UPDATE_ITEM(new Request(`http://localhost/api/error-items/${item.id}`, json({ questionText: '成员编辑' })), params(item.id))).status).toBe(200); + expect((await DELETE_ITEM(new Request(`http://localhost/api/error-items/${item.id}`), params(item.id))).status).toBe(403); + const batch = await (await BATCH_DELETE(new Request('http://localhost/api/error-items/batch-delete', json({ ids: [item.id] })))).json(); + expect(batch).toMatchObject({ deleted: 0, failed: [item.id] }); + + signInAs(alice); + expect((await DELETE_ITEM(new Request(`http://localhost/api/error-items/${item.id}`), params(item.id))).status).toBe(200); + + // 管理员可删除其他用户的错题、错题本与批量选中项 + const { notebook: adminNotebook, item: adminItem } = await seedNotebook(alice.id, '管理员测试本'); + await database.user.update({ where: { id: carol.id }, data: { role: 'admin' } }); + signInAsAdmin(carol); + expect((await DELETE_ITEM(new Request(`http://localhost/api/error-items/${adminItem.id}`), params(adminItem.id))).status).toBe(200); + const emptyNotebook = await database.subject.create({ + data: { userId: alice.id, name: '空本', stage: 'junior_high', subjectKey: 'math' }, + }); + expect((await DELETE_NOTEBOOK(new Request(`http://localhost/api/notebooks/${emptyNotebook.id}`), params(emptyNotebook.id))).status).toBe(200); + const adminBatchItem = await database.errorItem.create({ + data: { userId: alice.id, subjectId: adminNotebook.id, questionText: '批量删除题', shortId: 'del6', originalImageUrl: 'data:image/png;base64,AA==' }, + }); + const adminBatch = await (await BATCH_DELETE(new Request('http://localhost/api/error-items/batch-delete', json({ ids: [adminBatchItem.id] })))).json(); + expect(adminBatch).toMatchObject({ deleted: 1, failed: [] }); + }); }); diff --git a/src/app/api/error-items/[id]/delete/route.ts b/src/app/api/error-items/[id]/delete/route.ts index e7da76f7..7b65d2b3 100644 --- a/src/app/api/error-items/[id]/delete/route.ts +++ b/src/app/api/error-items/[id]/delete/route.ts @@ -4,7 +4,8 @@ import { forbidden, notFound, internalError } from "@/lib/api-errors"; import { withUser } from "@/lib/api-handler"; import type { AuthenticatedContext } from "@/lib/api-handler"; import { createLogger } from "@/lib/logger"; -import { canWriteNotebook, errorItemAccessSelect, resolveErrorItemRole } from "@/lib/notebook-access"; +import { errorItemAccessSelect, resolveErrorItemRole } from "@/lib/notebook-access"; +import { isAdmin } from "@/lib/auth-utils"; const logger = createLogger('api:error-items:delete'); @@ -24,8 +25,9 @@ export const DELETE = withUser(async (_req: Request, { user, params }: RouteCont return notFound("Item not found"); } - if (!canWriteNotebook(resolveErrorItemRole(user.id, errorItem))) { - return forbidden("Not authorized to delete this item"); + // 删除仅所有者或管理员:edit 共享成员可编辑,但不能删除共享错题 + if (!isAdmin(user) && resolveErrorItemRole(user.id, errorItem) !== "owner") { + return forbidden("Only the owner or an administrator can delete this item"); } // Delete the item diff --git a/src/app/api/error-items/batch-delete/route.ts b/src/app/api/error-items/batch-delete/route.ts index 041893f4..47fe2098 100644 --- a/src/app/api/error-items/batch-delete/route.ts +++ b/src/app/api/error-items/batch-delete/route.ts @@ -7,6 +7,7 @@ import { createLogger } from "@/lib/logger"; import { batchDeleteSchema } from "@/lib/schemas/error-items"; import { buildBatchResults } from "@/lib/error-list/batch-operation"; import { getNotebookAccessSets, writableErrorItemWhere } from "@/lib/notebook-access"; +import { isAdmin } from "@/lib/auth-utils"; const logger = createLogger('api:error-items:batch-delete'); @@ -27,10 +28,13 @@ export const POST = withUser(async (req: Request, { user }: AuthenticatedContext logger.debug({ userId: user.id, idsCount: ids.length }, 'Batch delete request'); - // 查询可写的错题:自有的,或位于自有/edit 共享错题本中的 - const access = await getNotebookAccessSets(user.id); + // 删除仅所有者或管理员:edit 共享成员可编辑,但不能删除共享错题 + const admin = isAdmin(user); + const access = admin ? null : await getNotebookAccessSets(user.id); const itemsToDelete = await prisma.errorItem.findMany({ - where: { id: { in: ids }, ...writableErrorItemWhere(user.id, access.writeIds) }, + where: admin + ? { id: { in: ids } } + : { id: { in: ids }, ...writableErrorItemWhere(user.id, access!.ownedIds) }, select: { id: true }, }); const ownedIds = itemsToDelete.map(item => item.id); diff --git a/src/app/api/notebooks/[id]/route.ts b/src/app/api/notebooks/[id]/route.ts index 2de87236..9c8afb09 100644 --- a/src/app/api/notebooks/[id]/route.ts +++ b/src/app/api/notebooks/[id]/route.ts @@ -6,6 +6,7 @@ import { forbidden, notFound, badRequest, internalError } from "@/lib/api-errors import { updateNotebookSchema } from "@/lib/schemas/notebooks"; import { createLogger } from "@/lib/logger"; import { isNotebookShareRole } from "@/lib/notebook-access"; +import { isAdmin } from "@/lib/auth-utils"; const logger = createLogger('api:notebooks:id'); @@ -166,8 +167,8 @@ async function handleDelete( return notFound("Notebook not found"); } - if (notebook.userId !== user.id) { - return forbidden("Not authorized to delete this notebook"); + if (notebook.userId !== user.id && !isAdmin(user)) { + return forbidden("Only the owner or an administrator can delete this notebook"); } // 检查是否有错题 @@ -177,7 +178,7 @@ async function handleDelete( // 非空校验与删除放进同一条件写操作:并发写入的错题不会被数据库级联静默清空 const deleted = await prisma.subject.deleteMany({ - where: { id, userId: user.id, errorItems: { none: {} } }, + where: { id, ...(isAdmin(user) ? {} : { userId: user.id }), errorItems: { none: {} } }, }); if (deleted.count === 0) { // 校验后有人写入错题或被并发删除:重新查询区分 404/403/400 @@ -188,8 +189,8 @@ async function handleDelete( if (!current) { return notFound("Notebook not found"); } - if (current.userId !== user.id) { - return forbidden("Not authorized to delete this notebook"); + if (current.userId !== user.id && !isAdmin(user)) { + return forbidden("Only the owner or an administrator can delete this notebook"); } return badRequest("Cannot delete notebook with error items. Please move or delete all items first."); } diff --git a/src/app/error-items/[id]/page.tsx b/src/app/error-items/[id]/page.tsx index fa5ccec9..117d01f0 100644 --- a/src/app/error-items/[id]/page.tsx +++ b/src/app/error-items/[id]/page.tsx @@ -250,7 +250,7 @@ export default function ErrorDetailPage() { {masteryStatus && } - {!readOnly && isAdmin && ( + {!readOnly && (isAdmin || item.role === "owner") && ( - {isOwner && isAdmin && ( + {(isOwner || isAdmin) && ( - + {canDelete && ( + + )} {/* 手机端只保留高频图标操作,导出/移动/批量编辑收进「更多」,避免多行悬浮栏遮住列表 */} @@ -154,17 +159,19 @@ export function ErrorListSelectionBar({ > - + {canDelete && ( + + )} diff --git a/src/components/error-list.tsx b/src/components/error-list.tsx index 47f0c201..8aa0e98a 100644 --- a/src/components/error-list.tsx +++ b/src/components/error-list.tsx @@ -11,6 +11,8 @@ interface ErrorListProps { tagSet?: string; /** 只读共享错题本:隐藏多选与批量操作入口 */ readOnly?: boolean; + /** 仅所有者或管理员可批量删除 */ + canDelete?: boolean; } /** 从地址参数读取初始筛选(?mastery=new|reviewing|mastered / ?tag=标签名),仅首次进入时生效 */ diff --git a/src/components/error-list/error-list-content.tsx b/src/components/error-list/error-list-content.tsx index a318c333..bb37b6ce 100644 --- a/src/components/error-list/error-list-content.tsx +++ b/src/components/error-list/error-list-content.tsx @@ -47,6 +47,8 @@ interface ErrorListContentProps { tagSet?: string; /** 只读共享错题本:隐藏多选与批量操作入口 */ readOnly?: boolean; + /** 仅所有者或管理员可批量删除 */ + canDelete?: boolean; /** 首次进入时的初始筛选(由外层从 URL 解析后传入),之后改筛选不回写 */ initialMastery?: MasteryStatus; initialTag?: string; @@ -62,7 +64,7 @@ function toUiQuestionTypes(values: ErrorListFilters["questionTypes"]): string[] return values.map((value) => value === "none" ? NO_QUESTION_TYPE : value); } -export function ErrorListContent({ subjectId, subjectName, tagSet = 'default', readOnly = false, initialMastery, initialTag }: ErrorListContentProps) { +export function ErrorListContent({ subjectId, subjectName, tagSet = 'default', readOnly = false, canDelete = true, initialMastery, initialTag }: ErrorListContentProps) { const { t } = useLanguage(); const router = useRouter(); const pathname = usePathname() || (subjectId ? `/notebooks/${subjectId}` : "/notebooks"); @@ -559,6 +561,7 @@ export function ErrorListContent({ subjectId, subjectName, tagSet = 'default', r selectedIds={[...selectedIds]} deleting={deleteRunner.state.running} onCancel={toggleSelectMode} + canDelete={canDelete} onDelete={handleBatchDelete} onMoved={handleBatchMoved} onEdited={handleBatchEdited}