update document and unit of file size

This commit is contained in:
Kohaku-Blueleaf
2025-10-22 02:42:52 +08:00
parent 5ef51adb95
commit 8198d9e26c
4 changed files with 13 additions and 13 deletions

View File

@@ -176,7 +176,7 @@ async function handleFileSelect(event) {
}
// Validate file size (max 10MB)
if (file.size > 10 * 1024 * 1024) {
if (file.size > 10 * 1000 * 1000) {
ElMessage.error("Image is too large. Maximum size is 10MB");
return;
}

View File

@@ -133,7 +133,7 @@ const uploadData = computed(() => {
});
function beforeUpload(file) {
const maxSize = 100 * 1024 * 1024; // 100MB per file for regular upload
const maxSize = 100 * 1000 * 1000; // 100MB per file for regular upload
if (file.size > maxSize) {
ElMessage.warning(
`File ${file.name} is too large. Maximum size is 100MB per file.`,

View File

@@ -277,7 +277,7 @@ const branch = computed(() => route.params.branch || "main");
const filePath = computed(() => route.params.file || "");
// Constants
const maxPreviewSize = 100 * 1024; // 100KB
const maxPreviewSize = 100 * 1000; // 100KB
// State
const loading = ref(true);
@@ -497,11 +497,11 @@ function getFileIcon(filename) {
function formatSize(bytes) {
if (!bytes || bytes === 0) return "0 B";
if (bytes < 1024) return bytes + " B";
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + " KB";
if (bytes < 1024 * 1024 * 1024)
return (bytes / (1024 * 1024)).toFixed(1) + " MB";
return (bytes / (1024 * 1024 * 1024)).toFixed(1) + " GB";
if (bytes < 1000) return bytes + " B";
if (bytes < 1000 * 1000) return (bytes / 1000).toFixed(1) + " KB";
if (bytes < 1000 * 1000 * 1000)
return (bytes / (1000 * 1000)).toFixed(1) + " MB";
return (bytes / (1000 * 1000 * 1000)).toFixed(1) + " GB";
}
async function loadFileInfo() {

View File

@@ -138,9 +138,9 @@ export async function uploadLFSFile(repoId, file, sha256, onProgress) {
*/
export function formatFileSize(bytes) {
if (!bytes || bytes === 0) return "0 B";
if (bytes < 1024) return bytes + " B";
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + " KB";
if (bytes < 1024 * 1024 * 1024)
return (bytes / (1024 * 1024)).toFixed(1) + " MB";
return (bytes / (1024 * 1024 * 1024)).toFixed(1) + " GB";
if (bytes < 1000) return bytes + " B";
if (bytes < 1000 * 1000) return (bytes / 1000).toFixed(1) + " KB";
if (bytes < 1000 * 1000 * 1000)
return (bytes / (1000 * 1000)).toFixed(1) + " MB";
return (bytes / (1000 * 1000 * 1000)).toFixed(1) + " GB";
}