feat: update
This commit is contained in:
@@ -189,17 +189,15 @@ const getFileIcon = (file) => {
|
|||||||
|
|
||||||
// Format file size helper
|
// Format file size helper
|
||||||
const formatFileSize = (bytes) => {
|
const formatFileSize = (bytes) => {
|
||||||
if (bytes === 0) return '0 B';
|
if (!bytes && bytes !== 0) return '0 B';
|
||||||
const k = BigInt(1024);
|
|
||||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
const bytesValue = BigInt(bytes);
|
const base = 1024;
|
||||||
let i = 0;
|
let size = Number(bytes);
|
||||||
let size = bytesValue;
|
if (isNaN(size)) return '0 B';
|
||||||
while (size >= k && i < sizes.length - 1) {
|
|
||||||
size = size / k;
|
const i = Math.floor(Math.log(size) / Math.log(base));
|
||||||
i++;
|
size = size / Math.pow(base, i);
|
||||||
}
|
return `${size.toFixed(2)} ${sizes[i]}`;
|
||||||
return `${Number(size).toLocaleString('en-US')} ${sizes[i]}`;
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -271,16 +269,17 @@ const formatFileSize = (bytes) => {
|
|||||||
class="relative border border-gray-200 rounded-md p-2 flex items-center">
|
class="relative border border-gray-200 rounded-md p-2 flex items-center">
|
||||||
<div v-if="media.thumbnailUrl" class="flex-shrink-0 h-10 w-10 mr-3">
|
<div v-if="media.thumbnailUrl" class="flex-shrink-0 h-10 w-10 mr-3">
|
||||||
<img class="h-10 w-10 object-cover rounded" :src="media.thumbnailUrl"
|
<img class="h-10 w-10 object-cover rounded" :src="media.thumbnailUrl"
|
||||||
:alt="media.fileName">
|
:alt="media.file_name">
|
||||||
</div>
|
</div>
|
||||||
<div v-else
|
<div v-else
|
||||||
class="flex-shrink-0 h-10 w-10 mr-3 bg-gray-100 rounded flex items-center justify-center">
|
class="flex-shrink-0 h-10 w-10 mr-3 bg-gray-100 rounded flex items-center justify-center">
|
||||||
<i :class="getFileIcon(media)" class="text-2xl"></i>
|
<i :class="getFileIcon(media)" class="text-2xl"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 overflow-hidden">
|
<div class="flex-1 overflow-hidden">
|
||||||
<div class="text-sm font-medium text-gray-900 truncate">{{ media.fileName }}
|
<div class="text-sm font-medium text-gray-900 truncate">
|
||||||
|
{{ media.name }}
|
||||||
</div>
|
</div>
|
||||||
<Badge :value="media.fileType" :severity="getBadgeSeverity(media.fileType)"
|
<Badge :value="media.file_type" :severity="getBadgeSeverity(media.file_type)"
|
||||||
class="text-xs" />
|
class="text-xs" />
|
||||||
</div>
|
</div>
|
||||||
<Button icon="pi pi-times" class="p-button-rounded p-button-text p-button-sm"
|
<Button icon="pi pi-times" class="p-button-rounded p-button-text p-button-sm"
|
||||||
@@ -334,32 +333,28 @@ const formatFileSize = (bytes) => {
|
|||||||
|
|
||||||
<Column field="fileName" header="文件名">
|
<Column field="fileName" header="文件名">
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
<div class="flex items-center">
|
<div class="text-sm font-medium text-gray-900">{{ data.name }}</div>
|
||||||
<div v-if="data.thumbnailUrl" class="flex-shrink-0 h-10 w-10 mr-3">
|
|
||||||
<img class="h-10 w-10 object-cover rounded" :src="data.thumbnailUrl" :alt="data.fileName">
|
|
||||||
</div>
|
|
||||||
<div v-else
|
|
||||||
class="flex-shrink-0 h-10 w-10 mr-3 bg-gray-100 rounded flex items-center justify-center">
|
|
||||||
<i :class="getFileIcon(data)" class="text-2xl"></i>
|
|
||||||
</div>
|
|
||||||
<div class="text-sm font-medium text-gray-900">{{ data.fileName }}</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
<Column field="fileType" header="文件类型">
|
<Column field="fileType" header="文件类型">
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
<Badge :value="data.fileType" :severity="getBadgeSeverity(data.fileType)" />
|
<Badge :value="data.file_type" :severity="getBadgeSeverity(data.file_type)" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
<Column field="file_size" header="文件大小">
|
<Column field="fileSize" header="文件大小">
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
{{ formatFileSize(data.file_size) }}
|
{{ formatFileSize(data.file_size) }}
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
<Column field="uploadTime" header="上传时间"></Column>
|
<Column field="createdAt" header="上传时间">
|
||||||
|
<template #body="{ data }">
|
||||||
|
{{ new Date(data.upload_time).toLocaleString('zh-CN') }}
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|||||||
Reference in New Issue
Block a user