From 8198d9e26cde06c3c79cfe410867ecd6709f8b7c Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Wed, 22 Oct 2025 02:42:52 +0800 Subject: [PATCH] update document and unit of file size --- .../src/components/profile/AvatarUpload.vue | 2 +- .../src/components/repo/FileUploader.vue | 2 +- .../[namespace]/[name]/blob/[branch]/[...file].vue | 12 ++++++------ src/kohaku-hub-ui/src/utils/lfs.js | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/kohaku-hub-ui/src/components/profile/AvatarUpload.vue b/src/kohaku-hub-ui/src/components/profile/AvatarUpload.vue index f6b29bf..48c0c45 100644 --- a/src/kohaku-hub-ui/src/components/profile/AvatarUpload.vue +++ b/src/kohaku-hub-ui/src/components/profile/AvatarUpload.vue @@ -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; } diff --git a/src/kohaku-hub-ui/src/components/repo/FileUploader.vue b/src/kohaku-hub-ui/src/components/repo/FileUploader.vue index 66357b7..531c268 100644 --- a/src/kohaku-hub-ui/src/components/repo/FileUploader.vue +++ b/src/kohaku-hub-ui/src/components/repo/FileUploader.vue @@ -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.`, diff --git a/src/kohaku-hub-ui/src/pages/[type]s/[namespace]/[name]/blob/[branch]/[...file].vue b/src/kohaku-hub-ui/src/pages/[type]s/[namespace]/[name]/blob/[branch]/[...file].vue index 0055350..235d1bf 100644 --- a/src/kohaku-hub-ui/src/pages/[type]s/[namespace]/[name]/blob/[branch]/[...file].vue +++ b/src/kohaku-hub-ui/src/pages/[type]s/[namespace]/[name]/blob/[branch]/[...file].vue @@ -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() { diff --git a/src/kohaku-hub-ui/src/utils/lfs.js b/src/kohaku-hub-ui/src/utils/lfs.js index 2c90311..1dc689c 100644 --- a/src/kohaku-hub-ui/src/utils/lfs.js +++ b/src/kohaku-hub-ui/src/utils/lfs.js @@ -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"; }