mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 21:44:27 +00:00
feat(share): add allow download config to share links (#275)
* feat(share): add allow download config to share links * fix(share): hide download in public share list page when disabled
This commit is contained in:
@@ -4,7 +4,7 @@ import React, { useImperativeHandle } from 'react'
|
||||
import { FileViewerProps, MediaController } from '../types'
|
||||
|
||||
export const DefaultViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
({ file, shareId, children }, ref) => {
|
||||
({ file, shareId, children, allowDownload = true }, ref) => {
|
||||
// Implement no-op media controller
|
||||
useImperativeHandle(ref, () => ({
|
||||
play: () => {},
|
||||
@@ -46,15 +46,17 @@ export const DefaultViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
</div>
|
||||
</div>
|
||||
<div className="relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-end gap-2 transition-colors duration-200">
|
||||
<button
|
||||
onClick={handleDownload}
|
||||
disabled={!file.media?.original?.key}
|
||||
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 animate-in fade-in zoom-in-95 duration-200"
|
||||
title="Download original file"
|
||||
>
|
||||
<Download size={14} />
|
||||
Download
|
||||
</button>
|
||||
{allowDownload && (
|
||||
<button
|
||||
onClick={handleDownload}
|
||||
disabled={!file.media?.original?.key}
|
||||
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 animate-in fade-in zoom-in-95 duration-200"
|
||||
title="Download original file"
|
||||
>
|
||||
<Download size={14} />
|
||||
Download
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user