mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 14:19:24 +00:00
- Store uploaded files as files/{ulid}/{original-name} instead of files/{ulid}/raw
- Store transcoded videos as {stem}-{resolution}.mp4 (e.g. foo-720p.mp4)
- Store transcoded images as {stem}-{width}p.webp (e.g. foo-1920p.webp)
- Add download?: boolean param to presign - only sets Content-Disposition: attachment when true
- Local storage handler only sets Content-Disposition when ?download=1 query param is present
- Add POST /api/files/download-url endpoint for key-based single file downloads
- Uses ResourceType.Asset for permission check
- Validates key belongs to the asset's storage directory
- Fix existing download-links API to pass download: true to presign
- Fix breadcrumb navbar download: video shows resolution submenu, others download directly
- Fix video player download: calls download-url API, shows correct file type label
- Remove filename query param hack from presign URLs
- Add sanitizeFilename() and stemFromKey() utility helpers
- Add key field to VideoTranscode DTO interface
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { create } from 'zustand'
|
|
import type { AncestorFolder } from '@shumai/dtos'
|
|
|
|
export interface TopNavProjectState {
|
|
teamId: string
|
|
projectId: string
|
|
projectName: string
|
|
ancestorFolders: AncestorFolder[]
|
|
currentAsset: {
|
|
name?: string
|
|
type: 'file' | 'folder'
|
|
version?: number
|
|
}
|
|
isRootFolder: boolean
|
|
fileId?: string
|
|
downloadInfo?: {
|
|
originalKey?: string
|
|
videoTranscodes?: Array<{
|
|
key: string
|
|
width: number
|
|
height: number
|
|
isRaw?: boolean
|
|
}>
|
|
}
|
|
versions?: Array<{
|
|
id: string
|
|
version: number
|
|
name?: string | null
|
|
previewUrl?: string | null
|
|
creator?: { id: string; name: string | null } | null
|
|
}>
|
|
isPublic?: boolean
|
|
shareId?: string
|
|
onFolderClick?: (folderId: string) => void
|
|
isRightSidebarCollapsed?: boolean
|
|
onRightSidebarToggle?: () => void
|
|
}
|
|
|
|
interface TopNavStore {
|
|
projectState: TopNavProjectState | null
|
|
setProjectState: (state: TopNavProjectState | null) => void
|
|
clearProjectState: () => void
|
|
}
|
|
|
|
let timeoutId: ReturnType<typeof setTimeout> | null = null
|
|
|
|
export const useTopNavStore = create<TopNavStore>((set) => ({
|
|
projectState: null,
|
|
setProjectState: (state) => {
|
|
if (timeoutId) {
|
|
clearTimeout(timeoutId)
|
|
timeoutId = null
|
|
}
|
|
set({ projectState: state })
|
|
},
|
|
clearProjectState: () => {
|
|
if (timeoutId) clearTimeout(timeoutId)
|
|
timeoutId = setTimeout(() => {
|
|
set({ projectState: null })
|
|
timeoutId = null
|
|
}, 10) // Small debounce to prevent flicker during transitions
|
|
},
|
|
}))
|