feat: Add filtering for system files in FilePreview component
- Implemented function in to filter out and similar system files. - Updated rendering logic to ensure ignored files are not displayed in the frontend. - Ensured consistency with backend filtering logic for a seamless user experience. This change improves the frontend by preventing unnecessary or system files from being
This commit is contained in:
@@ -19,8 +19,40 @@ export function formatDuration(seconds) {
|
||||
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
// Hilfsfunktion zum Überprüfen ob eine Datei ignoriert werden soll
|
||||
export function shouldIgnoreFile(filename) {
|
||||
const ignoredFiles = [
|
||||
'.DS_Store', // macOS System file
|
||||
'Thumbs.db', // Windows Thumbnail cache
|
||||
'desktop.ini', // Windows Desktop configuration
|
||||
'.gitignore', // Git configuration
|
||||
'.gitkeep', // Git placeholder
|
||||
'config.yaml', // Configuration files
|
||||
'config.yml',
|
||||
'setup.yaml',
|
||||
'setup.yml',
|
||||
'.htaccess', // Apache configuration
|
||||
'web.config', // IIS configuration
|
||||
'.env', // Environment variables
|
||||
'.env.local',
|
||||
'README.md', // Documentation
|
||||
'readme.txt',
|
||||
'license.txt',
|
||||
'LICENSE'
|
||||
];
|
||||
|
||||
return ignoredFiles.some(ignored =>
|
||||
filename.toLowerCase() === ignored.toLowerCase()
|
||||
);
|
||||
}
|
||||
|
||||
// Datei-Vorschau-Komponente mit sofortiger Zoom-Skalierung und Loading-State
|
||||
export default function FilePreview({ file, zoom = 1, darkMode = false }) {
|
||||
// Frühe Rückgabe für ignorierte Dateien
|
||||
if (shouldIgnoreFile(file.name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [loaded, setLoaded] = React.useState(false);
|
||||
const width = file.width || 300;
|
||||
const height = file.height || 200;
|
||||
@@ -173,6 +205,10 @@ export default function FilePreview({ file, zoom = 1, darkMode = false }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// Sonstige Datei: Prüfen ob ignoriert werden soll
|
||||
if (shouldIgnoreFile(file.name)) {
|
||||
return null; // Ignorierte Dateien nicht anzeigen
|
||||
}
|
||||
// Sonstige Datei: Link
|
||||
return (
|
||||
<a href={file.url} target="_blank" rel="noopener noreferrer">{file.name}</a>
|
||||
|
||||
Reference in New Issue
Block a user