mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +00:00
feat(webui): add mobile friendly file detail and public share view (#359)
* feat(webui): add mobile friendly file detail and public share view * fix(webui): address review feedback for mobile file detail and public share view * fix(webui): use dynamic viewport and flex column layout for mobile file viewer * fix(webui): support iOS WebKit video fullscreen and guard requestFullscreen * fix(webui): compact page indicator and layout in mobile PDF control bar
This commit is contained in:
@@ -28,24 +28,29 @@ export function PdfControlBar({
|
||||
allowDownload = true,
|
||||
}: PdfControlBarProps) {
|
||||
return (
|
||||
<div className="relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-between gap-2 transition-colors duration-200">
|
||||
<div className="relative px-2 py-2 sm:px-4 sm:py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-between gap-1.5 sm:gap-2 transition-colors duration-200 shrink-0">
|
||||
{/* Page Navigation */}
|
||||
<div className="flex items-center gap-1.5 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5">
|
||||
<div className="flex items-center gap-1 sm:gap-1.5 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5 shrink-0">
|
||||
<button
|
||||
onClick={() => onPageChange(Math.max(1, currentPage - 1))}
|
||||
disabled={currentPage <= 1}
|
||||
className="p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40"
|
||||
className="p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40"
|
||||
title={m.previous_page()}
|
||||
>
|
||||
<ChevronLeft size={16} />
|
||||
</button>
|
||||
<span className="px-2 text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none">
|
||||
{m.page_of_pages({ current: currentPage, total: totalPages || 1 })}
|
||||
<span className="px-1 sm:px-2 text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none whitespace-nowrap">
|
||||
<span className="hidden sm:inline">
|
||||
{m.page_of_pages({ current: currentPage, total: totalPages || 1 })}
|
||||
</span>
|
||||
<span className="inline sm:hidden">
|
||||
{currentPage}/{totalPages || 1}
|
||||
</span>
|
||||
</span>
|
||||
<button
|
||||
onClick={() => onPageChange(Math.min(totalPages, currentPage + 1))}
|
||||
disabled={currentPage >= totalPages}
|
||||
className="p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40"
|
||||
className="p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40"
|
||||
title={m.next_page()}
|
||||
>
|
||||
<ChevronRight size={16} />
|
||||
@@ -53,21 +58,21 @@ export function PdfControlBar({
|
||||
</div>
|
||||
|
||||
{/* Zoom & Action Controls */}
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5">
|
||||
<div className="flex items-center gap-1 sm:gap-2 shrink-0">
|
||||
<div className="flex items-center gap-0.5 sm:gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5">
|
||||
<button
|
||||
onClick={onZoomOut}
|
||||
className="p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors"
|
||||
className="p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors"
|
||||
title={m.zoom_out()}
|
||||
>
|
||||
<Minus size={16} />
|
||||
</button>
|
||||
<span className="w-12 text-center text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none">
|
||||
<span className="w-10 sm:w-12 text-center text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none">
|
||||
{Math.round(zoom * 100)}%
|
||||
</span>
|
||||
<button
|
||||
onClick={onZoomIn}
|
||||
className="p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors"
|
||||
className="p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors"
|
||||
title={m.zoom_in()}
|
||||
>
|
||||
<Plus size={16} />
|
||||
@@ -75,7 +80,7 @@ export function PdfControlBar({
|
||||
</div>
|
||||
<button
|
||||
onClick={onFit}
|
||||
className="text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent"
|
||||
className="text-xs font-medium px-2 py-1 sm:px-3 sm:py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent"
|
||||
>
|
||||
{m.fit()}
|
||||
</button>
|
||||
@@ -83,11 +88,11 @@ export function PdfControlBar({
|
||||
<button
|
||||
onClick={onDownload}
|
||||
disabled={!canDownload}
|
||||
className="flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50"
|
||||
className="flex items-center gap-1 text-xs font-medium px-2 py-1 sm:px-3 sm:py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50"
|
||||
title={m.download_original_file()}
|
||||
>
|
||||
<Download size={14} />
|
||||
{m.download()}
|
||||
<span className="hidden sm:inline">{m.download()}</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -20,13 +20,19 @@ const MAX_RENDER_PIXELS = 32_000_000
|
||||
const MAX_RENDER_SCALE = 16
|
||||
|
||||
if (typeof window !== 'undefined' && pdfjsLib.GlobalWorkerOptions) {
|
||||
const workerPath =
|
||||
typeof pdfworker === 'string'
|
||||
? pdfworker.startsWith('/')
|
||||
? pdfworker
|
||||
: '/' + pdfworker.replace(/^\.\//, '')
|
||||
: pdfworker
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = workerPath
|
||||
try {
|
||||
const workerPath =
|
||||
typeof pdfworker === 'string'
|
||||
? pdfworker.startsWith('/')
|
||||
? pdfworker
|
||||
: '/' + pdfworker.replace(/^\.\//, '')
|
||||
: (pdfworker as unknown as string)
|
||||
if (typeof workerPath === 'string') {
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = workerPath
|
||||
}
|
||||
} catch {
|
||||
// Ignore in test/non-standard environments
|
||||
}
|
||||
}
|
||||
|
||||
export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
|
||||
Reference in New Issue
Block a user