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}

-
+
+ + {/* 手机端只保留高频图标操作,导出/移动/批量编辑收进「更多」,避免多行悬浮栏遮住列表 */} +
+ + + + + + + + setExportDialogOpen(true)} + disabled={selectedIds.length === 0 || deleting} + > + + {t.notebook.exportJson} + + setMoveDialogOpen(true)} + disabled={selectedIds.length === 0 || deleting} + > + + {t.notebook.moveToNotebook} + + setEditDialogOpen(true)} + disabled={selectedIds.length === 0 || deleting} + > + + {t.notebook.batchEdit} + + + + + +
-
+
(null); @@ -50,9 +52,16 @@ export function QuestionSimilarityDialog({ ids }: QuestionSimilarityDialogProps) return ( { setOpen(value); if (value) refresh(); }}> - diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index cc4c0294..942b3ad4 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -44,7 +44,7 @@ const DialogContent = React.forwardRef< // 用 inset-0 + m-auto 居中,不依赖 CSS translate 属性:旧版安卓系统 WebView(Chrome 104 以下) // 不支持 translate,按 left/top 50% 定位会让面板偏到屏幕右下方,按钮点不到 className={cn( - "fixed inset-0 m-auto h-fit z-50 grid w-[calc(100%-2rem)] max-w-lg gap-4 rounded-2xl border bg-card p-6 shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", + "dialog-viewport-limit fixed inset-0 m-auto h-fit z-50 grid w-[calc(100%-2rem)] max-w-lg gap-4 rounded-2xl border bg-card p-6 shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", className )} {...props} @@ -79,7 +79,7 @@ const DialogFooter = ({ }: React.HTMLAttributes) => (