From 596c585bdbd54617b4ce400fb2e4c7383152d0ed Mon Sep 17 00:00:00 2001 From: margrop <1731827+margrop@users.noreply.github.com> Date: Fri, 4 Dec 2026 22:03:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=8B=E6=9C=BA=E7=AB=AF=E6=A0=A1?= =?UTF-8?q?=E5=AF=B9=E4=BF=9D=E5=AD=98=E6=A0=8F=E4=B8=8E=E9=94=99=E9=A2=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B7=A5=E5=85=B7=E6=A0=8F=E6=94=B6=E6=95=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 校对页顶部栏允许换行,手机端增加底部固定保存栏 - 错题列表搜索框增加一键清空,手机端次要操作收进「更多」菜单 - 移动端筛选抽屉增加「清除筛选」 - 补充列表与校对页 E2E Refs: https://github.com/margrop/wrong-notebook/issues/108 --- e2e/error-list-ux.spec.ts | 20 +++ e2e/upload-correction.spec.ts | 12 +- src/components/correction-editor.tsx | 15 +- .../error-list/error-list-content.tsx | 1 + .../error-list/error-list-toolbar.tsx | 140 +++++++++++++----- .../error-list/mobile-filter-sheet.tsx | 8 +- src/lib/i18n/en.ts | 2 + src/lib/i18n/zh.ts | 2 + 8 files changed, 155 insertions(+), 45 deletions(-) diff --git a/e2e/error-list-ux.spec.ts b/e2e/error-list-ux.spec.ts index 28a1196e..38f1a2c3 100644 --- a/e2e/error-list-ux.spec.ts +++ b/e2e/error-list-ux.spec.ts @@ -83,9 +83,29 @@ test('错题列表跳页、位置恢复与常用筛选视图', async ({ page, sc await expect(page.getByText(`${marker} 题目 18`)).toBeVisible(); await expect(page.getByText('2 / 6')).toBeVisible(); + // 手机端工具栏只保留搜索、筛选与更多;桌面次要操作隐藏 + await expect(page.getByRole('button', { name: '常用筛选' })).toBeHidden(); + await expect(page.getByRole('button', { name: /打印/ })).toBeHidden(); + + // 搜索框提供一键清空,清空后提交并恢复全量 + await search.fill(`${marker} 题目 1`); + await page.getByRole('button', { name: '清空搜索' }).click(); + await expect(search).toHaveValue(''); + await expect(page.getByText(`共 ${ITEM_COUNT} 道错题`).last()).toBeVisible({ timeout: 15000 }); + + await page.getByRole('button', { name: '更多' }).click(); + await expect(page.getByRole('menuitem', { name: /打印/ })).toBeVisible(); + await expect(page.getByRole('menuitem', { name: '多选' })).toBeVisible(); + await page.keyboard.press('Escape'); + await page.getByRole('button', { name: '筛选条件' }).click(); const mobileSheet = page.getByRole('dialog'); await expect(mobileSheet.getByRole('heading', { name: '筛选条件' })).toBeVisible(); + await mobileSheet.getByRole('button', { name: '清除筛选' }).click(); + await expect(mobileSheet).not.toBeVisible(); + await expect(page.getByText(`共 ${ITEM_COUNT} 道错题`).last()).toBeVisible({ timeout: 15000 }); + await page.getByRole('button', { name: '筛选条件' }).click(); + await expect(mobileSheet).toBeVisible(); await mobileSheet.getByRole('button', { name: '查看结果' }).click(); await expect(mobileSheet).not.toBeVisible(); }); diff --git a/e2e/upload-correction.spec.ts b/e2e/upload-correction.spec.ts index 2918ebdc..640ebb39 100644 --- a/e2e/upload-correction.spec.ts +++ b/e2e/upload-correction.spec.ts @@ -6,7 +6,17 @@ test('没有卷别分组时也能首次校对保存,随后刷新并删除', as // 只有管理员账号在错题与错题本详情页保留删除入口 await scenario.db.user.update({ where: { id: scenario.user.id }, data: { role: 'admin' } }); await scenario.db.paperGroup.deleteMany({ where: { userId: scenario.user.id } }); - const item = await importImage(page, scenario, true); + const item = await importImage(page, scenario, true, async (correctionPage) => { + // 桌面顶部保存栏;手机端底部固定保存栏 + const mobileSaveBar = correctionPage.getByTestId('correction-mobile-save-bar'); + await expect(mobileSaveBar).toBeHidden(); + await correctionPage.setViewportSize({ width: 390, height: 844 }); + await expect(mobileSaveBar).toBeVisible(); + await expect(mobileSaveBar.getByRole('button', { name: /保存|Save/ })).toBeVisible(); + await expect(mobileSaveBar.getByRole('button', { name: /取消|Cancel/ })).toBeVisible(); + await correctionPage.setViewportSize({ width: 1280, height: 900 }); + await expect(mobileSaveBar).toBeHidden(); + }); const group = await scenario.db.paperGroup.findUniqueOrThrow({ where: { userId_key: { userId: scenario.user.id, key: 'a' } } }); expect(item.paperLevel).toBe(group.id); await expect(page.getByText('校对后的方程', { exact: false })).toBeVisible(); diff --git a/src/components/correction-editor.tsx b/src/components/correction-editor.tsx index cb2b1322..63deffbe 100644 --- a/src/components/correction-editor.tsx +++ b/src/components/correction-editor.tsx @@ -166,8 +166,8 @@ export function CorrectionEditor({ initialData, onSave, onCancel, imagePreview, const tagSubject = inferSubjectFromName(notebooks.find(n => n.id === data.subjectId)?.name || null) || inferSubjectFromName(data.subject || null) || undefined; return ( -
-
+
+

