<template>
  <div class="file-item">
    <div class="file-icon">
      <FileIcon :file="file" />
    </div>
    <div class="file-name">{{ file.name }}</div>
    <div class="file-info">
      <div class="file-last-modified">
        {{ new Date(file.lastModified).toLocaleString() }}
      </div>
      <div class="file-meta">
        {{ file.isDirectory ? "" : formatSize(file.size) }}
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { FileInfo } from "../utils/fileMgr";
import FileIcon from "./fileIcon.vue";
import { formatSize } from "../utils/common";
const props = defineProps<{
  file: FileInfo;
}>();
</script>
<style scoped>
.file-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}
.file-icon {
  width: 24px;
  height: 24px;
}
.file-name {
  flex: 1;
  margin-left: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: 10px;
}
</style>
