mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 23:54:25 +00:00
feat(webui): add compare versions view for version stacks
Add a Compare Versions mode to the file detail page (authenticated and public share) that splits the viewer into two 50/50 panes showing two versions side by side. - Breadcrumb file menu gains a Compare Versions entry (version stacks with >=2 versions); the file segment is hidden in compare mode. - URL-driven state (compare/cmpLeft/cmpRight/cmpActive) on both file routes so the view is refresh/share-safe. - Per-side topbar with filename, version, version-switch dropdown, an active-side highlight, and an X exit button. - Shared control bar reflects the active pane; for same-type media it coordinates both panes (play/pause, seek, frame-step, zoom, pan sync), seekbar length matches the active side while the shorter side holds its last frame; only the active side plays audio; resolution/download apply to the active side; fullscreen covers the whole compare view. - Right sidebar (comments/fields) binds to the active side; comment selection seeks the active pane and annotations/comments can be created. - Reuses useFramePlayer + DrawingCanvas without modifying the existing single-file video player. - Unit tests for compare selection/clamp logic.
This commit is contained in:
@@ -23,7 +23,7 @@ import { cn } from '@/ui/lib/utils'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import type { AncestorFolder } from '@shumai/dtos'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { Check, ChevronDown, FileIcon, History, LayoutGrid, List } from 'lucide-react'
|
||||
import { Check, ChevronDown, Columns2, FileIcon, History, LayoutGrid, List } from 'lucide-react'
|
||||
|
||||
interface BreadcrumbNavProps {
|
||||
teamId: string
|
||||
@@ -62,6 +62,9 @@ interface BreadcrumbNavProps {
|
||||
previewUrl?: string | null
|
||||
creator?: { id: string; name: string | null } | null
|
||||
}>
|
||||
compareMode?: boolean
|
||||
canCompareVersions?: boolean
|
||||
onCompareVersions?: () => void
|
||||
}
|
||||
|
||||
export function BreadcrumbNav({
|
||||
@@ -83,6 +86,9 @@ export function BreadcrumbNav({
|
||||
shareId,
|
||||
downloadInfo,
|
||||
versions,
|
||||
compareMode = false,
|
||||
canCompareVersions = false,
|
||||
onCompareVersions,
|
||||
}: BreadcrumbNavProps) {
|
||||
const navigate = useNavigate()
|
||||
const { canEdit } = usePermissions(projectId)
|
||||
@@ -176,7 +182,7 @@ export function BreadcrumbNav({
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{!isRootFolder && (
|
||||
{!isRootFolder && !compareMode && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-muted-foreground">/</span>
|
||||
{currentAsset.type === 'folder' ? (
|
||||
@@ -263,6 +269,16 @@ export function BreadcrumbNav({
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
|
||||
{canCompareVersions && onCompareVersions && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onClick={() => onCompareVersions()}>
|
||||
<Columns2 className="h-4 w-4" />
|
||||
<span>{m.compare_versions()}</span>
|
||||
</DropdownMenuItem>
|
||||
</>
|
||||
)}
|
||||
|
||||
{versions && versions.length > 0 && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
Reference in New Issue
Block a user