feat: 优化
This commit is contained in:
@@ -668,10 +668,13 @@ const handleBatchDelete = async () => {
|
||||
}
|
||||
|
||||
const formatFileSize = (size) => {
|
||||
if (size < 1024) return size + ' B'
|
||||
if (size < 1024 * 1024) return (size / 1024).toFixed(2) + ' KB'
|
||||
if (size < 1024 * 1024 * 1024) return (size / (1024 * 1024)).toFixed(2) + ' MB'
|
||||
return (size / (1024 * 1024 * 1024)).toFixed(2) + ' GB'
|
||||
const units = ['B', 'KB', 'MB', 'GB']
|
||||
let unitIndex = 0
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024
|
||||
unitIndex++
|
||||
}
|
||||
return `${size.toFixed(2)} ${units[unitIndex]}`
|
||||
}
|
||||
|
||||
const formatDate = (date) => {
|
||||
|
||||
@@ -19,7 +19,7 @@ function getBaseUrl() {
|
||||
}
|
||||
return ''
|
||||
}
|
||||
//
|
||||
|
||||
const BASE_URL = getBaseUrl()
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ export const isDev = () => {
|
||||
*/
|
||||
export function getApiUrl(module, path) {
|
||||
const base = API_BASE[module] || API_BASE.APP
|
||||
return `${base}${path.startsWith('/') ? path : '/' + path}`
|
||||
return `${base}${path.startsWith('/') ? '' : '/'}${path}`
|
||||
}
|
||||
|
||||
export default API_BASE
|
||||
|
||||
Reference in New Issue
Block a user