{t.editor.title}

+ + {/* 手机端底部固定保存栏,避免长表单滚动后还要回到顶部保存 */} +
+ + +
); } diff --git a/src/components/error-list/error-list-content.tsx b/src/components/error-list/error-list-content.tsx index 14590901..2d049c4b 100644 --- a/src/components/error-list/error-list-content.tsx +++ b/src/components/error-list/error-list-content.tsx @@ -445,6 +445,7 @@ export function ErrorListContent({ subjectId, subjectName, tagSet = 'default', r onKnowledgeChange={handleFilterChange} onPaperLevelChange={setPaperLevelFilter} onQuestionTypesChange={setQuestionTypesFilter} + onClearFilters={clearFilters} /> {selectedTag && ( diff --git a/src/components/error-list/error-list-toolbar.tsx b/src/components/error-list/error-list-toolbar.tsx index e04252b4..211a2ca6 100644 --- a/src/components/error-list/error-list-toolbar.tsx +++ b/src/components/error-list/error-list-toolbar.tsx @@ -1,10 +1,11 @@ "use client"; -import { GitCompareArrows, ListChecks, Printer, Search, SlidersHorizontal } from "lucide-react"; +import { GitCompareArrows, ListChecks, MoreHorizontal, Printer, Search, SlidersHorizontal, X } from "lucide-react"; import { FilterMenu } from "@/components/error-list/filter-menu"; import { SavedFilterViewsMenu } from "@/components/error-list/saved-filter-views-menu"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { useLanguage } from "@/contexts/LanguageContext"; import { PAGE_SIZE_OPTIONS } from "@/lib/constants/pagination"; @@ -64,56 +65,113 @@ export function ErrorListToolbar({ onSearchChange(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") onSearchSubmit(search.trim()); }} /> + {search && ( + + )}
-
- - - + {!readOnly && !selectMode && ( + + )} + {!readOnly && ( + + )} +
+ {t.notebook.pageSize} + +
+
+ - - {!readOnly && !selectMode && ( - - )} - {!readOnly && ( - - )} -
- {t.notebook.pageSize} - -
+ + + + + + + + {t.notebook.exportPrint} + + {!readOnly && !selectMode && ( + + + {t.questionSimilarity.title} + + )} + {!readOnly && ( + + + {selectMode ? t.notebook.cancelSelect : t.notebook.selectMode} + + )} + + {t.notebook.pageSize} +
+ +
+
+
); diff --git a/src/components/error-list/mobile-filter-sheet.tsx b/src/components/error-list/mobile-filter-sheet.tsx index 7581f1f5..dbab0083 100644 --- a/src/components/error-list/mobile-filter-sheet.tsx +++ b/src/components/error-list/mobile-filter-sheet.tsx @@ -19,6 +19,8 @@ interface MobileFilterSheetProps { onKnowledgeChange: (change: KnowledgeFilterChange) => void; onPaperLevelChange: (value: PaperLevel) => void; onQuestionTypesChange: (value: string[]) => void; + /** 清除全部筛选并关闭抽屉 */ + onClearFilters: () => void; } /** 移动端筛选抽屉:把桌面内联的高级筛选收进对话框,避免窄屏长表单挤占列表 */ @@ -34,6 +36,7 @@ export function MobileFilterSheet({ onKnowledgeChange, onPaperLevelChange, onQuestionTypesChange, + onClearFilters, }: MobileFilterSheetProps) { const { t } = useLanguage(); return ( @@ -53,7 +56,10 @@ export function MobileFilterSheet({ onPaperLevelChange={onPaperLevelChange} onQuestionTypesChange={onQuestionTypesChange} /> - + + diff --git a/src/lib/i18n/en.ts b/src/lib/i18n/en.ts index 873dce0f..f4a60d58 100644 --- a/src/lib/i18n/en.ts +++ b/src/lib/i18n/en.ts @@ -450,6 +450,8 @@ export const en = { subtitle: "Review and master your past mistakes.", addNew: "Add New Wrong Answer", search: "Search questions or tags...", + clearSearch: "Clear search", + moreActions: "More", filter: "Filter", filtersTitle: "Filter conditions", applyFilters: "Show results", diff --git a/src/lib/i18n/zh.ts b/src/lib/i18n/zh.ts index b4948194..1edbee49 100644 --- a/src/lib/i18n/zh.ts +++ b/src/lib/i18n/zh.ts @@ -450,6 +450,8 @@ export const zh = { subtitle: "温故知新,查漏补缺。", addNew: "添加错题", search: "搜索题目或知识点...", + clearSearch: "清空搜索", + moreActions: "更多", filter: "筛选", filtersTitle: "筛选条件", applyFilters: "查看结果",