Fix file rename bugs and hide file extensions
All checks were successful
Automated Container Build / build-and-push (push) Successful in 34s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 34s
This commit is contained in:
parent
5200654d0f
commit
99e0cd5f0c
2 changed files with 51 additions and 17 deletions
|
|
@ -18,6 +18,12 @@ interface FilePreviewProps {
|
|||
onClose: () => void;
|
||||
}
|
||||
|
||||
function getFileDisplayName(name: string) {
|
||||
const dotIndex = name.lastIndexOf('.');
|
||||
if (dotIndex > 0) return name.substring(0, dotIndex);
|
||||
return name;
|
||||
}
|
||||
|
||||
export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
||||
const [content, setContent] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
|
@ -87,8 +93,8 @@ export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
|||
<div className="flex items-center justify-between px-4 py-3 border-b shrink-0" style={{ borderColor: 'var(--color-border-subtle)', backgroundColor: 'var(--color-bg-secondary)' }}>
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
{getIcon(previewType)}
|
||||
<span className="font-medium truncate" style={{ color: 'var(--color-text-primary)' }} title={file.name}>
|
||||
{file.name}
|
||||
<span className="font-medium truncate" style={{ color: 'var(--color-text-primary)' }} title={getFileDisplayName(file.name)}>
|
||||
{getFileDisplayName(file.name)}
|
||||
</span>
|
||||
<span className="text-xs px-2 py-1 rounded-md" style={{ backgroundColor: 'var(--color-bg-tertiary)', color: 'var(--color-text-tertiary)' }}>
|
||||
{formatSize(file.size)}
|
||||
|
|
@ -139,7 +145,7 @@ export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
|||
{previewType === 'audio' && (
|
||||
<div className="w-full max-w-md p-6 rounded-xl text-center" style={{ backgroundColor: 'var(--color-bg-elevated)', border: '1px solid var(--color-border)' }}>
|
||||
<Music className="w-16 h-16 mx-auto mb-6" style={{ color: 'var(--color-accent)' }} />
|
||||
<h3 className="text-lg font-medium mb-4 truncate" style={{ color: 'var(--color-text-primary)' }}>{file.name}</h3>
|
||||
<h3 className="text-lg font-medium mb-4 truncate" style={{ color: 'var(--color-text-primary)' }}>{getFileDisplayName(file.name)}</h3>
|
||||
<audio src={downloadUrl} controls autoPlay className="w-full outline-none" />
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
Reference in a new issue