feat: use icons for files
All checks were successful
Deploy MinIO Explorer / deploy (push) Successful in 1m50s
All checks were successful
Deploy MinIO Explorer / deploy (push) Successful in 1m50s
This commit is contained in:
47
script.js
47
script.js
@@ -471,10 +471,11 @@ function createFileRow(file) {
|
||||
const row = document.createElement("tr");
|
||||
row.className = "clickable-row";
|
||||
const fileUrl = `${config.baseUrl}/${file.fullKey}`;
|
||||
const fileIcon = getFileIcon(file.name);
|
||||
|
||||
row.innerHTML = `
|
||||
<td>
|
||||
<span class="icon-file"></span>
|
||||
<span class="file-icon">${fileIcon}</span>
|
||||
<a href="#" class="file-link" data-file-url="${fileUrl}" data-file-name="${file.name}">${file.name}</a>
|
||||
</td>
|
||||
<td class="file-size">${formatFileSize(file.size)}</td>
|
||||
@@ -614,6 +615,50 @@ function detectFileType(fileName) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
function getFileIcon(fileName) {
|
||||
const extension = fileName.toLowerCase().split(".").pop();
|
||||
const fileType = detectFileType(fileName);
|
||||
|
||||
// Icônes spécifiques par extension
|
||||
const specificIcons = {
|
||||
pdf: "📕",
|
||||
zip: "📦", rar: "📦", "7z": "📦", tar: "📦", gz: "📦", bz2: "📦",
|
||||
mp4: "🎬", avi: "🎬", mov: "🎬", wmv: "🎬", flv: "🎬", webm: "🎬", mkv: "🎬",
|
||||
mp3: "🎵", wav: "🎵", ogg: "🎵", aac: "🎵", flac: "🎵", m4a: "🎵",
|
||||
jpg: "🖼️", jpeg: "🖼️", png: "🖼️", gif: "🖼️", bmp: "🖼️", svg: "🖼️", webp: "🖼️",
|
||||
txt: "📝", log: "📝",
|
||||
json: "⚙️", xml: "⚙️", csv: "📊",
|
||||
js: "🟨", ts: "🔷", jsx: "⚛️", tsx: "⚛️",
|
||||
py: "🐍", java: "☕", php: "🐘", rb: "💎", go: "🐹", rs: "🦀",
|
||||
html: "🌐", htm: "🌐", css: "🎨",
|
||||
vue: "💚", svelte: "🧡",
|
||||
md: "📖", markdown: "📖", rst: "📖",
|
||||
tex: "📄", latex: "📄",
|
||||
c: "⚡", cpp: "⚡",
|
||||
};
|
||||
|
||||
// Retourner l'icône spécifique si elle existe
|
||||
if (specificIcons[extension]) {
|
||||
return specificIcons[extension];
|
||||
}
|
||||
|
||||
// Sinon, retourner une icône par type
|
||||
const typeIcons = {
|
||||
images: "🖼️",
|
||||
text: "📝",
|
||||
code: "💻",
|
||||
markdown: "📖",
|
||||
rst: "📖",
|
||||
pdf: "📕",
|
||||
video: "🎬",
|
||||
audio: "🎵",
|
||||
archive: "📦",
|
||||
unknown: "📄"
|
||||
};
|
||||
|
||||
return typeIcons[fileType] || "📄";
|
||||
}
|
||||
|
||||
function showPreview(fileUrl, fileName) {
|
||||
currentPreviewFile = { url: fileUrl, name: fileName };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user