flat: 图片优化

This commit is contained in:
史典卓
2025-03-28 18:19:05 +08:00
parent 68e78d9624
commit b8ee5e7c17
43 changed files with 151 additions and 38 deletions

View File

@@ -433,6 +433,12 @@ function parseQueryParams(url = window.location.href) {
return params;
}
function formatFileSize(bytes) {
if (bytes < 1024) return bytes + ' B'
else if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB'
else if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(2) + ' MB'
else return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB'
}
export const $api = {
msg,
prePage,
@@ -442,7 +448,8 @@ export const $api = {
streamRequest,
chatRequest,
insertSortData,
uploadFile
uploadFile,
formatFileSize
}
export default {