功能完善
This commit is contained in:
@@ -45,6 +45,25 @@ const isActive = computed(() => {
|
||||
return props.currentFilePath != null && props.currentFilePath === props.entry.path;
|
||||
});
|
||||
|
||||
// ── File type detection ─────────────────────────────────────
|
||||
const fileType = computed(() => {
|
||||
if (props.entry.is_dir) return "folder";
|
||||
const ext = props.entry.name.split(".").pop()?.toLowerCase();
|
||||
if (ext === "md") return "markdown";
|
||||
if (["png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "bmp", "ico"].includes(ext ?? "")) return "image";
|
||||
if (["mp4", "webm", "mov", "m4v", "ogv", "avi", "mkv"].includes(ext ?? "")) return "video";
|
||||
return "file";
|
||||
});
|
||||
|
||||
const fileIcon = computed(() => {
|
||||
switch (fileType.value) {
|
||||
case "markdown": return "ri-markdown-line";
|
||||
case "image": return "ri-image-line";
|
||||
case "video": return "ri-film-line";
|
||||
default: return "ri-file-line";
|
||||
}
|
||||
});
|
||||
|
||||
// ── Menu ─────────────────────────────────────────────────
|
||||
const menuOpen = ref(false);
|
||||
const menuRef = ref<HTMLElement | null>(null);
|
||||
@@ -176,7 +195,7 @@ function onClick() {
|
||||
class="tree-arrow ri-arrow-right-s-line text-sm transition-transform shrink-0"
|
||||
:class="expanded && entry.children ? 'rotate-90' : ''"
|
||||
></i>
|
||||
<i class="tree-entry-icon ri-folder-line text-base shrink-0"></i>
|
||||
<i class="tree-entry-icon ri-folder-2-line text-base shrink-0"></i>
|
||||
<span class="truncate flex-1 min-w-0">{{ entry.name }}</span>
|
||||
|
||||
<!-- More button -->
|
||||
@@ -251,7 +270,7 @@ function onClick() {
|
||||
:style="{ paddingLeft: `${depth * 16 + 8}px` }"
|
||||
@click="onClick"
|
||||
>
|
||||
<i class="tree-entry-icon ri-file-line text-sm shrink-0"></i>
|
||||
<i :class="['tree-entry-icon', fileIcon, 'text-sm shrink-0']"></i>
|
||||
<span class="truncate flex-1 min-w-0">{{ entry.name }}</span>
|
||||
|
||||
<!-- More button -->
|
||||
|
||||
Reference in New Issue
Block a user