From ab38db08d2f87ddf8a785a4e16a83e747e0bb260 Mon Sep 17 00:00:00 2001 From: margrop <1731827+margrop@users.noreply.github.com> Date: Fri, 4 Dec 2026 23:47:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=AB=AF=E5=BC=B9=E7=AA=97=E9=AB=98=E5=BA=A6=E4=B8=8E=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E6=82=AC=E6=B5=AE=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DialogContent 默认限制 90vh/90dvh 并滚动,避免手机端弹窗溢出视口 - 多选悬浮栏在 sm 以下收敛为单行图标操作,导出/移动/批量编辑收进「更多」 - 相似度对比弹窗新增 compact 图标触发按钮,补充 375×667 E2E 断言 --- e2e/mobile-controls.spec.ts | 46 ++++++++++ src/app/globals.css | 12 +++ src/components/error-list-selection-bar.tsx | 87 +++++++++++++++++-- src/components/question-similarity-dialog.tsx | 17 +++- src/components/ui/dialog.tsx | 4 +- 5 files changed, 154 insertions(+), 12 deletions(-) diff --git a/e2e/mobile-controls.spec.ts b/e2e/mobile-controls.spec.ts index bada6690..2ee82726 100644 --- a/e2e/mobile-controls.spec.ts +++ b/e2e/mobile-controls.spec.ts @@ -23,6 +23,52 @@ test.describe('手机端基础控件', () => { await expect(page.getByRole('tab', { name: '导入题库文件' })).toBeVisible(); }); + test('[E2E-M12] 手机端多选栏保持单行且弹窗不超出视口', async ({ page, scenario }) => { + test.setTimeout(90000); + const first = await scenario.item('A'); + const second = await scenario.item('B'); + await scenario.login(page); + await page.goto(`/notebooks/${scenario.book.id}`); + await expect(page.getByText(first.questionText!, { exact: false })).toBeVisible({ timeout: 15000 }); + + await page.getByRole('button', { name: '更多', exact: true }).first().click(); + await page.getByRole('menuitem', { name: '多选', exact: true }).click(); + for (const item of [first, second]) { + await page.locator('a', { hasText: item.questionText! }).locator('..').getByRole('checkbox').click(); + } + + const bar = page.getByTestId('error-list-selection-bar'); + await expect(bar.getByText('已选 2 项')).toBeVisible(); + const barBox = await bar.boundingBox(); + expect(barBox).not.toBeNull(); + // 375×667 下悬浮栏收敛为单行图标操作,不再折成三行遮住列表 + expect(barBox!.height).toBeLessThan(120); + const visibleButtons = bar.getByRole('button'); + for (const button of await visibleButtons.all()) { + const box = await button.boundingBox(); + if (!box) continue; + expect(box.x).toBeGreaterThanOrEqual(0); + expect(box.x + box.width).toBeLessThanOrEqual(375 + 1); + } + + // 次要操作收进「更多」,批量编辑弹窗可完整滚动且不越出视口 + await bar.getByRole('button', { name: '更多', exact: true }).click(); + await expect(page.getByRole('menuitem', { name: '导出 JSON' })).toBeVisible(); + await expect(page.getByRole('menuitem', { name: '移动到错题本' })).toBeVisible(); + await expect(page.getByRole('menuitem', { name: '批量编辑' })).toBeVisible(); + await page.getByRole('menuitem', { name: '批量编辑' }).click(); + + const dialog = page.getByRole('dialog').filter({ has: page.getByRole('heading', { name: '批量编辑 2 道错题' }) }); + await expect(dialog).toBeVisible(); + const dialogBox = await dialog.boundingBox(); + expect(dialogBox).not.toBeNull(); + expect(dialogBox!.y).toBeGreaterThanOrEqual(0); + expect(dialogBox!.y + dialogBox!.height).toBeLessThanOrEqual(667 + 1); + expect(dialogBox!.height).toBeLessThanOrEqual(667 * 0.9 + 1); + await dialog.getByRole('button', { name: '保存修改', exact: true }).scrollIntoViewIfNeeded(); + await expect(dialog.getByRole('button', { name: '保存修改', exact: true })).toBeVisible(); + }); + test('[E2E-M11] 子页面页头在手机端返回按钮与标题同行', async ({ page, scenario }) => { test.setTimeout(90000); await scenario.login(page); diff --git a/src/app/globals.css b/src/app/globals.css index b5fef355..50415ab4 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -141,6 +141,18 @@ @apply bg-background text-foreground; -webkit-tap-highlight-color: transparent; } + + /* 弹窗默认限制在可视高度内并可滚动;优先动态视口,旧内核回退静态视口 */ + .dialog-viewport-limit { + max-height: 90vh; + overflow-y: auto; + } + + @supports (height: 90dvh) { + .dialog-viewport-limit { + max-height: 90dvh; + } + } } /* 移动端底部导航与系统安全区之间的留白 */ diff --git a/src/components/error-list-selection-bar.tsx b/src/components/error-list-selection-bar.tsx index a004e324..c33e5dd4 100644 --- a/src/components/error-list-selection-bar.tsx +++ b/src/components/error-list-selection-bar.tsx @@ -1,12 +1,13 @@ "use client"; import { useState } from "react"; -import { ArrowRightLeft, FileJson, ListChecks, PencilLine, Trash2, X } from "lucide-react"; +import { ArrowRightLeft, FileJson, ListChecks, MoreHorizontal, PencilLine, Trash2, X } from "lucide-react"; import { Button } from "@/components/ui/button"; import { BatchEditDialog } from "@/components/error-list/batch-edit-dialog"; import { BatchProgress } from "@/components/error-list/batch-progress"; import { ExportQuestionsDialog } from "@/components/error-list/export-questions-dialog"; import { MoveToNotebookDialog } from "@/components/error-list/move-to-notebook-dialog"; +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { QuestionSimilarityDialog } from "@/components/question-similarity-dialog"; import { useLanguage } from "@/contexts/LanguageContext"; import type { BatchRunnerState } from "@/lib/hooks/use-batch-runner"; @@ -46,13 +47,13 @@ export function ErrorListSelectionBar({ const [editDialogOpen, setEditDialogOpen] = useState(false); return ( -
{t.notebook.selectedCount.replace("{count}", String(selectedIds.length))}
-{t.questionSimilarity.selectTwo}
+{t.questionSimilarity.selectTwo}